Project

General

Profile

Emoncms briq

Added by fjhug about 7 years ago

Here is a small briq that will publish the readings collection from housemon in emoncms (http://emoncms.org/)

I use it to log data received in housemon by a clone of a jeeNode_USB, based on a Microchip PIC processor, with embedded USB, and running a rf12demo compatible firmware.

The readings are logged in emoncms as “node”nodeId_keyname with its value. For example node16_temp

For now, the briqs need to be edited and the variables SERVER and APIKEY need to be set with the information relevant to your setup:

SERVER = 'http://localhost/emoncms' # Emoncms host and base path
APIKEY = 'xxxxxxxxxxx' # API write key to use

Once edited, place the file in the ~/housemon/briqs folder in your housemon setup.
In the housemon admin page, install the briq to create the blob. You should then be able to see new inputs in emoncms.

You need to have readings working for the data to be logged in emoncms, as this briq takes the readings collection, and passes the collection to emoncms with the time stamp at which it was received, and the node ID of the sender.

In the readings collection, the variables are labelled by the driver. For example, the lightNode driver from the DIJN series present a variable called value.
This would be logged in emoncms as an input labelled “node19_value”, with the value of the lightNode.

Update Version 1.1: support node_id sharing. Inputs are labelled node19_value_1 for example if node ID 19 is shared.

emoncms.coffee (1.45 KB) emoncms.coffee Emoncms briq
emoncms.coffee (1.94 KB) emoncms.coffee Version 1.1 - Node ID sharing

Replies (3)

RE: Emoncms briq - Added by jcw about 7 years ago

Great job. FWIW, I’ve started work on making briqs configurable, so that the above settings can then be adjusted from the browser i.s.o. editing source files.

RE: Emoncms briq - Added by gyrolen over 6 years ago

I would like to try this on a water-meter which has reed-switch connection to measure water usage.
Can anyone suggest the Sketches to use at the Water-Meter end and at the RPi end which will both have JeeNode with FDTI serial connectors. ?

For instance I would run Housemon on a RFPi with FWIW’s emoncms briq to send the data to emoncms.org

I have tried the following but it does not work, can anyone help. ?

A Sketch for the RPi base-station from the NanodeRf b_MultiNode.

#include       //https://github.com/jcw/jeelib

void setup ()
{
  Serial.begin(9600);
  Serial.println("RPi Server");
  rf12_initialize(15, RF12_868MHZ, 100);
}

void loop ()
{
  if (rf12_recvDone() && rf12_crc == 0 && (rf12_hdr & RF12_HDR_CTL) == 0)
  {     
    int node_id = (rf12_hdr & 0x1F);

    // Get the packet length (number of integers sent is n/2)
    byte n = rf12_len;

    Serial.print("Node: ");
    Serial.print(node_id);

    Serial.print(" data: ");

    // Go through the packet 2 bytes at a time
    for (byte i=0; i

A Sketch for the water-meter adapted from JCW’s Housemon test2

#include 
#include  // needed to aviod Linker error

typedef struct { int counts,battery;} PayloadTX;

PayloadTX watermeter;

void setup () {

 Serial.begin(9600);

  Serial.println("Water-meter");

  rf12_initialize(10, RF12_868MHZ, 100);
}

void loop () {
  watermeter.counts = analogRead(0); // simulate watermeter count
  watermeter.battery =map(analogRead(6),0,1023,0,660);// not active yet
   int i = 0; while (!rf12_canSend() && i<10) {rf12_recvDone(); i++;}
   rf12_sendStart (0, &watermeter, sizeof watermeter);
}

Any help appreciated
Thanks
Len

RE: Emoncms briq - Added by fjhug over 6 years ago

To make sure the emoncms briq works, we need to have a reading object.
For readings to be populated, the incoming data needs to be decoded by a driver.
A basic visual flow is available here: http://jeelabs.org/2013/02/27/housemon-0-5-0/hm050-2/

The minimum required briqs are: rf12demo, drivers and emoncms. The drivers briq is the one making the reading object available to the emoncms briq.

If we use the example with test1 sketch, this is how the string received from node 1 is processed:
When starting, housemon loads the briqs/nodeMap.coffee file. This links nodes to drivers. If you look in the exports.rf12nodes section, you will see

100:
    1: 'lightNode'

This means that messages received from network group 100 and node 1 will be passed to a driver called lightNode.
This driver is located in the drivers folder, as lightNode.coffee (Be carefull, it is case sensitive…)

In this file, it describe the key(s) expected in the message. Here, we have one key called value (In the descriptions section). It gives this key various properties, like a title, units…

It expects the message from the rf12.packet object, which is given by the rf12demo briq.

The decode function give the key its value. In this case, the key is called value, and is assigned byte 1 of the received message.

The drivers briq makes the key and its value available in the readings object. It is essential to have the drivers briq installed.

The emoncms briq takes the key names (value here) and their value, and send them to the emoncms server.

Hope it makes sense !



    (1-3/3)