Internet Connected Petduino - Part 1, The Plan

Published: 10 December 2015

If you’ve been keeping up with my blog posts recently, you’ll know I have introduced a few add-on code libraries for the Petduino including PetduinoSerial and PyPetduino. One of the big aims of this for me has been to give the Petduino an internet connection so that it can make use of the plethora of online services out there.

As noted in my PyPetduino post, PyPetduino can run nicely on a Raspberry Pi, so we could just write custom python scripts for each service we would want to work with, but this often leads to a lot of wheel re-invention. What would be better then is if we could expose Petduino to a service that could allow you to easily “wire” it up to other services in an easy manner.

My initial thought was connecting it to something like IFTTT, which with it’s new Maker channel, would be possible, but IFTTT do a very good job of restricting the ways you can connect with it (great for product developers, not so much for hackers and makers) and unfortunately it doesn’t quite fit with how we would want to connect.

Then I remembered another service that does a very similar thing, but is much more maker friendly, and that is NodeRED. If you haven’t heard of NodeRED before, it’s a great web application written by IBM that lets you effectively connect and process heaps of web services “nodes” by literally connecting wires between them to define the flow of data. It’s programming, but without the code (well, maybe a little), and so easy to do, so for us, this is perfect. If we could expose our Petduino to NodeRED then, we can reuse a plethora of pre-existing nodes and quickly be able to wire them up and tear them down as we play and experiment. Perfect!

So we now have a service in mind, but the next question is how do we connect our Petduino to that service. The answer is to check out the various nodes supported by NodeRED and find one that we can use as a bridge. After a quick review, a couple immediately stood out which were nodes for the web services and Pubnub.

I’ve already played with in my PetduinoConnect project so I know this could work well, but from looking into Pubnub another simple real-time messaging platform for devices, I was really impressed with it’s simplicity and it’s support for so many systems out of the box that I decided that would be the one to go with.

With that decision made, the plan is set. We’ll use PetduinoSerial wrapped around the standard Petduino Arduino library to let our Petduino routine communicate over serial. We’ll then connect the Petduino to a Raspberry Pi, via USB, which will act as our physical internet connection which will in turn run a python script using PyPetduino and the python PubNub library to proxy outbound messages from the Petduino to the internet and the incoming messages from the internet back down to the Petduino. Finally, we’ll use NodeRED to connect to our Pubnub endpoints and use the extensive node libraries to further wire our Petduino to all the other web services out there.

Now that the plan is set, over the next few posts I’ll go through steps needed to setup these parts. So that we have a specific end goal in mind, we’ll build an actual demo implementation, a simple routine to display how many people are currently in space. An example of what we should end up with can be seen below.

Until next time, feel free to have a look at the various services and get to grips with what each one does.