Hi,
Recently i helped a friend route his beloved fluksometer to emoncms, at the end he was completely blown away with this great piece of software. Not only he has much better visualization tools, he gained a ticket to complete integration with everything.
I didn’t know flukso, i find the project very interesting it’s a router with OpenWRT with a arduino inside and a complete online and local visualization app. The great thing about this piece of hardware is its MQTT implementation that publishes huge amount of data. the measurements are reported at 1-second rate with lots of options, more than i could understand.
Here’s the implementation details:
Flukso comes with it’s own MQTT server, unauthenticated on port 1883 available at both wan or lan interfaces. The topics to subscribe are:
/sensor/+/counter/#
/sensor/+/gauge/#
The function:
////////////////////////////////////////////////////APR
// Slow down rate to every 10s
///////////////////////////////////////////////////////
var Value = msg.payload.split(",");
if(Value[0].substr(Value[0].length - 1) != '0' )
{
return null;
}
///////////////////////////////////////////////////////
/*
* The following structure defines reasonable names
* and type of measuring for each sensor ID
* - pplus, pminus, q1, q2, q3 and q4:
* same sensor ID @ counter & gauge MQTT topics
*
* - vrms, irms, pf, vthd and ithd:
* unique sensor ID @ gauge MQTT topic
*
* Find your own sensor id's and build the tables below
* accordingly:
* - 1st argument: *node* at emoncms
* - 2nd argument: *key* at emoncms
*
*/
var myGauge = {};
var Counter = {};
// PORT1 (CT)
myGauge['00000000000000000000000000010001'] = 'port1,pplus';
Counter['00000000000000000000000000010001'] = 'port1,pplusWh';
myGauge['00000000000000000000000000010002'] = 'port1,pminus';
Counter['00000000000000000000000000010002'] = 'port1,pminusWh';
myGauge['00000000000000000000000000010003'] = 'port1,q1';
Counter['00000000000000000000000000010003'] = 'port1,q1VARh';
myGauge['00000000000000000000000000010004'] = 'port1,q2';
Counter['00000000000000000000000000010004'] = 'port1,q2VARh';
myGauge['00000000000000000000000000010005'] = 'port1,q3';
Counter['00000000000000000000000000010005'] = 'port1,q3VARh';
myGauge['00000000000000000000000000010006'] = 'port1,q4';
Counter['00000000000000000000000000010007'] = 'port1,q4VARh';
myGauge['00000000000000000000000000010008'] = 'port1,vrms';
myGauge['00000000000000000000000000010009'] = 'port1,irms';
myGauge['00000000000000000000000000010010'] = 'port1,pf';
myGauge['00000000000000000000000000010011'] = 'port1,vthd';
myGauge['00000000000000000000000000010012'] = 'port1,ithd';
// PORT4 (SO)
Counter['00000000000000000000000000040001'] = 'port4,pplus';
/*
* ** Main Program **
*
* Value[0] - timestamp with some leading garbage
* Value[1] - actual measured value
* SensorID[2] - original Sensor ID
* SensorID[3] - gauge or counter mqtt topics
* Info[0] - name of the sensor (port1, port2, ...)
* Info[1] - type of measurement (pplus, pminus, ...)
*/
var SensorID = msg.topic.split("/");
var Info;
if(SensorID[3] == 'gauge' && myGauge[SensorID[2]] )
{
Info = myGauge[SensorID[2]].split(",");
}
else if(SensorID[3] == 'counter' && Counter[SensorID[2]] )
{
Info = Counter[SensorID[2]].split(",");
}
else
{
node.status({fill:"red",shape:"dot",text:"invalid"});
return null;
}
node.status({fill:"green",shape:"dot",text:"success"});
msg.nodegroup = Info[0];
msg.payload = "{\"" + Info[1] + "\":" + Value[1] + "}";
return [msg];
Each incoming message that matches with the associative array that defines node and key produces a valid datapoint that is posted to Emoncms and turns on a green dot status indication. Incoming messages that are not defined generate a red dot at the function status. If this is the case the status indicator will blink at the presence of unconfigured sensor IDs.
The hardware used was a RPI3 with the latest emoncms SD image. Thanks to all contributors for making this easily available.