Friday, September 16, 2016

RBox - Raspberry pi Zero + USB 3G internet + XMPP = awesome IoT device

RBox - its a lightweight linux distribution built with buildroot. Current update binary size of RBox is around 25MB.

Here is my compact IoT setup based on Pi Zero + 3G usb Modem +prepaid SIM card+ 5200mAH battery pack.






What does this setup do?
SDCard in this Pi-Zero boots RBox linux image, during linux bootup following activities happen.

  1. usb_modeswitch switches the usb 3G modem to act as modem instead of default memory stick behaviour.
  2. umts-keeper along with sakis3g script would establish internet connection and keeps the connection alive.
  3. gloox, c++ library based daemon starts and logs in to a jabber server using preset xmpp login username and password. this xmpp daemon acts as a chat-bot.
  4. using android xabber app, communicate and control your pi-zero-IoT setup using chat messages.


What is so special about this setup?

  1. very low cost setup < 50Euro(PI_zero + sdcard + 3g_stick+sim_card+battery_pack)
  2. linux image is mounted as read-only, power cut doesnt harm the sdcard data.
  3. OTA linux image upgrade - full linux image upgrade over-the-air can be triggered by sending xmpp chat message.
  4. No need to have special cloud based service or opening-up-the port on internet with special dyndns registration. you just need two xmpp(jabber) or gmail accounts. one for pi-zero, second one for your mobile phone.
  5. possible to dial ussd codes via xmpp chat message for knowing the balance amount of prepaid sim card.
  6. possible to send/receive sms from your 3g-stick using xmpp chat messages.
  7. acts as a sms-gateway with xmpp based remote access for sms sending and receiving.
  8. possible to control pi-zero gpio's by sending get/set-gpio chat messages.
  9. possible to execute shell commands on pi-zero by sending  chat messages.

What are the typical application's of this setup?
  1. sms gateway - deploy this setup in your home country having local prepaid sim card, access your sms from anywhere in the world by sending jabber chat messages.
  2. weather station - deploy this setup within the 3g coverage area of your sim provider, along with solar panel and weather sensors, monitor the parameters by sending xmpp/jabber chat messages.
  3. fleet management - place this setup in your taxi/truck along with gps sensor, keep track of all your vehicles from a centralized control PC.
  4. wildlife monitoring - place this setup(along with camera) in 3G/Gsm covered forest area, monitor the activity of animals and take a picture and upload it on a cloud server.
  5. Remote asset management(e.g digital signage) - deploy this setup along with digital-signage display, control the content of your signage display by sending xmpp chat messages.
  6. Anti theft device - for cars, boats, mobile homes and caravans. let this device send you gps co-ordinates as chat messages when the pi-zero starts moving.
  7. Home automation - keep track of your holiday home, monitor temperature/humidity and control the relay's via gpio for switching on/off various devices.
  8. many more..


FAQ:
1) how much 3g data is consumed with this setup?
Ans: if there is no chat-message traffic to this setup, there is just xmpp-heart-beat packet sent to the jabber server(in my case typical usage per day is around few hundred kilo bytes).

2)how long does the battery backup last?
Ans: i have 5200mAH battery, fully charged battery kept my setup alive for about 8 to 10hours(you can have higher capacity battery for increased backup time).

3)Can i deploy this setup in a off the grid remote location?
Ans: ensure that you have higher capacity battery along with large solar panel(especially during winter with very low sun light  condition, you might need extra juice to keep setup running). Also Ensure that your setup is in 3G coverage area.

4)Is this project open source? where can i find the sources? how can i build the binary image myself?
Ans: yes, source code is hosted at this github location. Instructions for creating the binary image is given in the github location.

5)If i do, Over-The-Air linux image update, will this consume lot of my 3g-Data? 
Ans: yes, compared to normal xmpp traffic, linux image Over-The-Air update consume about 25MB data per upgrade, but then, how frequently would you be upgrading linux image? if you keep on adding new features, you might want to do frequent upgrades.

6)What happens if battery or power to pi-zero goes off during Over-The-Air linux image upgrade? will this brick my remotely deployed pi zero?
Ans:Rbox upgrade mechanism reduced the chances of bricking. During the upgrade process, non-active partition is programmed with new image. After the image is written to non-active partition, boot flag is flipped and pi reboots with updated partition.

7)I see that you have stacked up pi-zero/3g-stick/battery, why did u do that? wouldn't this be simpler to use pi-zero-included mini-usb-to-usb-converter?
Ans: yes, initially i did this, this is how my old and new setup looks, i like the compact setup instead of dangling wires, moreover rectangular brick shaped setup is easy for designing a 3D printed case.


8) I see that you are distributing ready to use bootable-binary-disk-image, but what if i want to build the image by myself from sources?
Ans: Here are details for generating binary from sources.

