Python plugin: Modbus RTU / ASCII / TCP/IP Topic is solved

Python and python framework

Moderator: leecollings

User avatar
Domoticx
Posts: 90
Joined: Sunday 07 January 2018 21:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Marienheem / The Netherlands
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by Domoticx »

Strange indeed!

And if you try register address 83 or 85?
My Domoticz plugins:
- Modbus RS485 RTU/ASCII/TCP

Maatwerk in: Domotica - Automatisering - Elektronica - 3D printing - Software ontwikkeling
Website / Webshop / Knowledge Center / Facebook (like de pagina en blijf op de hoogte!)
snooze7555
Posts: 8
Joined: Saturday 16 May 2020 17:35
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: Hengelo ov /NL
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by snooze7555 »

Domoticx wrote: Monday 18 May 2020 18:28 Strange indeed!

And if you try register address 83 or 85?

That's the problem. When is use 83 then the right value. Normal i use with de sniffer 84 :roll:
snooze7555
Posts: 8
Joined: Saturday 16 May 2020 17:35
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: Hengelo ov /NL
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by snooze7555 »

Hallo

It works, adress -1.

After 2 minutes then see attachment

Problem with domoticz. When i use custom the all ok
:D
Attachments
Solaredge.jpg
Solaredge.jpg (193.79 KiB) Viewed 3139 times
User avatar
Domoticx
Posts: 90
Joined: Sunday 07 January 2018 21:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Marienheem / The Netherlands
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by Domoticx »

snooze7555 wrote: Monday 18 May 2020 18:38
Domoticx wrote: Monday 18 May 2020 18:28 Strange indeed!

And if you try register address 83 or 85?

That's the problem. When is use 83 then the right value. Normal i use with de sniffer 84 :roll:
Yes, this is a common problem/thingy, there is no official modbus rule for register mapping, some manufactorers or software e.d. start with register 0 other with 1 and other with 40000 or 40001 in the documentation, sometime it's trail and error....
My Domoticz plugins:
- Modbus RS485 RTU/ASCII/TCP

Maatwerk in: Domotica - Automatisering - Elektronica - 3D printing - Software ontwikkeling
Website / Webshop / Knowledge Center / Facebook (like de pagina en blijf op de hoogte!)
User avatar
Domoticx
Posts: 90
Joined: Sunday 07 January 2018 21:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Marienheem / The Netherlands
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by Domoticx »

About modbus thingies...

Last week we have made a practical board to test all modbus stuff out for or new platform ConX, in wich you can create and add you own modbus devices easily!, stay tuned!
DomoticX ConX test board.jpg
DomoticX ConX test board.jpg (304.55 KiB) Viewed 3093 times
My Domoticz plugins:
- Modbus RS485 RTU/ASCII/TCP

Maatwerk in: Domotica - Automatisering - Elektronica - 3D printing - Software ontwikkeling
Website / Webshop / Knowledge Center / Facebook (like de pagina en blijf op de hoogte!)
webrazor
Posts: 61
Joined: Monday 09 November 2015 9:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by webrazor »

Hello everybody,

Today i started trying to read out 1 of my kwh meters through modbus RTU.
I wired everything up i'm using Raspberry Pi 4 with domoticz and RS485 RTU USB-A 2.0 Adapter 2-Pin.
The kwh meter is a ABB B23 put all the setting in the ABB the same as in the configuration of hardware in domoticz.
But can't get it to work, constant same error message in log.
  • 2020-07-16 19:19:23.609 (modbus ABB 3Fase) MODBUS DEBUG - INTERFACE: Port=/dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0, BaudRate=38400, StopBits=1, ByteSize=8 Parity=N
    2020-07-16 19:19:23.609 (modbus ABB 3Fase) MODBUS DEBUG - SETTINGS: Method=rtu, Device ID=1, Register=20488, Function=3, Data type=int16, Pollrate=10
    2020-07-16 19:19:25.623 (modbus ABB 3Fase) MODBUS DEBUG - RESPONSE: Modbus Error: [Input/Output] Modbus Error: [Invalid Message] Incomplete message received, expected at least 2 bytes (0 received)
    2020-07-16 19:19:25.623 (modbus ABB 3Fase - Modbus-READ) Updating device from 1:'0' to have values 1:'0'.
    2020-07-16 19:19:25.629 (modbus ABB 3Fase - Modbus-READ) Updating device from 1:'0' to have values 1:'0'.
    2020-07-16 19:19:25.623 Error: (modbus ABB 3Fase) Modbus error decoding or received no data (RTU/ASCII/RTU over TCP)!, check your settings!
    2020-07-16 19:19:25.629 Error: (modbus ABB 3Fase) Modbus error decoding or received no data!, check your settings!
