How we got BG to tweet!

System Overview

Hi All, as promised we prepared a new post with all the juicy details of what was used to have BG send tweets all over the world. Originally when HelloComputer came to us for help, we had grand plans of creating new designs and circuit boards. Unfortunately the timelines would not allow for such a system (at least not for the original pilot). We then decided to use as much off the shelf components as possible. Great products such as the Arduino and the variety of shields available makes prototyping systems like this a lot easier. This system has some much more potential to be developed and expanded and it’s definitely something we are planning to continuously work on.


The concept behind BG the tweeting badger is basically that we added infra red motion sensors to BG’s enclosure at various places. As the sensors detect his movement it sends the data through to a base station which in turn sends it through to a server. The server handles the conversion from sensor triggers to tweets being sent. While we could tweet directly from the base station we wanted a system that could be managed easily in terms of keeping the tweet database up to date and making sure that BG doesn’t become a twitter spammer.

Wireless Sensors

We tried to keep the wireless sensors as simple as possible. The main concern was that power usage since BG doesn’t have any electrical sockets in his enclosure (He is more of a reader, so he doesn’t watch TV).


Because you are planning on using electronics combined with little bits and bobs, you need to make sure that BG can’t get to it. Worst case scenario if he did manage to get his hands on it, it should be rugged enough that he can’t get inside the enclosure of the sensor and chew on any of the internal bits. The safety of BG always needed to come first.

We ended up going with a ABS molded enclosure with a clear lid. The enclosure is IP65 rated (We don’t want any rain to spoil the fun).

ENCL-11-3T (1)

The wireless sensors were attached to various places in his enclosure. One of the challenges was that since BG is a pretty good climber, so we couldn’t just attached the enclosure to the side. The solution was to attach it to the poles with an aluminium arm that kept the sensor out of reach from BG. In other places, for example his bedroom, we could mount the sensors directly against the wall as long as it wasn’t within close range of any of his play shelves.



The hardware used in the sensors consist of three parts, mainly the infrared sensor, a wireless radio and a battery pack. The wireless radio is by default in sleep mode (to keep power usage low). When the infrared motion sensor detects movement it triggers a digital input on the wireless radio, which in turns wakes up and sends the signal to the base station.

For the wireless radio we used a XBee radio. These are nifty little radios which can be setup very easily, but they are slightly expensive.


The following was set up on the XBee radio’s:

– Change the communication to API mode
– Configure the DI (digital input)
– Configure the sleep mode

Base Station

The base station is a big part of the project, since without it, the sensors would be useless. We also needed something smarter so we decided to go with an Arduino, easy enough to program and with the shields available it would be minimal hardware development. The base station has three main functions. It receives the trigger information from the sensors and handles the connection to the server. Again there was no power or IT infrastructure within close range of his enclosure, so we had to make it a solar powered solution.

BG Tech

Since we were using wireless sensors we could place the base station outside of the enclosure but still very close to maintain connectivity. We used a similar enclosure with the clear lid, but slightly bigger to keep all the bits together. Originally the base station was mounted on top of BG’s enclosure, but 5 minutes after it was mounted he managed to climb all the way to top and loosen the nuts and bolts that kept it attached. We promptly moved it to the top of the porcupine enclosure next door (they don’t climb that well).


The hardware used for the base station consist of an Arduino, a GSM shield and a XBee shield. Other bits include the solar panel, a battery pack and the solar battery charger (The lipo rider pro is awesome and so easy to use!).


The software for the base station was designed as a basic state machine. Depending on the current state it will either listen to the sensors, check the GSM connection or send through data to the server.

The GSM shield makes it very easy to send through data to a server. Once the initial connection is created, you can access perform simple HTTP POST and GET actions with the built in AT commands. Just remember to keep on the lookout for connection state changes so that you can reconnect the GPRS data connection if it’s not running.


The XBee side of things are simplified by using this XBee library. The main reason for using the XBee shield is that the wireless radio’s run on 3.3V and you need to do level shifting to connect it to the 5V Arduino. The XBee shield handles all of that.


The Arduino IDE makes it very simple to upload a program to the Arduino. The only thing to keep in mind is that keeping the shield plugged in while trying programming the Arduino does not work.

Planned Upgrades

The system is currently running very nicely, but there is lots of room for improvements. At the moment the wireless sensors are rather dumb. They currently only receive the actual trigger and we would also like to add current battery levels in the reports. Most of the stuff is also mostly being kept together in the enclosures using duct tape and double sided tape. While it does make for a neat hack it doesn’t exactly look professional.


Now that the project is up and running we are going to take out time to design some proper electronics with new pcb’s and hardware. Another reason for wanting to upgrade the electronics is that prototyping equipment like XBee shields and Arduino boards aren’t really designed with low power applications in mind. Custom PCB’s designed strictly for the application could deliver anything from a 100% – 250% increase in battery life, as well as better management of the wireless sensors.

And finally we are in the process of designing some inserts for the enclosures that would keep everything in the right place and will make it more presentable. These inserts are currently being design in OpenSCAD and will be 3d printed on our in-house 3d printer.


Thanks to HelloComputer for getting us to do this project with them. It’s been lots of fun and we’re looking forward to more projects.

Have any questions? Want to stay updated about future BinarySpace projects? Check out our Facebook page, or join our mailing list 🙂

One thought on “How we got BG to tweet!

  1. Hermanus

    Hi all and Especially BG, we are a family of 5 and we just love visiting Johannesburg zoo. The kids aged 9, 4 and 3 find it very facinating to see ands hear all the animals.

    It is totally great what has been done, we would love to hear from the LIONS and TIGERS too.

    I still have a photo that I took of the TIGER where he was playing in the water and he was soaked.

    Hope to keep hearing from you all and especially BG.




Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.