Can I connect emonTx's to EmonPi via a wired connection instead of wireless?

I was in quick edit mode and only had access to the twitter link. Edited it now.

This is exactly what I wish to do… I figured that I needed 3 usb serial adapters
( good ftid ones )

I still have a couple of relevant questions :

  1. If I order a EmonPi now will it include wireless network connection (wifi) ?
  2. Upon ordering emonTx will it include the firmware to allow serial connection ?
  3. What is the update rate of the emonTx and can the EmonPi handle 3 via serial at 5 seconds ?
  4. If I wish to compare the pulse on my smart meter to the EmonPi data logs for accuracy is that supported ?

Hopefully I can connect all 3 emonTx to monitor my appliance rings and water heater etc via serial and have the EmonPi log the overall incoming power and potentially Solar in the future via wifi while keeping and eye on how accurate the “smart” power meter billing claims…

While I could build my own I’m happy to purchase through the shop to support the men/women/children

regards

John Jones

  1. Yes (it has the RPI model 3 inside, with an acrylic fascia to let the signal out!)
  2. I believe so - but the actual dialect of the serial data seems to be in a state of change, so some programming might be necessary.
  3. The default is 10 s, but you can change that in the sketch. A programmer will be required. The emonPi can handle that (and faster), emoncms.org will refuse.
  4. If you use and accumulate the input pulses, yes - but you’ll need to distinguish in your input processing between import and export, because I believe your meter pulses ignore export.

Not that “they” will believe you if you contest it! You’ll need to calibrate everything very carefully to get inside the accuracy band of your supplier’s meter, and you’ll need some pretty good test gear to do that.

On behalf of @glyn.hudson, @TrystanLea and @Gwil - Thank You. :thumbsup:

The emonTx V3 can be connected to the emonPi without any change in emonPi FW.

Just connect to emonPi using USB adapter and add the following to emonhub.conf:

[interfacers]
### This interfacer manages the EmonTx3 ESP format serial
[[SerialTx3e]]
     Type = EmonHubTx3eInterfacer
      [[[init_settings]]]
           # Un-comment line below if using RS485 adapter
           #com_port = /dev/ttyRS485-0
           # default com port if using USB to UART adapter
           com_port= /dev/ttyUSB0
           com_baud = 115200
      [[[runtimesettings]]]
           pubchannels = ToEmonCMS,

It should work for multiple USB devices, by duplicating and changing USB0 to USB1. I’ve not tested this

Yes, you can connect a optical pulse sensor to the emonTx V3: Optical Utility Meter LED Pulse Sensor - Shop | OpenEnergyMonitor

I know this post is very old, but I have been all over the place trying to find a simple, concise answer .
I have a emonpi and an emonTx.
The wireless comm is poor between them.
What I want to do is wire the comm together.
I don’t think RS232 (serial) is going to work due to distance limitations (50 feet, and I need about 100 feet), so my other option is RS485.
I have a USB to RS485 adapter (assuming the emonPi end?)
I have several RS232 to RS485 adaptors with +5,gnd,DI,DE,RO,RE pins and the two A/B rs485 terminals.
This one;
https://www.amazon.com/gp/product/B088Q8TD4V/ref=ppx_yo_dt_b_asin_title_o02_s00?ie=UTF8&psc=1

First, from what I have gathered from all the different posts that i have read, it is possible, but the details are rather poor, and second, do I have the correct RS232 to RS485 adapter?
My adapter is consists of several resistors (terminating and pullup) and a MAX485 chip, with two headers and a screw terminal strip.
Don’t know how to connect the DE and RE terminals as they are enable pins.
The blog that owenduffy has shows an adaptor but NOTHING is mentioned as to WHERE/WHAT it is… not helpful!
this blog:
https://owenduffy.net/blog/?p=9942

IF I can get away with wired serial, I could, but the distance I am looking at is probably too long for that, hence the RS485.
I have tried to search for answers, but have come up empty handed (or at least too scattered as to what i want to do).

I think what you have should work, but the data that’s available for the Amnbest part is - shall we say - novel, and requires a bit of unpicking.

First,

Yes, that’s correct.

Second, the Amnbest adapter. It mentions it is half-duplex. That’s OK, you are only sending from the emonTx RS232 to the RS485, so it also means that you can permanently enable data in that direction and never enable data in the opposite direction. (Half-duplex means you can send data in both directions, but not at the same time, hence the need to enable either the receiver or the driver.)

Further down the page, you get the pin connections.
The first catch is the emonTx is NOT labelled conventionally: Tx receives data and is looking for the other Tx pin, and Rx sends data and is looking for the other Rx pin. Confusing? Absolutely.

As the Tx only ever transmits (unless you’re programming it or calibrating it, which you will need to do with the programmer connected directly instead of the RS485 adapter), you can permanently enable the driver and never enable the receiver.

A & B. These are the RS485 connections. You may or may not need the GND connection to the other end - there was a long discussion about that a few months ago - the link is lower down.
RO – Receiver Output. You don’t need to connect this - no data will be coming in. In fact, if it does, it might well corrupt the calibration of the emonTx.
RE – Receiver Output Enable. This should be pulled high to disable the receiver. According to the diagram it does have an internal pull-up, so this can be left with no connection.
DE – Driver Output Enable (high to enable) This should be pulled high to enable the receiver. According to the diagram it does have an internal pull-up, so this can also be left with no connection.
DI – Driver Input (to Tx pin of micro controller) As I wrote above, this goes to the Rx pin of the FTDI connector on the emonTx.
GND Connect to the emonTx GND (either on the FTDI or the screw connector)
VCC. Connect to the 5 V pin of the screw connector, and you’ll need the 5 V USB power to supply the emonTx - the a.c. adapter does not supply the 5 V rail, only the 3.3 V.

And I think that should work hardware-wise. I’d advise reading https://electrical-engineering-portal.com/correct-cabling-modbus-rs485 and this topic too RS485 and other sensor cabling

Despite what the first reference says about A & B legs, if it doesn’t work it’s worth swapping them and checking, because some manufacturers apparently label them wrongly.

According to Glyn’s much earlier post, you’ll need to send the data in the EmonHubTx3eInterfacer output format in your emonTx. Depending on the age of your emonTx, it might be called that or “Key:value” format.

That is what I was unsure of… thank you for clarifying that!

Yes, I have seen that in other posts, thanks again!

Once again, thank you. Makes this SO much easier!

I appreciate ALL the detail that you have given me! REALLY brings it all together and 'splains the details that I have been searching for, rather unsuccessfully. Thank you so very much!

i bought my EmonTX a couple of months ago, and when connected to Arduino terminal, I have EmonTX v. 3.4 and EmonLibCM Continuous monitoring version 2.0, so i think that is the latest version?
Isn’t there a newer FW version for the TX that supports more than 3 temperature sensors? I thought I saw that in Github… think I should try and get the RS485 working FIRST though!

Also need to get my Emonpi to talk to the RS485 to USB adaptor that i have.
I thought I read that I can SSH into the Pi and modify a file?
Also, modify and upload a file to the TX to talk RS485 and not the text that the serial is talking now?
On the TX, do I use my USB to serial converter to send the FW to the TX. I am using Arduino IDE since I am somewhat familiar with it.
Just need to get the libraries setup correctly… I always seem to have a problem with that… DARN IT!

Once again, thank you so VERY much for helping me out! It is appreciated!

My notes say that is the latest (unless it’s been changed and nobody has told me, which is highly likely).
The problem with emonLibCM is the processor is very busy, and fetching temperature readings takes an inordinate amount of time, to the point where you lose too many energy samples while the sensors are sending their data. That’s the reason for limiting the number. You can increase it - at your peril.
Here is the emonTx getting the value from just TWO temperature sensors - it takes 1½ mains cycles (nearly two for you) to do so.

RS485 is a hardware connection. It has nothing to do with the format of the data that is being carried.
If you turn RF off using the on-line settings/calibration, the output should be sent in the correct format. You don’t need the radio any more, and turning it off will prevent two sets of values arriving in emonCMS.

If your converter is equivalent to the programmer sold by the shop, then yes, you use that (with the emonTx right next to the laptop so that the programmer plugs straight in to the emonTx).

There’s a page in Learn about setting up the Arduino IDE with the 3 major operating systems. I advise you not to go near platformio - when I tried it, it effectively destroyed my OEM set-up and it took hours to put everything straight again.

Well that makes sense to limit the number of inputs to be processed. After all the Tx has 4 CT, 1 ACV, and 3 temps and 1 pulse inputs, so there is alot to process.
I was wondering why the limitation on the Tx’s 3 temp inputs vs. the Pi’s (up to) 6 temps. The Pi has MO-Power!

Yes, I am aware of the RS485/RS232/etc. just being a type of hardware communication and NOT a “data format”.
I just thought i remembered reading somewhere on this forum that the data coming out of the serial port is not formatted correctly for the Pi unless the radio is turned off, and yes, the radio does need to be turned off so that the Pi doesn’t receive two sets of data. Might also take some load off the Tx’s processor.

I did look at the Learn section, but at the time I was probably totally confused with reading all the posts, so the info didn’t make sense. I will revisit that section.
I did try platformio a while back and didn’t really like it. I will NOT go near it now after hearing that it totaled your setup… and I am somewhat familiar with Arduino after using it with my 3D printer controller. Just been a while…

Thank You for being patient with me and offering all your help! I does get frustrating reading some many different posts and trying to make sense of it all, but the information is there!

My USB to UART converter seems to work ok. It is 5/3.3v switchable and I have been using it to monitor the TX while it is running using Arduino’s monitor. I just haven’t talked to the TX yet.
I just have to use short jumpers between the TX and converter, with 5v/gnd/tx/rx connected… seems to work ok!
I am taking a read of the learn section now and will dive into it NOW that you have helped me so much!

I think the library lists need to be updated - I’ll look at that.

Indeed it does. The additions are:

Library Link Notes
emonEProm https://community.openenergymonitor.org/uploads/short-url/eSkSOEesXkOL2FtaMCkrzhnUAOF.zip Manages the EEPROM when saving config & energy values
rfmTxLib https://community.openenergymonitor.org/uploads/short-url/2itZ1bA7J0D1bfJO2byhattak9U.zip Transmit-only - message format is compatible with JeeLib.
  The following are NOT compatible with JeeLib and the RFM12B and the RFM69 in ‘compatibility’ mode (i.e. using “#define RF69_COMPAT 1”).
rf69 https://community.openenergymonitor.org/uploads/short-url/5aI8TKgQAIJqOGOIH5443qD1oz1.zip RFM69 ‘Native’ format - does not check for a busy radio channel
rfm69nTxLib https://community.openenergymonitor.org/uploads/short-url/pv8ewlR5XzEfB8M4Qge6ekUIlOR.zip RFM69 ‘Native’ format version of rfmTxLib

True, the Pi does have more power.

But, the front-end processor used in the emonPi is the same ATMEGA 328p that’s in an emonTx.

The emonPi’s front-end is essentially a stripped-down version of the one used in the EmonTx.

Well still having problems.
I received a proper serial to RS485 adaptor, with the controller chip and rx/tx in/outs and +5 and gnd and A/B for the 485 bus, and connect only the +5, gnd, and Rx pins on the emonTx’s programming header.
The RX light on the RS485 adapter blinks when sending, so I have the correct pins.

I used Glyn’s addition to emonhub.conf and changed it for a sUB to RS485 adapter:

### This interfacer manages the EmonTx3 ESP format serial
[[SerialTx3e]]
     Type = EmonHubTx3eInterfacer
      [[[init_settings]]]
           # Un-comment line below if using RS485 adapter
             **com_port = /dev/ttyRS485-0**
           # default com port if using USB to UART adapter
           #com_port= /dev/ttyUSB0
           #com_baud = 115200
      [[[runtimesettings]]]
           pubchannels = ToEmonCMS,

and this is what I got in the log (spoiler alert… ERRORS)

2021-08-31 05:16:10,130 INFO     MainThread Opening hub...
2021-08-31 05:16:10,130 INFO     MainThread Creating EmonHubJeeInterfacer 'RFM2Pi'
2021-08-31 05:16:12,137 INFO     MainThread RFM2Pi device firmware version & configuration: not available
2021-08-31 05:16:12,138 INFO     MainThread Setting RFM2Pi baseid: 5 (5i)
2021-08-31 05:16:13,140 INFO     MainThread Setting RFM2Pi frequency: 433 (4b)
2021-08-31 05:16:14,142 INFO     MainThread Setting RFM2Pi group: 210 (210g)
2021-08-31 05:16:15,144 INFO     MainThread Setting RFM2Pi quiet: 1 (1q)
2021-08-31 05:16:16,147 INFO     MainThread Setting RFM2Pi calibration: 230V (1p)
2021-08-31 05:16:17,150 INFO     MainThread Creating EmonHubTx3eInterfacer 'SerialTx3e'
2021-08-31 05:16:17,152 **ERROR    MainThread [Errno 2] could not open port /dev/ttyRS485-0: [Errno 2] No such file or directory: '/dev/ttyRS485-0'**
2021-08-31 05:16:17,154 INFO     MainThread Creating EmonHubMqttInterfacer 'MQTT'
2021-08-31 05:16:17,158 INFO     MainThread Setting MQTT node_format_enable: 1
2021-08-31 05:16:17,159 INFO     MainThread Setting MQTT nodevar_format_enable: 1
2021-08-31 05:16:17,159 INFO     MainThread Setting MQTT nodevar_format_basetopic: emon/
2021-08-31 05:16:17,161 INFO     MainThread Creating EmonHubEmoncmsHTTPInterfacer 'emoncmsorg'
2021-08-31 05:16:17,163 INFO     MainThread Setting emoncmsorg apikey: set
2021-08-31 05:16:17,163 INFO     MainThread Setting emoncmsorg url: https://emoncms.org
2021-08-31 05:16:17,164 INFO     MainThread Setting emoncmsorg senddata: 1
2021-08-31 05:16:17,165 INFO     MainThread Setting emoncmsorg sendstatus: 1
2021-08-31 05:16:17,462 INFO     MQTT       Connecting to MQTT Server
2021-08-31 05:16:17,567 INFO     MQTT       connection status: Connection successful
2021-08-31 05:16:17,568 INFO     emoncmsorg sending: https://emoncms.org/input/bulk.json? data=[[1630383377.200861,5,1414.5,-1.05,2828,240.82614,21,20.8,21,21,21,0,3]]&sentat=1630383377&apikey=E-M-O-N-C-M-S-A-P-I-K-E-Y
2021-08-31 05:16:17,673 INFO     MQTT       on_subscribe
2021-08-31 05:16:19,087 INFO     MQTT       Publishing 'node' formatted msg

So OBVIOUSLY I am doing something wrong, or missing a step…

I tried verifying the FW with Arduino, selecting the atmega 328p xplained mini, and the verify failed. Isn’t this the correct board?

I want to disable the radio, but according to what Glyn wrote, no FW mod is needed, just add the lines to emonhub.conf like I tried, but that didn’t work…
REALLY stumped! (obviously not enough knowledge… but I’m trying!)

A little more testing tonight…
I connected to the emonTx, disabled the radio (x0), saved to eeprom (s), exit (x) and the emonTx continued to run.
I disconnected my serial to USB converter, and connected my serial to RS485 converter and the Rx light on the converter flashed in sync with the emonTx’s activity led.

I copied and pasted Glyn’s code from above and uncommented the line for Rs485, and commented the ttyUSb0 line (I thought that was for direct serial and not RS485.

### This interfacer manages the EmonTx3 ESP format serial
[[SerialTx3e]]
     Type = EmonHubTx3eInterfacer
      [[[init_settings]]]
           # Un-comment line below if using RS485 adapter
           com_port = /dev/ttyRS485-0
           # default com port if using USB to UART adapter
           #com_port= /dev/ttyUSB0
           #com_baud = 115200
      [[[runtimesettings]]]
           pubchannels = ToEmonCMS,

Log shows that it cannot open port and no data, so something is different between what Glyn posted and how the EmonPi is now…OUI!

Is that address correct on your machine? If you list the ports, ls -l /dev/tty* and it’s not listed, that’s why it can’t open the port.

If I do that, I see every number from tty0 to tty63, ttyS0 to ttyS31, and a few more besides, but not one with the format with “-0” on the end. But I don’t have a USB-RS485 adapter.

Thank you. I did the ls -l /dev/tty* and you are correct… USB -0 is NOT listed, BUT USB0 IS listed so I tried that and…
NO GOOD.
I wish glyn would take a look as something has changed since he posted, but he does say that he has not tried an RS485 adaptor.

"It should work for multiple USB devices, by duplicating and changing USB0 to USB1. I’ve not tested this"
This was back in July of 2017, so NOT current, and who knows WHAT changes have happened since then!

I sure wish there was a “dummy” guide somewhere, with examples… it might give me a clue as to what I am doing wrong. It can’t be THAT difficult, but the correct ports/names/etc MUST be correct or it ain’t gonna work!

I have turned the radio off on my Tx board, and the Rx led is flashing on my serial to RS485 adapter, so I believe the data is being sent to the Pi.

Also of note… there is no dev/ttyRS485 listed when I ls -l , therein lies the problem.
Like you, I do see tty0 to tty63 and 4 more including ttyUSB0, so there must have been a change to what glyn posted.

I’ll look around some more to see how to get the RS485 device added…

What does lsusb tell you? with and without the RS485 adapter plugged in?

Did anything that gives us a hint come with your RS485 to USB adapter?

Failing that, I would first try all the USB… addresses, because it won’t necessarily be the same as the one Glyn found/used.

I don’t think you’re doing anything wrong, it’s just that you haven’t got the information to enable you to do it right.

That’s very true. I can understand your frustration, but I’m seriously handicapped because I’ve never used one of those adapters so I’ve never been in the position of getting one to work. All I can do is give you a steer in what I hope will be the right direction. You at least have the thing in your hand and you’re able to try things.

1 Like

Well I DO VERY much appreciate the help!
I ran the lsusb command and my USB to RS485 adapter comes back as:

pi@emonpi:~ $ lsusb
Bus 001 Device 005: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter <----- THIS IS THE ADAPTER
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

I tried plugging the adapter into a different USB port on the Pi, and the “device” number changed, just to verify that the Pi is actually seeing the adapter.

When I unplug the adapter, the QinHeng entry goes away, so it is being identified as a USB to serial adapter.
Nothing came with the adapter… it was a cheapie from Amazon, and the package sticker indicate “JBtek USB to RS485”.
The controller is a CH340G and drives a MAX485 (probably a clone though). There is a 12 Mhz xtal driving the controller chip, so it is probably a USB to serial converter and they are driving the 485 for the RS485 output.
That is why the ls command sees it as a USB to serial interface, so I will treat it as one.

I will try using USB5 in the Emonpic configuration and see if that works.

The bit you need is 1a86:7523

Look at this post How to match a ttyUSBX device to a USB Serial device

It tells you how to link that adapter - no matter which port you plug it in to - to a device name. You then refer to it by that name, in for example, Glyn’s Interfacer. My guess is this is the part he left out.

I’m not sure whether you need a restart for your machine to read and use the rule(s) you add.

Looked at the link you provided and THERE IT WAS!!!
Found the 99-com.rules and copied the line for the ch304 subsystem:

SUBSYSTEM=="tty", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", SYMLINK+="CH340", MODE="0666"

but when I tried to save it, permission was denied… must be read only so I need to change that permission and then add the line and save it.

WE ARE GETTING CLOSER!!!