These are my settings in the hardware config.
Image

And here is some information from the manual about the ABB B23 Kwh meter:
Image
Image

I'm testing to readout register 20488 that is the Active net (HEX 5008)

For some reason it is not working, between the USB RS485 converter and the ABB B23 is about 1 meter cable.
Anybody a idea why this is not working?
User avatar
Domoticx
Posts: 90
Joined: Sunday 07 January 2018 21:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Marienheem / The Netherlands
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by Domoticx »

Hi Webrazor,

Reviewing th error, it seems not a plugin issue, so it could be config mismatch, hw error, driver issue or else...

Ps. is there any documentation PDF for this device available?
My Domoticz plugins:
- Modbus RS485 RTU/ASCII/TCP

Maatwerk in: Domotica - Automatisering - Elektronica - 3D printing - Software ontwikkeling
Website / Webshop / Knowledge Center / Facebook (like de pagina en blijf op de hoogte!)
webrazor
Posts: 61
Joined: Monday 09 November 2015 9:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by webrazor »

Hello Domoticx,

Yes here is a download link for the manual.
www.wms.nl/download_file/view/112/186&v ... hE51d-Mfx9

From page 80 is about modbus protocol.
User avatar
Domoticx
Posts: 90
Joined: Sunday 07 January 2018 21:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Marienheem / The Netherlands
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by Domoticx »

webrazor wrote: Friday 17 July 2020 20:18 Hello Domoticx,

Yes here is a download link for the manual.
www.wms.nl/download_file/view/112/186&v ... hE51d-Mfx9

From page 80 is about modbus protocol.
Hi webrazor, seems the link is broken...
My Domoticz plugins:
- Modbus RS485 RTU/ASCII/TCP

Maatwerk in: Domotica - Automatisering - Elektronica - 3D printing - Software ontwikkeling
Website / Webshop / Knowledge Center / Facebook (like de pagina en blijf op de hoogte!)
webrazor
Posts: 61
Joined: Monday 09 November 2015 9:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by webrazor »

Domoticx wrote:
webrazor wrote: Friday 17 July 2020 20:18 Hello Domoticx,

Yes here is a download link for the manual.
www.wms.nl/download_file/view/112/186&v ... hE51d-Mfx9

From page 80 is about modbus protocol.
Hi webrazor, seems the link is broken...
Hmm if i click on the link i get the pdf download.
What about this?
https://search.abb.com/library/Download ... ion=Launch

Verstuurd vanaf mijn ONEPLUS A6003 met Tapatalk
Sprokkie
Posts: 13
Joined: Friday 22 June 2018 10:05
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by Sprokkie »

must be doing something wrong.

today fresh install buster-lite and domoticz 2020.2
copied the files in to the plugin folder
/home/pi/domoticz/plugins/modbus-read the file plugin.py
/home/pi/domoticz/plugins/modbus-write the file plugin.py

