How we made a Twitter powered bubble machine

Electronic gizmo’s and do-da’s were piling up in my locker at work and not doing much beyond perpetuating my nerd image, so I thought I’d roll up my sleeves and plug stuff into other stuff to create A Twitter Powered Wifi Arduino Bubble Machine!

Luckily I’m familiar with electronics, having a Diploma in it, however I’d never actually made anything due to the fact that my course made anything electrical seem infinitely dull and theoretical. No more of that though with the coming of Arduino; the little programmable circuit that lets you make anything into anything with minimum effort and maximum back patting.

I decided to find the most basic bubble machine. One with only one setting – on or off. None of those fancy bubble customization options I would have had to decipher and reorganize. Bypassing the on/ off switch was simple enough, minus the remembering I can’t solder part. The two cables poked out the top where I could easily plug the Arduino in.

Next was the relay. This component is essentially a switch which can be turned on or off by a signal from another circuit (our Arduino). Worth noting that I bought a relay module and not just a relay so I wouldn’t have had to create a mess of wires on a prototype board. The module needs only three wires connected to the Arduino – 5V power, any binary pin that’s not 10, 11, 12 or 13 (our wifi shield needs those), and ground.

Arduino has a brilliant collection of example code. I used their looping wifi client which downloads a page over and over and modified it a little for our needs.

I wanted to keep the code on the Arduino to a minimum to give me more options later on. The only thing the Arduino would be responsible for was downloading a page from our server every few seconds, reading its content and blowing out three seconds worth of bubbles if the content contained instructions to do so.

The heavy work was done by two PHP scripts. One would be run frequently to search Twitter for a specific word (“@IUHQ” in this case) and save the search results to a database. The second would read the database and output instructions for the Arduino to download and act upon. On a scale of one to disgustingly dirty, this method is about a 7. The elegant solution would have been to use Twitter’s streaming API to search for tweets and then stream instructions to the Arduino. Alas, time was against me and the hoard of bubble dancers were becoming inpatient.

The machine worked surprisingly well and was far more responsive than I expected. But polling Twitter isn’t ideal, especially since some tweets can be missing from the search results, you only get 450 searches per 15 minutes and is a waste of server resources. But it’s certainly worth giving the project a go given how quick it was.

  • pixelpusher_ca

    You should use the Twitter streaming API it’s awesome… no need to poll and you get every tweet.

    • Peter Bailey

      Totally! This project was just to get something up and running as quickly as possible, but I would like to do it properly.