Saturday, January 06, 2018

DIY Router UPS for Under $2 with a Battery Bank

A low-cost uninterruptible power supply for your broadband Wi-Fi router using a USB battery bank and a 5 V to 12 V DC boost cable (~1 EUR from AliExpress). Keeps your router running through short power outages so you don't lose calls or downloads while the backup generator kicks in.

The boost cable

A USB 5 V to DC 12 V step-up cable with a 2.1 × 5.5 mm barrel connector — sold for about 1 EUR including shipping.

USB 5V to 12V DC boost cable

USB 5 V to 12 V boost cable — the black housing contains an MT3068 converter PCB.

MT3068 boost converter PCB inside the cable housing

Inside the housing — MT3068-based boost converter.

This cable provides up to ~8 W output, which is enough for a standard broadband router. If your router draws more than 8 W, look for a higher-capacity boost cable.

Setup

Connect a 5 V DC adapter to the battery bank's charging port. The battery bank's USB output feeds the boost cable, which powers the router at 12 V.

Complete UPS setup — adapter, battery bank, boost cable, and router

Complete setup — 5 V adapter charges the battery bank, which powers the router through the boost cable.

Backup duration depends on the battery bank capacity. A smaller battery handles short outages (a few minutes while a generator starts); a larger one extends runtime for longer outages.

Sunday, December 31, 2017

Remote Home Access with a 5-Euro Pocket Router

How to turn a ~5€ A5-V11 pocket router into an XMPP chat-bot that lets you remotely access and control your home network from a smartphone — no port forwarding or dynamic DNS required.

Why the A5-V11?

In the quest for the cheapest off-the-shelf Linux hardware, the A5-V11 pocket router stands out — it consumes just ~0.3W, making it ideal for always-on IoT applications.

CPU360 MHz MIPS (Ralink RT5350)
RAM32 MB SDRAM
Flash4 MB
Ethernet100 Mbit
Wi-FiIEEE 802.11b/g/n
USB1 port for peripherals
LEDsRed and blue status indicators
A5-V11 pocket router overview

The A5-V11 pocket router — a ~5€ Linux device consuming just 0.3W.

How it works

The custom a5v11-xmpp firmware strips down most router/Wi-Fi functionality to fit an XMPP chat client daemon (based on lib-gloox) that acts as a chat-bot. XMPP makes it easy to access your home network without tweaking your home router settings — no port forwarding or NAT configuration needed.

Keep this device connected to your home internet and "chat" with it from anywhere using the Xabber app on your smartphone.

Setup instructions

Step 1 — Create two XMPP/Jabber accounts (master and slave) on your favorite Jabber server as explained here. Add both accounts as friends so the XMPP server can pass messages between them.

Step 2 — Connect a CAT-5/6 cable between your PC and the A5-V11 router, then power it on.

Step 3 — Flash the stock firmware with the a5v11-xmpp image. Follow the step-by-step guide in this blog post (also see the OpenWrt wiki for general instructions).

Step 4 — Connect the A5-V11 router to your home router's network (internet).

Step 5 — Log in via SSH to host my-a5v11 (user: root, default password: brb0x).

Step 6 — Configure the XMPP login details:

echo "user: test-slave-account@xabber.de" >/etc/xmproxy/xmpp-login.txt
echo "pw: chatbotpw" >>/etc/xmproxy/xmpp-login.txt
reboot

Important: Replace the test account details with your own credentials. Also use passwd to change the default root password.

Step 7 — Install Xabber on your smartphone and log in with the master account.

Step 8 — You should see the A5-V11 router appear online in Xabber. Send help to get a list of available commands.

Use cases

1. Get your public IP — Send publicip and the chat-bot responds with your home router's public IP. No dynamic DNS needed.

2. I2C peripheral control — Connect an i2c-tiny-usb adapter to the USB port for controlling sensors, GPIO expanders, and other I2C devices:

shellcmd i2cdetect -r -y 0       # scan for I2C devices
shellcmdresp                      # read the scan result
shellcmd i2cset -f -y 1 0x3c 0x00 0xff b   # set PCF8574 pins high
A5-V11 with i2c-tiny-usb adapter connected

A5-V11 with i2c-tiny-usb adapter for peripheral control.

3. Sonoff relay control — Control Sonoff Wi-Fi relays running Tasmota firmware on your local network:

sonoff 192.168.1.10 on       # switch ON
sonoff 192.168.1.10 off      # switch OFF
sonoff 192.168.1.10 toggle   # toggle
sonoff 192.168.1.10          # read current state

4. Remote SSH commands — Trigger commands on other Linux machines via sshpass:

shellcmd sshpass -praspberry ssh -y pi@raspi-ip sudo reboot
shellcmd sshpass -praspberry ssh -y pi@raspi-ip sudo poweroff
shellcmd sshpass -praspberry ssh -y pi@raspi-ip omxplayer /tmp/video.mp4

