My pet IoT project :)
What?I have a few pet coding projects in Github. I usually maintain them as private repositories. The reason I keep them private is because they are Proof of Concept type work (and are also skunk-work).
One such project I started a few months back was an IoT prototype. What I wanted to develop was an application that qualifies as an IoT use case and structure it in such a way that the architecture, design, development, deployment and continuous delivery is laid out as a pattern.
During the course of development, I found out about a few cloud based technologies such as Pubnub (https://www.pubnub.com/) and Google's Firebase (https://firebase.google.com/).
The text below is directly from the README of my project at https://github.com/tyrell/control-things-from-the-internet
I'm making this project public from today, and hope this helps someone else to get started!
Control 'Things' from the InternetThis is a Proof of Concept application I maintain to fine tune a develop+test+deployment work-flow for IoT use cases.
The Circuit (Things)I used a really basic setup of 'things' that I want to control over the Internet.
The breadboard brings together the following ...
- An Arduino Uno
- A Servo
- An LM35 temperature sensor
- An LED
- A Photoresistor
The InternetA web UI controls the Servo and the on/off frequency of the LED. The UI also displays readings from the LM35 temperture sensor continuously. The progress bar displays readings from the photoresistor. Higher percentage indicates more light, vise versa.
I have hosted this UI in Firebase at https://servo-controller.firebaseapp.com/
In May 2016, Google announced major upgrades to Firebase during their Google I/0 conference. Now I love it even more.
How to run
- Complete breadboard connections as illustrated.
- Plug Arduino to the host computer via USB.
- Install the Arduino IDE and load Standard Firmata.
- Install Node.js
- clone git repository to your local machine.
- npm install
- npm start
- Load index.html either directly in the web browser to test that everything communicates with each other. Once verified, host it on the Internet.
How to run as a Docker container
- Install Docker on your raspberry pi. I have documented my work flow at https://gist.github.com/tyrell/2963c6b121f79096ee0008f5a47cf347 .
docker run -dti --privileged tyrell/control-things-from-the-internet:rpi-latest
Setup a cron job to restart the container after a reboot
sudo crontab -e
- Add the following line to the file and save
@reboot /bin/bash /
/scripts/control-things-from-the-internet.sh 2> / /cron_errors.log
How to run as a Node-RED flow
- Install Node-RED on your Raspberry Pi.
- Setup the circuit and attach your Arduino to the Pi.
- Go to http://[your-pi-ip-address]:1880 in a browser to view the Node-RED flow designer.
- Copy and paste the flow definition from node-red/flows_raspberrypi.json file and deploy to Node-RED
- Pubnub - https://www.pubnub.com
- Firebase - https://www.firebase.com
- Resin.io - https://resin.io/ They have operationalised deployments in a way I find really interesting.
- Node-RED - http://nodered.org/
- Johnny Five and Node-RED HowTo - https://github.com/rwaldron/johnny-five/wiki/Getting-started-with-Raspberry-Pi-node-red-and-IoT