Thursday, April 4, 2019

Nodered, influxdb and Grafana

I had installed nodered to help monitor some of the systems on the boat and elsewhere some time ago. It has the ability to display some data, charts and plots with the extra "dashboard" module.

I also installed mosquitto to collect data from the ESP devices and the OPis. I probably followed someone's notes, but I didn't seem to log it.

It was OK for a while, but each time I restarted a display, it would start with no historical data. There was also no way to remove erroneous data. As I change things, plug in or forget to plug in things, I do get erroneous data points on occasion.

I tried sqlite/sqlite3 on op2e and croc for a while. It is like mysql, only a little simpler. I found an example flow for nodered and tried it for a while.

Then I saw the youtube from Andreas and decided to try it.

It didn't take too long to get some data going into influxdb, but it did take some learning. The data had to be formatted just right to be inserted in a way that grafana could read it back.

For the simple case of a two values JSON string this is it. It did take a while fo make it this simple:

var tokens  = msg.topic.split("/");
msg.measurement   =tokens[1];       //get device  name from topic  level 3 /v1.6/devices/tokens[3]
var dest    = tokens[tokens.length-1];
inputjson   =JSON.parse(msg.payload);
msg.payload =inputjson;
return msg;
// End

For the more complex report for the disk space it took several days:

var tokens  = msg.topic.split("/");
sys = tokens[1];       

function extract(elem) {
    let extr = elem;// { fileSystem: "/home", percent: "96" }
   // node.warn(extr)
    var tag = {"host": sys, "filesystem": extr.fileSystem};
    msg.measurement = "Disk";
    msg.payload= [{"percent": extr.percent}, tag];
    return extr;
// End

But it is working now.

The next hurdle was to get the data out into a graph with Grafana. A longer learning curve. And I'm not sure how to show it. Several windows for input all have to agree for the data to show up.


Just the battery monitor

Saturday, January 19, 2019

A Quick Look at RFID

Back in 2002, I was working a short contract in Seattle, just as the company was notified by Walmart that they must implement RFID on ALL of their products or no longer be eligible to sell through them. I dreamed of starting a consulting company specializing in implementing RFID, but then I realized I'd rather be retired and sailing in warm waters.

Just for kicks I ordered this RFID kit to evaluate, "MFRC-522 RC522 RFID RF IC Card Sensor Module". I would post a link, but I bought it in Chinese via Google Translate. It was only $2.63 so I couldn't pass it up.

I tested it on a Wemos D1 Mini, ESP8266, my current CPU of choice. The Arduino IDE has a library for the  MFRC-522 from It includes several examples. It is 3.3v and has a SPI interface plus a RST signal.

I tried several of the examples and the reader actually works! The blue tag needed to be less than 1cm to read, but the white card worked out to about 2.5cm.

Writing also worked. Both types of tags are identified as 1kilobhyte. I only wrote my name so I didn't test the limits.

MFRC-522 RC522 RFID Card Sensor Module

Tuesday, January 1, 2019

More Battery Monitor

It was still too hard to tell whether the new batteries were coming up to full charge, so while I waited, I added to the monitor. I already have a current shunt for the old "Heart/Cruising Designs" monitor and now the Xantrex LinkLite, so all I had to do was hook the ADS1115 differential input channels to it.

I added the current monitor with amp hour calculation and a status web page to the Batt_volt_mon. I re-factored the code using the tab capability of the Arduino IDE rev 1.8.8.

I also copied from a friend the idea to make each tab's code optionally included at compile time with #ifdef's. This makes it easier to debug.

  #define DO_ADS
  #ifdef DO_ADS
     #include "ads.h"
  #endif //DO_ADS
  #ifdef DO_ADS
  #endif // DO_ADS
  #ifdef DO_ADS
     if ( (last_ads + ads_time) < millis() ){
       last_ads = millis();
  #endif //DO_ADS

And I uploaded the new code to my github.

Top of the board with the modules out to see the wires
The bottom of the board

And then I documented the connections in Fritzing.
The Fritzing layout