I have successfully installed EMONCMS in a Raspberry Pi. Also, I have a Moteino connected via /tty/AMA0. I see the data coming in, it's all working fine. What doI need to do to feed the data into the EMONCMS Inputs? Do I create a python script that makes a HTTP POST? Or is there a more direct way? Just need a point in the right direction.
Regards,
Yes EmonCMS expects HTTP requests to inject data. Here's an old repo with sample code (https://github.com/LowPowerLab/WattMote) showing how you might do that.
It turns out that they have added new subsystem that makes all this very easy called EMONHUB. It comes all ready to go in the Raspberry PI image.
All you have to do is edit the /etc/emonhub/emonhub.conf with a DirectSerial reporter and configure the data format:
[reporters]
# This reporter sends data to emonCMS
[[emonCMS_local]]
Type = EmonHubEmoncmsReporter
[[[init_settings]]]
[[[runtimesettings]]]
url = http://localhost/emoncms
apikey = xxxxxxxxxxxxxxxxxxxxx
[interfacers]
[[SerialDirect]]
Type = EmonHubSerialInterfacer
[[[init_settings]]]
com_port = /dev/ttyAMA0
com_baud = 115200
[[[runtimesettings]]]
[nodes]
# List of nodes by node ID
# 'datacode' is default for node and 'datacodes' are per value data codes.
# if both are present 'datacode' is ignored in favour of 'datacodes'
[[99]]
datacode = h
datacodes = l, h, h, h
In the Moteino that is connected to the Raspberry PI you just have format the data like this:
NodeID[SPACE]VALUE1[SPACE]VALUE2[SPACE]VALUE3[SPACE]VALUE4[CR/ENTER]
Using Felix's struct example:
Serial.print(theData.nodeId);Serial.print(' ');
Serial.print(theData.uptime);Serial.print(' ');
Serial.print(theData.temp);Serial.print(' ');
Serial.print(radio.RSSI);Serial.print(' ');
Serial.print(theData.moisture);
Serial.println();