Node-RED is currently taking the IoT world by storm, described as “A visual tool for wiring the Internet of Things” it is built on top of Node.js and is an open source project developed by IBM employees. It makes it easy to link various inputs and outputs adding simple or not so simple processing in between, just drop your various parts into a workspace and link them up. It also makes a great way to map MQTT topics to each other.
It comes with a whole host of input and output nodes, MQTT, http, websockets, serial, tcp/udp and it can read logs, write to files, call external programs, connect to databases etc. which make it possible to connect with just about anything you can think of. There is also built in support for services like email, Twitter, irc, Pushbullet and Twillio SMS.
To bring the data from my sensors into Node-RED I am using one of my Tiny328 boards running the Jeelib RF12demo sketch which is connected to a cheap FTDI adapter plugged directly into my server but this could just as easily be done with a JeeLink, a TinyTX or any Arduino compatible with an RFM12B radio. If using a Raspberry Pi then the RFM12Pi could also be used.
From there it just a case of setting up a serial input node, parsing the incoming packet and publishing the data to MQTT topics and/or uploading to emoncms.
I’m using it to upload to my own emoncms installation on the same server as well as publishing to MQTT topics for each reading. I am using topics of the form rfm12b/12/1, rfm12b/12/2 where 12 is the node number and 1 is the first data field from the sensor (eg. temperature) 2 is the second (eg. humidity) etc. I have then set up a series of MQTT inputs from these topics which go through a function node to do any required processing (eg. divide by 100 to get the real temperature reading, set a global context etc.) and the republish to a more readable topic name such as kitchen/temperature.
So I now have all my temperature and humidity sensors, air pressure, electricity and gas usage and rainfall readings coming into Node-RED as well as the doorbell, several PIRs and magnetic contacts on the fridge door and front door. From there it is possible to perform actions based on this data such as warn if the fridge door it left open, turn a heater on or off at a particular temperature etc.
I also have a flow set up to send the time out via the RFM12B once an hour for setting the time on the various LCD displays I have around the house. You might also notice in the screenshot there is also a function to set topics for OOK commands but that is a topic for another post.
Here are the flows I am using for the input and output.