Requesting mqtt data from LoRa server for emoncms node

That’s excellent - congratulations! Node-red will run in the background while the rPi is running, but depending on how it was installed, it may not start after a reboot. But you can change this with

sudo systemctl enable nodered.service

on the command line. Further info on starting, stopping etc at node-red. These things do occassionally stop, especially when routers decide to change IP addresses, so worth checking that data is arriving. There are also some great tools in node-red if you feel like playing around - e.g. a dashboard where the data can be displayed, graphed etc in near real time. Have fun!

Hi Anthony,
Sorry to bother you again but I’m not getting any takers on my latest question regarding graph data for the two nodes coming from MQTT.

My two nodes, emoncms and emoncms1, are working fine thanks to your help. However I seem unable to graph the data beyond 1, 6 hours. or a week–the data is there but I can’t plot it.
The problem, I believe, is the input interval. It seemed to set automatically on the emonTX nodes but not for the new ones I just added. The two new nodes create data every 20 minutes but, since their timers aren’t coordinated, the data comes in an irregular manor, 5 minutes, 10 minutes, 15 minutes, etc. Are there some settings you might suggest for me to try? Here are a couple of screen shots. I have a week showing now but two weeks won’t show at least the one week’s data, just a complete blank chart. Thanks again, Bob


Hi Bob
If the data isn’t being logged at a regular interval then you should use PHPTIMESRIES instead of PHPFINA. PHPFINA only really logs the value and assumes a time based on a fixed sampling period, while PHPTIMESERIES logs the actual time with each data point (so uses at least double the disk storage space).
Can you try to setup a new feed from your inputs, but select PHPTIMESERIES as the “engine”?

1 Like

Thanks, Anthony, I have switched to PHPTIMESERIES. Once I get some data logged then I’ll let you know. Cheers, Bob

Looks like it worked. Thanks again.

Hi (again) Anthony,

Many thanks to you, I now have 4 LHT65s running on LoRa and sending data via mqtt/node-red to emoncms. I am now attempting to do the same with a Seeed CO2 sensor but have hit a problem which I don’t understand. The sensor is working correctly and sending data to my chirpstack gateway. When I try to get the data into emoncms, using the setup which worked for the LHT65s, I get the message that my object is undefined. I have attached a breakdown of my node-red below. The node-red flow is contacting the LoRa gateway and has setup a node on the emoncms pi but the data is missing. If you have time to comment please let me know if you need additional information. Thanks in advance.

From LoRa gateway


debug message
11/14/2021, 4:56:48 PMnode: 64d043922a280e22
msg.payload : Object
CO2_Value_PPM: undefined
emoncms node

Emoncms server   emonpi
Node              CO2
Data Type       valid JSON object
Name             CO2
From Node-Red Function Node
On Message
input = msg.payload
var CO2_Value_PPM = input.object.CO2_Value_PPM
msg2 = {payload:{"CO2_Value_PPM":CO2_Value_PPM}};
return msg2;
From Json Node
Action  Always convery to JavaScript Object
Property  msg payload
Name  CO2
MQTT in node
Server   RAK7244
Topic    application/18/device/2cf7f12122500013/rx
QoS       1
Output    auto-detect (string or buffer)
Name     CO2

Formatted text - BT, Moderator

Hi Bob - I suspect it is in a slightly different format, and the node-red flow will need a change. I’ll have a play tomorrow.
Just to be sure - have you used the three backtics in your post as suggested by Robert above? The forum software may be changing some of the quotes and newline characters making it difficult to interpret.

Hi Anthony,
Just wanted to let you know that a Node-Red forum member solved my CO2 sensor problem. He suggested the function which I listed below. It seems to be sending the data correctly to my emoncms server. I’ll send you a link once I get it set up on my web page. Thanks again, @icenov, for the help.

// Test to see if CO2 measurement is present in uplink
// Assumption is msg.payload.object.messages[] array is always present
// if not then we need to test in different way
// why do we do this to ensure we don't send rubbish to emoncms

if ("CO2_Value_PPM" in msg.payload.object.messages[0]){
    msg = {payload:{"CO2_Value_PPM":msg.payload.object.messages[0].CO2_Value_PPM}};
    return msg;

That’s good to hear. The Node-Red forum is another great resource!