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