9) what about two or more xmpp accounts controlling this pi-zero-IoT setup? will this work?
Ans: Yes, Raspi0 acts as an xmpp-chat-bot, like typical xmmp-chat-scenario between humans, raspi can have multiple "friends" authorized to send/receive messages. e.g: you and your wife having separate xmpp/jabber accounts can trigger house-door-opening after kids arrival from school. Similarly, raspi can send asynchronous chat message to multiple subscribers on an I/O event(e.g when kids ring the door bell).

10)How much does this setup cost? what are the running costs?
Ans: Total cost including all components and prepaid simcard shall not be more than 50Euros.   Having a prepaid sim with around 100MB/30days data plan would be sufficient to keep the setup alive with basic I/O control and command traffic. Here in Germany, congstar charges 2Euros for a data plan of 100MB/30days. You need to decide for yourself based on your data-usage and provider's data plan.

11) I want to re-create the exact setup of your's, what parts do i need and what are the steps for creating sd card?
Ans: Items needed

  1. Raspberry pi zero v1.3
  2. Huawei E173 usb-3g-modem
  3. 8gb sdcard
  4. battery-pack
  5. four pogo pins
  6. general purpose pcb
  7. pcb mountable usb male and female connectors
SDCard Image creation:

  1. First and foremost is to have two xmpp login accounts on publicly available jabber servers(So far RBox has been tested with jabber.de/xabber.de and ubuntu-jabber.de). Follow my previous Post on how to create master and slave xmpp accounts(ensure that master/slave accounts have authorized each other to send/receive messages).
  2. Download the initial SDCard Image from here.
  3. Unzip the downloaded xz image using 7zip or your favorite decompression tool.
  4. Write the unzipped binary image to Sdcard using Win32DiskImager
  5. After writing the image to SDCard, remove and re-insert the card on your PC. Your PC will detect a new drive as "boot" where raspi's kernel and boot images are listed.
  6. In this "boot" drive, create a new file called xmpp-login.txt and copy this text. After copy, edit this file and replace sample user and password with actual username and password of your slave-device which you created in Step-1(please note that your providers APN details may differ).
  7. Remove the SDCard from PC, and insert it into pi zero, wait for about 2-3 minutes for 3G Modem's LED to glow solid blue.
  8. On your android phone, open xabber app and login using master's username and password which you created in Step-1.
  9. If everything goes well, raspi-zero will show up as online on your xabber client.
  10. Send a "Help" to your raspi-zero, it will reply with list of available commands.
  11. Send "Sysupdate;reboot" and wait for raspi to update to latest RBox image, after update, it will reboot and be back online again with latest RBox version. Here is the detailed information on all available commands.
  12. for gracious shutdown, send "poweroff" chat message and wait for 3g Modem's blue led to go off.



31 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...

Wonderful article! We are linking to this particularly great post on our website. Keep up the good writing.hobart Plasma Cutter

Best Circular Saws said...


Best Circular Saws;A motivating discussion is worth comment. There's no doubt that that you ought to publish more about this subject matter, it may not be a taboo matter but usually people don't discuss these subjects. To the next! Cheers!!

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!

Anonymous said...

The post was really informative and I enjoyed reading it. Before this post, I read HOSTINGER REVIEW and that too was and informative post.

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!

Greencut said...

¿Por qué? De las alternativas más económicas y eficientes, nos brinda equipos de gran calidad. Uno de ellos, la motosierra [greencut] GS6200 es uno de los más Produttore, Greencut . Codice articolo, GS6200 20. Product dimension, 81 x 26 x 28 cm; 7.5 Kg. Articolo model number, GS620X. Dimensioni, 62 cc

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!

Anonymous said...

best Aligners designs/

ATIF said...


Nibble remedy with aligners is another method in orthodontics, an option in contrast to supports. In the event that prior just supports were utilized to adjust teeth in dentistry, presently you can put agreeable and tasteful aligners ( removable aligners ).
clear Aligners/

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

Anonymous said...

Read a wide range of energy-saving LED neon lighting.LED lights Whether you're looking for the ideal way to add some much-needed functional lighting into your domestic or business job regions or whether you simply wish to introduce a splash of lighting around your home, we can assist.led lighting Install LED neon lights today where you need them most for convenient solutions to your lighting needs.LED Light Pakistan

Our complete range includes everything from solid LED neon tubes to adjustable Rope 360 Bend lighting, led light giving you the freedom to choose and install the best-fit money-saving LED lighting possibilities specific to your lighting job.led light manufacturers In addition, we offer water-resistant custom made neon signs,LED lights ideal for modern company promotion - all of our signals are IP rated for outdoor use. led lighting

Alexa said...

"SEO is very important because it makes your website more visible which means more traffic and more opportunities however here I am looking for seo services in dubai because can see huge competition in my city.

"

Gaurav said...

children line - The amount of lines is thought to represent the number of children you are going to have. The deep lines denote a male child's birth.

Anonymous said...

I found the tips shared in this post to be incredibly helpful and practical - definitely going to implement them! I'm grateful for this color blind test for kids, it helped us identify and address my child's color vision deficiency early on.Must visit.