Hey all, I’ve just received my EmonPi3 and got it hooked up with no problems monitoring my electrical energy feeds.
Given that the logging and user interface in Emoncms (Local) is so good I’d like to import data using MQTT from an existing raspberry pi that’s already receiving data from an Arduino based heat pump monitor as well as other data and transmitting it using Node-red to various other destinations.
The Arduino is already publishing data to mosquitto installed on the existing Pi and Node-red is installed on the same Pi and is reading data on from mosquitto and is displaying it on some dashboards.
What’s the recommended method of getting the information into the EmonPi3 from the existing Pi?
Can you setup Emoncms to subscribe to an external broker?
I’ve had a reasonable search on here and found the emoncms nodes and I’m assuming that emoncms push node should be able to push data to my EmonPi3?
However, i seem to be struggling with the syntax on both the node-red and and within Emoncms.
Does anyone have any example of flows and settings at both ends.
No point reinventing the wheel if someone has an out of the box write-up to get me going.
emoncms can only subscribe to one Broker. However, you can bridge MQTT Brokers so all or some of the Topics are replicated on the other. Mosquitto MQTT Bridge-Usage and Configuration However, unless the Topic in question is in the right format, it doesn’t help.
As you have found, there is a NodeRED Flow for publishing data to emoncms.
Otherwise, simply process the data in NodeRED and publish it to the emonPi3’s MQTT broker. You may need to change a Mosquitto setting on the emonPi3 to receive data from a machine other than localhost IIRC.
You need to use the base topic of emon for emoncms to pick the Input up automatically and I’d use a JSON format to send it as one data set. Publish the data on a topic such asemon/HP and it will appear as a Node on emoncms as HP with the Inputs being each of the Key:Value pairs of data.
Hi Brian, thanks for taking the time to respond. I appreciate it.
I’ve looked at the nodes, bit theres very little detail on how to actually use them, would you be able to point me at an example of the dataset formatting at each end?
I don’t know if you’re familiar with MQTT tools like mosquitto_pub, which allows sending arbitrary MQTT messages, but here’s an example I just tried and worked fine:
Decoding that (!), the topic is "emon/testMQTTJSON", and the JSON payload is {"power":34,"energy":999} i.e. it’s a JSON list, with names in quotes and numeric items as straight digits. EmonCMS won’t accept anything else I believe, so any ON/OFF values will have to be converted to 1/0 or similar.