restart, reboot but stil nog modbus in the list of devices :(

i also wanted to install the modbus tcp i want to read out over the lan.
got an error
sudo: pip3: command not found

can someone point me in the right direction ?
Sprokkie
Posts: 13
Joined: Friday 22 June 2018 10:05
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by Sprokkie »

forgot to install pip3 and modbus tcp :oops:

now it works, at least i see th emodbus settings.

got another thing now,
the modbus device has a holding register and 8byte float.
i dont see the 8byte float, do i have to change modbus ini file ?
User avatar
Domoticx
Posts: 90
Joined: Sunday 07 January 2018 21:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Marienheem / The Netherlands
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by Domoticx »

webrazor wrote: Friday 17 July 2020 21:23
Domoticx wrote:
webrazor wrote: Friday 17 July 2020 20:18 Hello Domoticx,

Yes here is a download link for the manual.
www.wms.nl/download_file/view/112/186&v ... hE51d-Mfx9

From page 80 is about modbus protocol.
Hi webrazor, seems the link is broken...
Hmm if i click on the link i get the pdf download.
What about this?
https://search.abb.com/library/Download ... ion=Launch

Verstuurd vanaf mijn ONEPLUS A6003 met Tapatalk
Link now works!, can you try address 20487 or 20489

Are you sure the BAUD rate and 1N8 settings are correct to match the meter?
My Domoticz plugins:
- Modbus RS485 RTU/ASCII/TCP

Maatwerk in: Domotica - Automatisering - Elektronica - 3D printing - Software ontwikkeling
Website / Webshop / Knowledge Center / Facebook (like de pagina en blijf op de hoogte!)
User avatar
Domoticx
Posts: 90
Joined: Sunday 07 January 2018 21:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Marienheem / The Netherlands
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by Domoticx »

Sprokkie wrote: Wednesday 22 July 2020 16:19 forgot to install pip3 and modbus tcp :oops:

now it works, at least i see th emodbus settings.

got another thing now,
the modbus device has a holding register and 8byte float.
i dont see the 8byte float, do i have to change modbus ini file ?
Hi,

8 byte float is very rare, can you post specs and pdf of the device?, and your screen settings and log?
My Domoticz plugins:
- Modbus RS485 RTU/ASCII/TCP

Maatwerk in: Domotica - Automatisering - Elektronica - 3D printing - Software ontwikkeling
Website / Webshop / Knowledge Center / Facebook (like de pagina en blijf op de hoogte!)
webrazor
Posts: 61
Joined: Monday 09 November 2015 9:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by webrazor »

Domoticx wrote: Wednesday 22 July 2020 20:10 Link now works!, can you try address 20487 or 20489
I did a test with both addres 20487 and 20489 but same error message.

Code: Select all

2020-07-22 20:33:30.214 Status: (modbus ABB 3Fase) Exiting work loop.
2020-07-22 20:33:30.274 Status: (modbus ABB 3Fase) Stopping threads.
2020-07-22 20:33:30.274 Status: (modbus ABB 3Fase) Stopped.
2020-07-22 20:33:30.274 Status: (modbus ABB 3Fase) Started.
2020-07-22 20:33:30.482 Status: (modbus ABB 3Fase) Entering work loop.
2020-07-22 20:33:30.483 Status: (modbus ABB 3Fase) Initialized version 2020.2F, author 'S. Ebeltjes / DomoticX.nl'
2020-07-22 20:33:30.206 Error: (modbus ABB 3Fase) Modbus error decoding or received no data (RTU/ASCII/RTU over TCP)!, check your settings!
2020-07-22 20:33:30.211 Error: (modbus ABB 3Fase) Modbus error decoding or received no data!, check your settings!
2020-07-22 20:33:40.484 (modbus ABB 3Fase) Pushing 'onHeartbeatCallback' on to queue
2020-07-22 20:33:40.500 (modbus ABB 3Fase) Processing 'onHeartbeatCallback' message
2020-07-22 20:33:40.500 (modbus ABB 3Fase) Calling message handler 'onHeartbeat'.
2020-07-22 20:33:40.500 (modbus ABB 3Fase) onHeartbeat called
2020-07-22 20:33:40.500 (modbus ABB 3Fase) MODBUS DEBUG - INTERFACE: Port=/dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0, BaudRate=38400, StopBits=1, ByteSize=8 Parity=N
2020-07-22 20:33:40.500 (modbus ABB 3Fase) MODBUS DEBUG - SETTINGS: Method=rtu, Device ID=1, Register=20487, Function=3, Data type=int16, Pollrate=10
2020-07-22 20:33:42.512 (modbus ABB 3Fase) MODBUS DEBUG - RESPONSE: Modbus Error: [Input/Output] Modbus Error: [Invalid Message] Incomplete message received, expected at least 2 bytes (0 received)
2020-07-22 20:33:42.513 (modbus ABB 3Fase - Modbus-READ) Updating device from 1:'0' to have values 1:'0'.
2020-07-22 20:33:42.521 (modbus ABB 3Fase - Modbus-READ) Updating device from 1:'0' to have values 1:'0'.
2020-07-22 20:33:42.513 Error: (modbus ABB 3Fase) Modbus error decoding or received no data (RTU/ASCII/RTU over TCP)!, check your settings!
2020-07-22 20:33:42.521 Error: (modbus ABB 3Fase) Modbus error decoding or received no data!, check your settings!

2020-07-22 20:34:08.226 Status: (modbus ABB 3Fase) Stop directive received.
2020-07-22 20:34:08.226 Status: (modbus ABB 3Fase) Exiting work loop.
2020-07-22 20:34:08.426 Status: (modbus ABB 3Fase) Stopping threads.
2020-07-22 20:34:08.427 Status: (modbus ABB 3Fase) Stopped.
2020-07-22 20:34:08.427 Status: (modbus ABB 3Fase) Started.
2020-07-22 20:34:08.598 Status: (modbus ABB 3Fase) Entering work loop.
2020-07-22 20:34:08.599 Status: (modbus ABB 3Fase) Initialized version 2020.2F, author 'S. Ebeltjes / DomoticX.nl'
2020-07-22 20:34:18.600 (modbus ABB 3Fase) Pushing 'onHeartbeatCallback' on to queue
2020-07-22 20:34:18.616 (modbus ABB 3Fase) Processing 'onHeartbeatCallback' message
2020-07-22 20:34:18.616 (modbus ABB 3Fase) Calling message handler 'onHeartbeat'.
2020-07-22 20:34:18.616 (modbus ABB 3Fase) onHeartbeat called
2020-07-22 20:34:18.616 (modbus ABB 3Fase) MODBUS DEBUG - INTERFACE: Port=/dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0, BaudRate=38400, StopBits=1, ByteSize=8 Parity=N
2020-07-22 20:34:18.616 (modbus ABB 3Fase) MODBUS DEBUG - SETTINGS: Method=rtu, Device ID=1, Register=20489, Function=3, Data type=int16, Pollrate=10
2020-07-22 20:34:20.629 (modbus ABB 3Fase) MODBUS DEBUG - RESPONSE: Modbus Error: [Input/Output] Modbus Error: [Invalid Message] Incomplete message received, expected at least 2 bytes (0 received)
2020-07-22 20:34:20.629 (modbus ABB 3Fase - Modbus-READ) Updating device from 1:'0' to have values 1:'0'.
2020-07-22 20:34:20.637 (modbus ABB 3Fase - Modbus-READ) Updating device from 1:'0' to have values 1:'0'.
2020-07-22 20:34:20.629 Error: (modbus ABB 3Fase) Modbus error decoding or received no data (RTU/ASCII/RTU over TCP)!, check your settings!
2020-07-22 20:34:20.637 Error: (modbus ABB 3Fase) Modbus error decoding or received no data!, check your settings!
Domoticx wrote: Wednesday 22 July 2020 20:10 Are you sure the BAUD rate and 1N8 settings are correct to match the meter?
Image

So no luck yet
User avatar
Domoticx
Posts: 90
Joined: Sunday 07 January 2018 21:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Marienheem / The Netherlands
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by Domoticx »

@webrazor

What kind of wiring have you used?

Ps. Connection A+ to A+ and B- to B- is correct? and connected to the right connections on the meter?
(maybe by accident on the pulse connection mounted?)
My Domoticz plugins:
- Modbus RS485 RTU/ASCII/TCP

Maatwerk in: Domotica - Automatisering - Elektronica - 3D printing - Software ontwikkeling
Website / Webshop / Knowledge Center / Facebook (like de pagina en blijf op de hoogte!)
webrazor
Posts: 61
Joined: Monday 09 November 2015 9:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by webrazor »

Domoticx wrote: Wednesday 22 July 2020 22:19 What kind of wiring have you used?
3x0,28mm multibus cable use only 2 wires for A+ and B-.
Where is C connection for, because on my USB to serial i only have 2 connections. There is also a 3 connection USB to serial interface available what is the difference between 2 and 3 connection USB to serial interface?
Domoticx wrote: Wednesday 22 July 2020 22:19 Ps. Connection A+ to A+ and B- to B- is correct? and connected to the right connections on the meter?
(maybe by accident on the pulse connection mounted?)
These connection options the ABB B23 has.
Do is connected A+ to A(37) and B- to B(36)

Image
Sprokkie
Posts: 13
Joined: Friday 22 June 2018 10:05
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by Sprokkie »

Domoticx wrote: Wednesday 22 July 2020 20:11
Sprokkie wrote: Wednesday 22 July 2020 16:19 forgot to install pip3 and modbus tcp :oops:

now it works, at least i see th emodbus settings.

got another thing now,
the modbus device has a holding register and 8byte float.
i dont see the 8byte float, do i have to change modbus ini file ?
Hi,

8 byte float is very rare, can you post specs and pdf of the device?, and your screen settings and log?
its a scada system called mango.
i got it working with 64byte float.
User avatar
Odiebla
Posts: 5
Joined: Friday 14 September 2018 20:46
Target OS: Linux
Domoticz version: 2020.2
Location: Amsterdam
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by Odiebla »

Hi All,

I have a brand-new SolarEdge inverter and I've been digging into the wonderful world of Modbus and found this plugin. In essence I have this working (although it seems that I need to use a register value -1 in Domoticz compared to the SolarEdge/SunSpec documentation to get correct readings, this seems a base = 0 / base = 1 issue?).

However, for most values I need to set a Scale Factor (which I now do manually) but I see the plugin is also capable of reading this from the next register. For some this works, as the SF is in the next but for some values (for example "AC Phase A Current Value” in 40073) this doesnt work as there is first a Phase B and Phase C value in 40074 and 40075 and then in 40076 there is a SF used for all 3 registers.

Am I missing here something, or would it be nice if the plugin has a "In next register +1/In next register +2/In Next Register +3" option (+1 for the true next register, +3 for the 3 phase example I just mentioned.

Forgive me if I'm ignoring something here, Modbus is a pretty new territory for me :)
markh
Posts: 1
Joined: Wednesday 29 July 2020 18:38
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by markh »

Hello Odiebla,

I added the support for the scale factor as I also have a SolarEdge inverter. I did not see that SolarEdge also could store the scale factor in anything other than the next register, so I did not add support for that.
I only wanted to read the power value and the scale factor for that was in the next register.
Looking through the documentation of SolarEdge there is voltage registers for which the scale factor can be even further away than the example you showed. I am not sure if it is a good idea to add a dropdown option for every possibility as that might make a long list.
I am not sure if we could add a separate field for the offset where the scale factor is located. At least then users could fill in something themselves and the dropdown list could remain compact.

Do take into account that at the moment you cannot reliably read more than one register from the SolarEdge inverter. At least when I tried it I got errors that the read failed. Not sure what the problem is exactly. If you want to do that, the modbus plugin might not be your best option. Or at least this problem needs to be fixed first.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest