FHEM Forum

FHEM => English Corner => Thema gestartet von: dudasekk am 25 Juli 2019, 19:14:52

Titel: Help with two or more modbus devices on RS485 over TCP - RS485 converter
Beitrag von: dudasekk am 25 Juli 2019, 19:14:52
Hello,
I have ETH/RS485 converter and on RS485 I have 2 modbus devices.
If I create virtual serial port via socat

### Create virtual serial interface via
### socat -d -d -d pty,link=/home/karel/com1,echo=0,crnl tcp:ew11-1:8899
define MB1 Modbus /home/karel/com1@9600,8,N,1

define Relay4_6 ModbusAttr 6 10 RTU
attr Relay4_6 IODev MB1

define MD01_01_ew111 ModbusMD0X 30 30 RTU
attr MD01_01_ew111 IODev MB1


Is there clearly definition ?

define  xxx ModbusAttr 6 10 aaa.bbb.ccc.ddd:8899 RTU
define yyy ModbusAttr 30 30 aaa.bbb.ccc.ddd:8899 RTU

have problems with open/close and no response.
Thank you
Titel: Antw:Help with two or more modbus devices on RS485 over TCP - RS485 converter
Beitrag von: pejonp am 25 Juli 2019, 21:14:20
Example Definition usb-port to tcpip

Sender:
socat TCP4-LISTEN:54321,fork,reuseaddr /dev/signald2,raw,echo=0,b57600 &

Empfänger:(defmod WH2 SIGNALduino Inet-IP:54321)

define Relay4_6 ModbusAttr 6 10 inet-ip:54321 RTU

Pejonp
Titel: Antw:Help with two or more modbus devices on RS485 over TCP - RS485 converter
Beitrag von: dudasekk am 25 Juli 2019, 23:21:26
Hi,
It is working if I have only one modbus device connected to Eth2RS485 converter, but not working when two or more devices on RS485.
I try it before.
My connection:

Fhem server --- network --- Eth2RS485 ---- Relay4_6 --- MD01 [ ---- other modbus devices ]
                       ^^^^^^^^^^^^^                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                        Ethernet          8899 - RS485    RS485

I need to define Modbus bus and then define multiple devices connected to this bus with different address.

Thank you
Karel
Titel: Antw:Help with two or more modbus devices on RS485 over TCP - RS485 converter
Beitrag von: pejonp am 26 Juli 2019, 14:27:50
@dudasekk

Master/Slave or 1. device pro usb/tcpIp

https://wiki.fhem.de/wiki/ModbusAttr

pejonp
Titel: Antw:Help with two or more modbus devices on RS485 over TCP - RS485 converter
Beitrag von: dudasekk am 26 Juli 2019, 21:41:16
Hi,
relay module and MD module ( temperature and humidity) are slaves. One master is fhem server. Slaves are connected on RS485 bus via EW11 (WIFI to RS485).
My full working config is in attachment. I would like to make direct connection to RS485 bus via TCP port for more slaves.
I think, this is for change in 98_Modbus.pm.
Titel: Antw:Help with two or more modbus devices on RS485 over TCP - RS485 converter
Beitrag von: BrainHunter am 18 September 2019, 23:41:27
Hi,

this is funny, I did the same thing today...
Is there a better way without socat?


Titel: Antw:Help with two or more modbus devices on RS485 over TCP - RS485 converter
Beitrag von: disney am 29 September 2019, 23:40:04

Would I be right in thinking you are trying to connect two PZEM power monitors to FHEM?

If so, my approach may work for you.

Basically, I used 5V esp8266 modules plus the sonoff-tasmota firmware to make the PZEM modules wireless allowing the data to be sent to FHEM via an MQTT server.

I am using PZEM-16 modules which output RS485. These were modified to output TTL level serial data by removing the internal MAX485 chip and addind two internal jumper wires to bring the TTL serial out via the four terminal screw connectors. It then only requires four short wires to provide power and the TTL serial port to the ESP8266.  An addational 100uf cap across the power lines to allow the ESP8266 to work reliably.

The sonoff-tasmota firmware already has support for the PZEM-04 and PZEM-16 modules so the rest is just configuration. 

If you want I can post some images of the mod if you want to try this yourself.