Is anyone using the Open Energy Monitor (emonPi)

here is a great post by glyn

at openenergy.

maybe he is reading us… really a nice guy

I just got my emonTxv3 + emonPi, and after some regex fiddling I got everything working.
This is how I did it:

  1. Added the org.openhab.binding.mqtt jar addon file in the addons folder,
  2. Modifed openhab.cfg with this:

mqtt:emonHub.url=tcp://192.168.1.253:1883

(192.168.1.253 is the emonPI)

  1. My items defined like this:

/* OPEN ENERGY MONITOR /
Number mainPowerL1 { mqtt="<[emonHub:emonhub/rx/8/values:state:REGEX(([0-9]+),.
?)]" }
Number mainPowerL2 { mqtt=“<[emonHub:emonhub/rx/8/values:state:REGEX(.?,([0-9]+),.?)]” }
Number mainPowerL3 { mqtt=“<[emonHub:emonhub/rx/8/values:state:REGEX(.?,.?,([0-9]+),.?)]" }
Number vpPower { mqtt="<[emonHub:emonhub/rx/8/values:state:REGEX(.
?,.?,.?,([0-9]+),.?)]" }
Number mainPowerVrms { mqtt="<[emonHub:emonhub/rx/8/values:state:REGEX(.
?,.?,.?,.?,([0-9]+.[0-9]+),.?)]” }

NB:

  • restart openhab after adding the mqtt binding file or you might experience some weird regex matches, at least I did.
  • Remember to modify the iptables (firewall) rules on the emonPi so you can connect to the mqtt service remotely (1883)
1 Like

look at the post above.
There are sample config files working perfectly.

Please be aware that you have to open mosquitto ports on the emonpi (look at nodered config in the same blog of the post above).

I opened the same ports on openhab.
restarted services and bam

Did not notice your post and reposted. TX

I am having some trouble.
My items and sitemap have been copied literally from blogpost github.
It worked well as posted before but suddenly it does not anymore.
From the log I can see that the mqtt service is initialized and ona pc client and on emonpi I can see messaes arriving and sent…
I am currently working with a subset of items and sitemap with just emonpi related stuff to focus on it.
next step will be removing all other bindings.
Question: how can I see any traffic? in openhab.log there’s no trace of it .
I amlooking at the onscreen log after strting in debug mode (start_debug).

TX in advance

Gosh… forget the post above.
I must have deleted the bindings in a night manoeuvre…
working at night (currently 1am CET) due to wife curfew :slight_smile:

1 Like

Hi Ben,
I’m quite interested in your solution, as I already have mosquitto, influxDB and Grafana running. I’ve already an arduino uno r3 (funduino) and wonder which ethernet shield I need. It seems, there are some with and without sd card. In your code I found out, that PIN 4 is used for sd card. What is this for? Do I need a ethernet shield with sd card?
Is in your code more than the IP and username/password to be adapted?
Is your code compatible with the current EmonTx Shield, as I found your first postings on this topic from 2014?
Kind regards
Michael

Any ethernet shield should be fine, although I am no Arduino shield expert! Mine had a SD slot, which alot appear to have, but there may well be those without. I don’t use it for anything, I just noted that PIN 4 is used by it when present.

You will need to read the docs on OEM to learn how to calibrate your EmonPi, if you want accurate readings. Most of the calibration is related to the 9VAC adaptor you use, which varies of course.

I haven’t changed my code much at all over the years. My EmonPi just sits there publishing readings every 5s and has done for 2yrs!

The later EmonPi images have changed the MQTT format, which is now available in 2 forms. Either the form above using Regex to find the value which is the “node format”, or in the format of
emon/EMONPi/power1
emon/EMONPi/power2
which is the “nodevar format”.

I think the default on new images may be the “nodevar format”

Its set in the EmonHub Config Editor in the “EmonHubMqttInterfacer” section.
and the topic also needs setting in the “MQTT” section of /var/www/emoncms/settings.php

If you are unfamiliar with this, it may be easier to get an MQTT monitor program loaded, and subscribe to # to see what your device is putting out.

With the new format the items become similar to:

Number GridPower { mqtt="<[mosquitto:emon/emonTx_1/power1:state:default]" }
Number SolarPower { mqtt="<[mosquitto:emon/emonTx_1/power2:state:default]" }

note that I’m using an EMONTX rather than an EMONPI

1 Like

Whoops, that is a typo in my response - I am using the EmonTX as well, not the EmonPi.