RF Mote Web UI : Program all the RF things

Introduction

Deploying a bunch of remote nodes and a gateway into the wild presents a number of issues. What does each do? What is connected to it? How often should it tell me what’s up?

Typically wrapping up a group of remote sensors requires a unique program for each node, programming and debugging each node locally with a serial interface, and programming a gateway/data aggregator to understand each individually. This can be a bit of a nightmare, and we really wanted a solution where we would never have to get out our FTDI cable to program a micro directly!

We’ve addressed all of these issues with our UniMote code and our gateway UI for messaging remote nodes. Read on.

UniMote for universal code and remote config

One thing we all loathe is repeating ourselves. Another is constant maintenance of multiple instances of code, even if they are quite similar (and often even more so if they are). For this reason, we’ve built a UniMote sketch that does, well, everything. It works on a battery-powered mote as well as it does on a sensor gateway. You can configure it over serial or RF with simple commands. You can read about that here and here.

Gateway SerialHandler to dispatch and process

On a gateway, we have a mote connected by serial, often to a Raspberry Pi, for example on our Pi HAT.  On our gateway, we need to both listen for incoming messages from our mote, as well as send messages when necessary.

To facilitate this, we set up a pretty simple serial message handler. It continuously listens, and dispatches messages as they show up in a queue set up in a database, This database houses received messages, queued messages, as well as those that have been sent, time-stamped of course. It’s in python, uses pyserial, and is pretty darned straightforward. In the form you’ll find it, it does use our pilib, but you can easily cut and paste if you want a standalone version.

 serialhandler.py

UI to queue serial commands

Our serial handler does nothing except process commands put into a queue, so all we need to do with a UI is to present a way of inserting messages into it. This is pretty easy, and based on things we have talked about previously. We create a UI that executes a simply wsgi function to insert entries in the serial queue. We add some css, and we get the UI below:

Terminal UI for entering sending messages to our motes.
Terminal UI for entering sending messages to our motes.

We can pretty easily see the messages as they go out and are received. Simple stuff.

Mote Control Panel

Now, on top of this basic goodness, we’re going to build something that resembles a control panel, where we can view each node’s vitals, update data, and view what the status of all the IO are. We do it using the same basic methods above, combined with the databased data retrieval we’ve talked about here and here. The end result is a browser-determined data retrieval sequencing that complements the node-side code that is set up to deliver data when the node feels like it. This will be the bedrock that our remote thermostat/PLC code rests firmly on. Here are a couple videos with an explanation and demo of the control panel interface:

Overview:

Demo:

3 thoughts on “RF Mote Web UI : Program all the RF things”

  1. Hello Colin,

    I have trouble compiling the latest revision of the uni_mote sketch (uni_mote_2p7.ino), see below:

    uni_mote_2p7.ino:1572:3: note: in expansion of macro ‘FLASH_STRING’
    /home/jdp/Arduino/libraries/Flash-5/Flash.h:70:3: note: _FLASH_STRING::_FLASH_STRING(const int*)
    _FLASH_STRING(const prog_char *arr);
    ^
    /home/jdp/Arduino/libraries/Flash-5/Flash.h:70:3: note: no known conversion for argument 1 from ‘const char [2]’ to ‘const int*’
    /home/jdp/Arduino/libraries/Flash-5/Flash.h:67:7: note: _FLASH_STRING::_FLASH_STRING(const _FLASH_STRING&)
    class _FLASH_STRING : public _Printable
    ^
    /home/jdp/Arduino/libraries/Flash-5/Flash.h:67:7: note: no known conversion for argument 1 from ‘const char [2]’ to ‘const _FLASH_STRING&’
    Error compiling.

    I suspect that I don’t use the correct version of the flash library.
    What version are you using?
    Where did you get it?

    Best regards and thanks for your work!
    Jacques-D.

    1. Hi Jacques,

      Sorry for the slow response. I have been working on the sketches recently without problems, so I’ll make sure to get an updated rev up into the repo that have the same flash libraries I am using. I actually don’t have any CuPIDs online right now (moving the shop and home is being updated), so it will be just a moment before I get that up.

      Thanks for the kind words and your patience!

      Cheers,
      Colin

Leave a Reply

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