TinyTX & Tiny328 Sensors with Node-RED


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.

Tiny328 with FTDI adapter
Tiny328 with FTDI adapter

Tiny328 & FTDI Cased
Tiny328 & FTDI Cased

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.

RFM12B in/out flow
RFM12B in/out flow

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.


6 thoughts on “TinyTX & Tiny328 Sensors with Node-RED

  1. You apparently have a lot of sensors. Do you also have any control nodes that operate blinds, locks, windows, AC or anything similar? And if you do then do you also have some kind of security in place to protect against replay attacks?

  2. Can you show us some photo of sensors ?
    Have You use batteries?
    If so, how much is the battery life ?
    Have you enclosed in some special boxes ?


  3. @Priit No, I don’t have anything critical using them. If you need something with security have a look at the RFM69CW and the Moteino library as that supports the RFM69 ranges built in encryption. The Jeelib library doesn’t yet.

    @Mauro, There are pictures of some sensors on the TinyTX page here: http://nathan.chantrell.net/tinytx-wireless-sensor/

    I mostly use 2 x AA batteries although I’ve used AAA on a couple, my oldest one is still running on the original batteries 2 years and 4 months on, I did a post on this at the 2 year mark here:

    For some of them I have just stuck the board to the battery holder, others have been cased in a range of plastic boxes, I particularly like this one: http://www.bitsbox.co.uk/index.php?main_page=product_info&cPath=185_186&products_id=1929

  4. Hi Nathan,

    Can you please give some advice on using/connecting a TinyTX or an arduino compatible on an RPi? Pin connections and getting the readings?

  5. I tried with the flow jeelink (in Windows Envirorment).

    In the package, after “OK”, it is a void string (“”). Before reading the node value I think need another tokens.shift ();

    I modified the code in this way:

    if (tokens.shift() == “OK”) {
    tokens.shift() ; // remove void string
    var node = tokens.shift() & 0x1F;

    so it is works

  6. Hi Nathan,

    Can you please share the sketch you use for the above flow. Also could you please confirm that your Tiny328 board is running RF12Demo sketch from Jeelib.

    Here is my scenario:

    Base station: Jeenode v6 (loaded with RF12Demo sketch) connected to Raspberry Pi 2 with USB
    Sensor Node: Arduino uno with RFM12B Board (from Jeenode) + DHT11

    Somehow I’m not able to see the Ok nodeid,data1,data2.. on Node Red.


Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.