Community
OpenEnergyMonitor

OpenEnergyMonitor Community

EmonTx 3phase - Arduino Build

I am looking at measuring the consumption of a 3phase (4 wire) supply using a recently purchased emontx, for which I really need to disable the 433 MHz Radio and use the Serial interface directly to a Raspberry Pi (perhaps using EmonCMS), however there appear to be a few issues with this approach that I need to get to grips with.

I cannot fathom out which Libraries are required to build the Arduino sketch (I’m trying to use the latest Arduino IDE V1.8.13 on Ubuntu 20.04) - The ‘emontx-3-phase-userguide.pdf’ tells me I need 4 Arduino Standard Libraries (Wire / SPI / CRC16 / EEPROM) but I am unable to identify these from the dozens of libs that have some match for these words. Plus an another ‘OneWire’ (not even looked for this yet).

The serial data format from the 3phase Firmware that was shipped on the device (reports are being V1.4 but I suspect is really V1.6) does not seem to recognised by EmonHub - I have seen conflicting information on how to configure this,I tried this in my emonhub.conf

in the [interfacers] section:

[[SerialDirect]]
Type = EmonHubSerialInterfacer
[[[init_settings]]]
com_port = /dev/ttyAMA0 # or /dev/ttyAMA0 or/dev/ttyACM0 etc
com_baud = 9600 # to match the baud of the connected device
[[[runtimesettings]]]
pubchannels = ToEmonCMS,

and in the [node] section

[[99]]
nodename = emontx-serial
[[[rx]]]
names = powerL1, powerL2, powerL3, power4, Vrms, temp1, temp2, temp3, temp4, temp5, temp6, pulse
datacodes = h,h,h,h,h,h,h,h,h,h,h,L
scales = 1,1,1,1,0.01,0.01,0.01,0.01,0.01,0.01,0.01,1
units = W,W,W,W,V,C,C,C,C,C,C,p

But the emonhub logs shows:

2020-11-24 10:26:23,925 WARNING MainThread SerialDirect thread is dead.
2020-11-24 10:26:23,926 WARNING MainThread Attempting to restart thread SerialDirect (thread has been restarted 0 times…)
2020-11-24 10:26:23,927 INFO MainThread Creating EmonHubSerialInterfacer ‘SerialDirect’
2020-11-24 10:26:28,679 WARNING SerialDirect Exception caught in SerialDirect thread. Traceback (most recent call last):
File “/home/pi/git/emonhub/src/emonhub_interfacer.py”, line 32, in wrapper
return func(*args)
File “/home/pi/git/emonhub/src/emonhub_interfacer.py”, line 99, in run
rxc = self.read()
File “/home/pi/git/emonhub/src/interfacers/EmonHubSerialInterfacer.py”, line 90, in read
c.nodeid = int(f[0])
ValueError: invalid literal for int() with base 10: ‘246.46’

The libraries you need are listed in the “Learn” section under installing and using the Arduino IDE. Some of those won’t be needed in your particular case. Those that are needed are listed in the documentation here: 3-phase 3&4-wire PLL - V1.7: Update to 3-Phase PLL sketch

And there are more notes in the sketch source code itself. One that might throw some light on your interfacer problem is the comment in line 60: “For serial input, emonHub requires “datacode = 0” in place of “datacodes = …” as above.” Which is because, when you send the serial data - and as you can see by looking at the sketch - it arrives as plain text that does not need decoding, hence the zero or no datacode.

You should read the documentation, because it contains (we hope) useful information for you.

Thanks for the tip on where to find the information on using Arduino IDE and the link to V1.7- I have managed to build and flash V1.7 without the RF module enabled and get my local EmonCMS accepting the inputs.

Although I have a slight problem with getting EmonHub to work on my EmonCMS install as it is looking for a ‘var-log.mount’ service.

As I might eventually deploy a significant number of emonTx / emonPi or similar devices (could be over 30) across one of a number of locations I need to think more about how this might work.

I’m afraid I can’t help you with that. It’s probably one for @borpin or @TrystanLea

Do you mean you have a number of separate locations, each with a number of emonTx’s?
Do you have a LAN at each location? I’m not a networking expert, but I think our recommendation would be either a Pi Zero W connected serially to each emonTx, alternatively a FTDI/RS232 - Ethernet adapter, feeding into the LAN, and either an emonBase serving that group, or send all 30 data streams via Internet to one central emonBase. I think @pb66 manages a similar scheme, so he could have some useful input for you.

The idea is to have a number of measuring devices spread across a large site measuring power usage and perhaps other parameters for different parts of the site (if the demo system that I am currently working towards impresses those that are really interested - it could expand to several sites) with each sending data to a central location (over WiFi and corporate VPN) - not sure yet if that will be to an EmonCMS or to something else using MQTT - A Pi0W or Pi3B+ to collect the data from one or more EmonTx style devices that are close together is what I currently envisage.

Some Pi devices are already used for displaying corporate messages that might also display a sub-set of the collected information (one room or one group of equipment from a room).

OK, I’m getting the picture now. What I wrote above still seems valid.

A number of people here are quite impressed with Grafana.

That has been fixed in the recent update.

I have just updated from guithub (https://github.com/openenergymonitor/emonhub.git) - tried both master and stable branches, but I still get the same issue:

- installing emonhub.service
Failed to restart emonhub.service: Unit var-log.mount not found.
- Service ActiveState=inactive```

Hello @G0LGS

The service file with the check for /var/log can be found in the emonhub/service directory, here’s the line requiring this condition:
https://github.com/openenergymonitor/emonhub/blob/master/service/emonhub.service#L6

We removed the check for the data directory mount recently but the check for /var/log is still there.
Do you have /var/log on your system and ideally /var/log/emonhub for emonhub.log?

/var/log exists, but is NOT a mount point as does /var/log/emonhub.

I assume this is because log2ram did not get installed during the build process.

I may have missed something during the build - perhaps I got the options in config.ini from EmonScripts wrong.

I am confused by some of them - especially ‘emonSD_pi_env’ (which I see I set to 0).

As a work around I have changed emonhub.service to remove the dependency on var-log.mount

As it I’m still at the stage of fathoming out what works for our requirements I will probably rebuild my emoncms anyway.

Interesting, perhaps we need different service files for different environments… Im not so sure about this side of the configuration. It would be good to have a solution that works well in the different environments whilst addressing the reason for this inclusion in the first place, which I assume was to ensure the filesystem was up and running before starting emonhub.

Great, does that work fine on reboots?

Yes it was working on reboot.

I’m just finishing a re-install from EmonScripts on RPi,