Emoncms briq

Added by fjhug about 7 years ago

Here is a small briq that will publish the readings collection from housemon in emoncms (

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. (1.45 KB) Emoncms briq (1.94 KB) 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

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       //

void setup ()
  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(" 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  // needed to aviod Linker error

typedef struct { int counts,battery;} PayloadTX;

PayloadTX watermeter;

void setup () {



  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

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:

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/ file. This links nodes to drivers. If you look in the exports.rf12nodes section, you will see

    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 (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 !