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

21 comments:

Donji said...

Will this work with MQTT and if it did, how do you think it would perform differently from your XMPP setup.
I want to make a portable smart locker with a 3G connection, solar panel, and a small E-ink display, but I want the battery to last for at least 8 hours, 3 days if possible with the solar panel.

I don't know a lot about computers, so forgive me if this is a stupid question.

ADAV said...

So far, i havent looked at MQTT. It should be possible to replace the XMPP daemon of Rbox with MQTT daemon, but i am not sure if this would have any impact on raspi-zero power consumption.

In my setup, linux on raspi is not tweaked for low power idle mode - linux continues to run all the time. So i cant comment how MQTT would help in reducing the power consumption.

assignment help service said...

it is offered by any official producer of such gadgets or you have made it on your own. how can i get one of these? if in case i need it ?

CT Solutions Highlands Ranch CO said...

very useful device for keep data saved.because due to many reasons data are not saved.so, we can use these type of devices

Online coursework said...

Help with Search Engine Optimization? I'm attempting to get my blog to rank for some focused on catchphrases yet I'm not seeing great outcomes. In the event that you are aware of any please share. Much obliged

http://www.needdissertation.co.uk/Nursing-dissertation/ said...

It is possible to boot your custom linux as read-only to avoid sd-data corruption because of power cuts. This allows your raspi zero and custom linux act as an embedded device which can sustain the power cuts.

Dissertation Writing Service said...

I think that working with your office will be good for me and I will learn many essay writing with you. I hope it is true that whatever you’ve written here and will help us all. 

Sophie Grace said...
This comment has been removed by a blog administrator.
Thanapong Phanthong said...

Can I use raspberry PI zero version 1.1?

online assignment help said...

A great work indeed at least to say. It Must get acknowledgement from us. Take a bow.

hobart plasma cutter said...

https://plasmacutterinsider.com/best-hobart-plasma-cutter/;When I originally commented I appear to have clicked on the -Notify me when new comments are added- checkbox and from now on each time a comment is added I get four emails with the exact same comment. Is there an easy method you are able to remove me from that service? Cheers!

mcdonalds swot analysis said...

It's far supplied by means of any respectable manufacturer of such devices or you have got made it on your personal. How can i am getting this sort of? If in case i need it ?

best-cheap-mechanical-keyboards said...

I truly love your blog.. Excellent colors & theme. Did you create this website yourself? Please reply back as I’m planning to create my own personal website and would love to learn where you got this from or what the theme is called. Kudos!

best-cheap-gaming-chair said...

It’s difficult to find well-informed people in this particular subject, however, you seem like you know what you’re talking about! Thanks

best-cheap-wireless-mouses said...

I really love your website.. Excellent colors & theme. Did you develop this site yourself? Please reply back as I’m attempting to create my own blog and would like to know where you got this from or just what the theme is named. Many thanks!

best-cheap-24-inch-monitors said...

Pretty! This was an extremely wonderful post. Many thanks for supplying this info.

best-straightening-brushes said...

Spot on with this write-up, I actually believe that this web site needs much more attention. I’ll probably be returning to see more, thanks for the info!

best-cheap-gaming-headsets said...

Hi there! This blog post couldn’t be written any better! Reading through this post reminds me of my previous roommate! He constantly kept talking about this. I most certainly will send this article to him. Fairly certain he will have a good read. Thank you for sharing!

best-cheap-mechanical-keyboards said...

I have to thank you for the efforts you've put in penning this site. I really hope to view the same high-grade blog posts by you later on as well. In truth, your creative writing abilities has inspired me to get my very own blog now ;)

best-cheap-mechanical-keyboards said...

This is the perfect webpage for anyone who hopes to understand this topic. You realize so much its almost hard to argue with you (not that I really would want to…HaHa). You definitely put a brand new spin on a subject which has been written about for ages. Wonderful stuff, just wonderful!

UML Assignment Help said...

Myself Layla Castillo, a blogger and freelance content writer working with NeedAssignmentHelp. For any information, call or whatsapp @ +1 (205) 9006105