5. Wake-on-LAN — Power on a PC that supports WoL:

shellcmd etherwake 00:00:DE:AD:BE:EF

SOURCE CODE

github.com/hackboxguy/lede-a5v11 — build instructions and sources

a5v11-xmpp.uimg — pre-built firmware image

Friday, September 16, 2016

Battery-Powered IoT Device with Pi Zero and 3G

A compact, battery-powered IoT device built from a Raspberry Pi Zero, a Huawei E173 USB 3G modem, and a prepaid SIM card. RBox — a lightweight Buildroot-based Linux distribution (~25 MB) — boots from the SD card, connects to the internet over 3G, and runs an XMPP chat-bot so you can monitor and control the device from your phone's chat app.

Compact Pi Zero IoT setup — top view

Compact stacked setup — Pi Zero, USB 3G modem, and 5200 mAh battery pack.

Pi Zero IoT setup — side view
Pi Zero IoT setup — rear view
Pi Zero IoT setup — detail view

What happens at boot

  1. usb_modeswitch switches the 3G modem from mass-storage mode to modem mode
  2. umts-keeper + sakis3g establish and maintain the 3G internet connection
  3. The XMPP chat-bot daemon (built on gloox, a C++ XMPP library) logs in to a Jabber server
  4. You can now communicate with the Pi Zero from your Android Xabber app (or any XMPP client)

Features

  • Total cost under ~50 EUR (Pi Zero + SD card + 3G stick + SIM + battery)
  • Read-only root filesystem — power cuts do not corrupt the SD card
  • Over-the-air Linux image upgrade via XMPP chat message (~25 MB per upgrade)
  • No cloud service, port forwarding, or dynamic DNS required — just two Jabber accounts
  • Send/receive SMS and dial USSD codes via chat messages
  • Control GPIO pins with get/set commands
  • Execute shell commands remotely via chat
  • Multiple XMPP accounts can control the same device simultaneously

Use cases

  • SMS gateway — deploy at home with a local prepaid SIM, access SMS from anywhere via Jabber
  • Weather station — deploy in a 3G coverage area with solar panel and sensors
  • Fleet management — place in vehicles with a GPS sensor, track from a central PC
  • Wildlife monitoring — deploy with a camera in a GSM-covered area
  • Digital signage — control display content remotely via chat
  • Anti-theft tracker — for cars, boats, caravans — sends GPS coordinates when movement is detected
  • Home automation — monitor temperature/humidity, control relays via GPIO

FAQ

How much 3G data does this use?
With no chat traffic, only XMPP heartbeat packets are sent — typically a few hundred kilobytes per day.

How long does the battery last?
A fully charged 5200 mAh battery keeps the setup running for 8–10 hours. Use a higher-capacity battery for longer runtime.

Can I deploy this off-grid?
Yes, with a larger battery and solar panel. Ensure the location has 3G coverage.

What happens if power fails during an OTA update?
RBox writes the new image to the non-active partition, then flips the boot flag and reboots. A power failure during the write leaves the active partition untouched.

Why the stacked form factor?
A compact rectangular brick is easier to enclose in a 3D-printed case than dangling cables.

Comparison — old setup with dangling cables vs compact stacked setup

Old setup (left) vs compact stacked setup (right).

How much does this cost to run?
Total hardware cost is under 50 EUR. A 100 MB / 30-day prepaid data plan (e.g. ~2 EUR/month with Congstar in Germany) is sufficient for basic I/O control and command traffic.

Items needed

  • Raspberry Pi Zero v1.3
  • Huawei E173 USB 3G modem
  • 8 GB SD card
  • Battery pack (5200 mAh or larger)
  • Four pogo pins
  • General-purpose PCB
  • PCB-mountable USB male and female connectors

SD card setup

  1. Create two XMPP accounts on a public Jabber server (tested with jabber.de, xabber.de, ubuntu-jabber.de) and authorize them to chat with each other
  2. Download the RBox SD card image
  3. Decompress with 7-Zip or your preferred tool
  4. Write the image to the SD card using Win32DiskImager or similar
  5. Remove and re-insert the SD card — a boot drive appears
  6. Create xmpp-login.txt on the boot drive using this template — replace the sample credentials with your device's XMPP username and password (update APN details for your carrier)
  7. Insert the SD card into the Pi Zero and power on — wait 2–3 minutes for the 3G modem LED to glow solid blue
  8. On your phone, open Xabber and log in with the master XMPP account
  9. The Pi Zero should appear online — send Help to see the list of available commands
  10. Send Sysupdate;reboot to update to the latest RBox image — see the full command reference
  11. For graceful shutdown, send poweroff and wait for the 3G modem LED to turn off

SOURCE CODE

github.com/hackboxguy/brbox — RBox sources and build instructions

Pi Zero build instructions — generate the binary image from source