Python plugin: Modbus RTU / ASCII / TCP/IP Topic is solved
Moderator: leecollings
-
- Posts: 13
- Joined: Saturday 25 November 2017 20:33
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
Hi
Great job
works fine for me with Unitronics V350 PLC
i can read memory intger in TCP mode thanks !
is it possible to read multiple registers with only one command and have them in multiple custom sensors ?
or i have to read 1 register by command ?
thanks
Great job
works fine for me with Unitronics V350 PLC
i can read memory intger in TCP mode thanks !
is it possible to read multiple registers with only one command and have them in multiple custom sensors ?
or i have to read 1 register by command ?
thanks
-
- Posts: 5
- Joined: Wednesday 14 February 2018 9:34
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
Unfortunately Domoticz doesn't start at all , after installation of the new true TCP plugin version. Maybe because I'm already on the Domo beta?
Will there be eventually a new plugin Version also supporting the latest Domo, then I can test reading and writing some TCP_modbus Devices
Will there be eventually a new plugin Version also supporting the latest Domo, then I can test reading and writing some TCP_modbus Devices

- 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: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
Bonebuster got it working with domoticz beta 3.8975JackWolfskind wrote: ↑Tuesday 06 March 2018 20:01 Unfortunately Domoticz doesn't start at all , after installation of the new true TCP plugin version. Maybe because I'm already on the Domo beta?
Will there be eventually a new plugin Version also supporting the latest Domo, then I can test reading and writing some TCP_modbus Devices![]()
Have you installed pymodbusTCP correctly ?? (you also need the normal "serial" pymodbus)
Last edited by Domoticx on Tuesday 06 March 2018 20:50, edited 1 time in total.
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!)
- 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!)
- 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: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
1 register by commandbonebuster wrote: ↑Tuesday 06 March 2018 7:06 Hi
Great job
works fine for me with Unitronics V350 PLC
i can read memory intger in TCP mode thanks !
is it possible to read multiple registers with only one command and have them in multiple custom sensors ?
or i have to read 1 register by command ?
thanks
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!)
- 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!)
-
- Posts: 5
- Joined: Wednesday 14 February 2018 9:34
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
Strange, it doesn't work anymore for me after replacing the plugin.py with the new 1.1.0 Version, although the older version was ok 
Before I got the old version working by following the installation manual:
Install for python 3.x with: sudo pip3 install -U six
copy the py file to v3.x python
sudo cp six.py /usr/lib/python3.5
Install for python 3.x with: sudo pip3 install -U pymodbus
Install for python 3.x with: sudo pip3 install -U pymodbusTCP

Before I got the old version working by following the installation manual:
Install for python 3.x with: sudo pip3 install -U six
copy the py file to v3.x python
sudo cp six.py /usr/lib/python3.5
Install for python 3.x with: sudo pip3 install -U pymodbus
Install for python 3.x with: sudo pip3 install -U pymodbusTCP
- 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: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
What does the LOG say?JackWolfskind wrote: ↑Tuesday 06 March 2018 22:01 Strange, it doesn't work anymore for me after replacing the plugin.py with the new 1.1.0 Version, although the older version was ok
Before I got the old version working by following the installation manual:
Install for python 3.x with: sudo pip3 install -U six
copy the py file to v3.x python
sudo cp six.py /usr/lib/python3.5
Install for python 3.x with: sudo pip3 install -U pymodbus
Install for python 3.x with: sudo pip3 install -U pymodbusTCP
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!)
- 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!)
- 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: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
Hi all,
Programmed some more hours on the plugin!
Released READ v1.1.1, notable changes:
- Can also decode STRING 2/4/6/8 bytes (not tested)
- Code cleanup, Fixed widths
- Added timeouts (5 sec)
Released WRITE v1.0.7, notable changes:
- TCP/IP support
- Code cleanup, Fixed widths
NOTE: RTU = HEX, TCP/IP = INT value
TODO: Option wich datatype to send (using stringbuilder)
Overall TODO: To cleanup plugin option space combine IP with port, like: 192.168.1.1:502 (and if only IP, port is 502 by default)
Updated readme, please read!
DL @ https://github.com/DomoticX/domoticz-modbus
Enjoy!
Programmed some more hours on the plugin!

Released READ v1.1.1, notable changes:
- Can also decode STRING 2/4/6/8 bytes (not tested)
- Code cleanup, Fixed widths
- Added timeouts (5 sec)
Released WRITE v1.0.7, notable changes:
- TCP/IP support
- Code cleanup, Fixed widths
NOTE: RTU = HEX, TCP/IP = INT value
TODO: Option wich datatype to send (using stringbuilder)
Overall TODO: To cleanup plugin option space combine IP with port, like: 192.168.1.1:502 (and if only IP, port is 502 by default)
Updated readme, please read!
DL @ https://github.com/DomoticX/domoticz-modbus
Enjoy!
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!)
- 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!)
-
- Posts: 5
- Joined: Wednesday 14 February 2018 9:34
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
Unfortunately I couldn't find out where the log is. So far domoticz pretends to be running but I can't access the domoticz GUI via Browser, as soon as I install the new TCP Modbus. With the old one its running fine.Domoticx wrote: ↑Tuesday 06 March 2018 22:51What does the LOG say?JackWolfskind wrote: ↑Tuesday 06 March 2018 22:01 Strange, it doesn't work anymore for me after replacing the plugin.py with the new 1.1.0 Version, although the older version was ok
Before I got the old version working by following the installation manual:
Install for python 3.x with: sudo pip3 install -U six
copy the py file to v3.x python
sudo cp six.py /usr/lib/python3.5
Install for python 3.x with: sudo pip3 install -U pymodbus
Install for python 3.x with: sudo pip3 install -U pymodbusTCP
Unfortunately it's the same fault with V1.11...
Gonna have find out where Domo hides its logs....
- McMelloW
- Posts: 434
- Joined: Monday 20 November 2017 17:01
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V2024.1
- Location: Harderwijk, NL
- Contact:
Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
I had the same kind of problem. Got on my Rpi with Putty or WinSCP and did the following stepsJackWolfskind wrote: ↑Tuesday 06 March 2018 23:55 Unfortunately I couldn't find out where the log is. So far domoticz pretends to be running but I can't access the domoticz GUI via Browser, as soon as I install the new TCP Modbus. With the old one its running fine.
Unfortunately it's the same fault with V1.11...
Gonna have find out where Domo hides its logs....
stopped domoticz with
Code: Select all
sudo service domoticz stop
Started domoticz again with
Code: Select all
sudo service domoticz start
Perhaps it is a quick and dirty trick, but it worked in my situation.
Greetings McMelloW
- 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: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
@JackWolfskind
New version also requires pymodbusTCP, have you installed it?
Also the plugin is for the stable version atm (not tested on beta)
New version also requires pymodbusTCP, have you installed it?
Also the plugin is for the stable version atm (not tested on beta)
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!)
- 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!)
-
- Posts: 13
- Joined: Saturday 25 November 2017 20:33
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
@Domoticx
Hi write command works fine with Domoticz beta V3.8975 TCP/IP modbus fonction 6 to write 1 register in Unitronics PLC in MI memory
Many thanks !
Hi write command works fine with Domoticz beta V3.8975 TCP/IP modbus fonction 6 to write 1 register in Unitronics PLC in MI memory
Many thanks !
-
- Posts: 229
- Joined: Wednesday 30 April 2014 20:27
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: The Netherlands
- Contact:
Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
@ Domoticx,
After a lot of trial and error I now can use function 6 (write single holding registor). Using the example as described on your website (http://domoticx.com/arduino-modbus-rs485-rtu-slave/), I learned to switch a LED on and off via modbus RS485. Thanks for stimulating my brain.
Jan
After a lot of trial and error I now can use function 6 (write single holding registor). Using the example as described on your website (http://domoticx.com/arduino-modbus-rs485-rtu-slave/), I learned to switch a LED on and off via modbus RS485. Thanks for stimulating my brain.
Jan
Last edited by Jan Jansen on Sunday 11 March 2018 7:52, edited 2 times in total.
- McMelloW
- Posts: 434
- Joined: Monday 20 November 2017 17:01
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V2024.1
- Location: Harderwijk, NL
- Contact:
Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
@ Domoticx
Tried it again with the 06-03-2018 update.
Installed the plugin dicrectorie from github in /home/pi/domoticz/plugins
Restarted Domoticz.
Add a Mobus Read for TCP/IP
As soon as I add the hardware domoticz hangs.
After removed the mudbus pligin directories and restarted Domomticz I received the following errors
The mesaages are different from the previous trial
Tried it again with the 06-03-2018 update.
Installed the plugin dicrectorie from github in /home/pi/domoticz/plugins
Restarted Domoticz.
Add a Mobus Read for TCP/IP
As soon as I add the hardware domoticz hangs.
After removed the mudbus pligin directories and restarted Domomticz I received the following errors
Code: Select all
2018-03-08 16:43:05.691 Error: (Modbus) failed to load 'plugin.py', Python Path used was ':/usr/lib/python35.zip:/usr/lib/python3.5:/usr/lib/python3.5/plat-arm-linux-gnueabihf:/usr/lib/python3.5/lib-dynload'.
2018-03-08 16:43:05.699 Error: (ModbusTCP) Module Import failed, exception: 'ImportError'
2018-03-08 16:43:05.699 Error: (ModbusTCP) Module Import failed: ' Name: plugin'
2018-03-08 16:43:05.699 Error: (ModbusTCP) Error Line details not available.
2018-03-08 16:44:30.971 Error: ModbusTCP hardware (9) thread seems to have ended unexpectedly
2018-03-08 16:45:01.544 Error: ModbusTCP hardware (9) thread seems to have ended unexpectedly
2018-03-08 16:45:30.558 Error: ModbusTCP hardware (9) thread seems to have ended unexpectedly
Greetings McMelloW
-
- Posts: 229
- Joined: Wednesday 30 April 2014 20:27
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: The Netherlands
- Contact:
Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
@Mc Mellow,
Suddenly I could no longer reach Domoticz via the web interface. Today I read viewtopic.php?f=65&t=22339&start=20#p173424.
I followed the instructions and was able to reach Domoticz (Stretch, V3.8976) again. I also can use the write function again.
Suddenly I could no longer reach Domoticz via the web interface. Today I read viewtopic.php?f=65&t=22339&start=20#p173424.
I followed the instructions and was able to reach Domoticz (Stretch, V3.8976) again. I also can use the write function again.
Last edited by Jan Jansen on Sunday 11 March 2018 11:39, edited 2 times in total.
- McMelloW
- Posts: 434
- Joined: Monday 20 November 2017 17:01
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V2024.1
- Location: Harderwijk, NL
- Contact:
Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
@Jan Jansen.Jan Jansen wrote: ↑Saturday 10 March 2018 19:38 @Mc Mellow,
Suddenly I could no longer reach Domoticz via the web interface. Today I read viewtopic.php?f=65&t=22339&start=20#p173424.
I followed the instructions and was able to reach Domoticz (V3.8976) again. I also can use the write function again.
Thanks for your support.
On my system this plugin is a total disaster.
After removing python3.5 the plugins did not show up in the hardware list.
Installing pymodbus pymodbusTCP with pip3 Python 3.5 was installed again. Aaaarghhh
After reboot Modbus plugins showed up in the hardware list.
Adding and activating a modbus-read hardware freese domoticz and has errors in retreiving devices.
Deleting the plugin modbus-xx directories bring Domoticz to live again.
This is not going to work for me.
This are the errors in the log
Code: Select all
2018-03-10 21:15:44.185 Error: (Modbus) failed to load 'plugin.py', Python Path used was ':/usr/lib/python35.zip:/usr/lib/python3.5:/usr/lib/python3.5/plat-arm-linux-gnueabihf:/usr/lib/python3.5/lib-dynload'.
2018-03-10 21:15:44.186 Error: (Modbus read test) Module Import failed, exception: 'ImportError'
2018-03-10 21:15:44.186 Error: (Modbus read test) Module Import failed: ' Name: plugin'
2018-03-10 21:15:44.186 Error: (Modbus read test) Error Line details not available.
2018-03-10 21:15:44.212 Error: (Rpi) 'onStart' failed 'KeyError'.
2018-03-10 21:15:44.212 Error: (Rpi) ----> Line 162 in /home/pi/domoticz/plugins/PiMonitor/plugin.py, function onStart
2018-03-10 21:15:44.212 Error: (Rpi) ----> Line 56 in /home/pi/domoticz/plugins/PiMonitor/plugin.py, function onStart
Greetings McMelloW
-
- Posts: 229
- Joined: Wednesday 30 April 2014 20:27
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: The Netherlands
- Contact:
Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
@Mc Mellow,
I am certainly not an expert, I learn from a lot of trial and error. Perhaps you know a lot more than me, but still. Before Domoticz broke, I had similar problems as you still have. I followed the instructions as described in the WIKI (Using Python plugins, Installing Python on Raspberry Pi with Raspbian). Maybe you have not seen that. At that moment those problems were over.
I am certainly not an expert, I learn from a lot of trial and error. Perhaps you know a lot more than me, but still. Before Domoticz broke, I had similar problems as you still have. I followed the instructions as described in the WIKI (Using Python plugins, Installing Python on Raspberry Pi with Raspbian). Maybe you have not seen that. At that moment those problems were over.
- 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: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
@McMelloW,
Seems like a possible python conflict on your raspbian somewhere
, maybe because you are using a very old (jessie or first stretch) rasbian image? have you installed six (or maybe you can check)?
six was already installed on (latest) stretch but not on some jessie images, maybe you can update to the latest stretch mage? (don't know of there is export/import function in domoticz that could save time)
Seems like a possible python conflict on your raspbian somewhere

six was already installed on (latest) stretch but not on some jessie images, maybe you can update to the latest stretch mage? (don't know of there is export/import function in domoticz that could save time)
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!)
- 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!)
- McMelloW
- Posts: 434
- Joined: Monday 20 November 2017 17:01
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V2024.1
- Location: Harderwijk, NL
- Contact:
Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
Thanks for your reaction.Domoticx wrote: ↑Sunday 11 March 2018 13:41 @McMelloW,
Seems like a possible python conflict on your raspbian somewhere, maybe because you are using a very old (jessie or first stretch) rasbian image? have you installed six (or maybe you can check)?
six was already installed on (latest) stretch but not on some jessie images, maybe you can update to the latest stretch mage? (don't know of there is export/import function in domoticz that could save time)
Two python plugins are running fine. PiMonitor and Disc-usage.
So I did compgen -c python and removed python3.5
After that no modbus plugins were in the hardware list.
I tried to install six but pip3 was gone.
Installing pip3 caused an automatic install of python3.5 again. Back to square 1
Code: Select all
compgen -c python ==> shows now the following python installed
python3.5m
python3.4m
python
python2-config
python3m
python3
python2.7
python3.5
python2.7-config
python3.4
python-config
python2
lsb_release -a ==> shows the following version.
No LSB modules are available.
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 9.3 (stretch)
Release: 9.3
Codename: stretch
Greetings McMelloW
- 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: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
@McMelloW,
So.... have you installed six too?... after pip3 installed 3.5 again? (just to be sure)
My environment:
-------------------------
-------------------------
Seems i don't have Python 3.4 installed, only Python 2.7 and 3.5 (and more -config listings)...
Maybe you can try to remove the 3.4 version (instead of 3.5)
So.... have you installed six too?... after pip3 installed 3.5 again? (just to be sure)
My environment:
Code: Select all
compgen -c python
Code: Select all
python3.5m-config
python3.5m
python
python2-config
python3m
python3-config
python3
python2.7
python3.5
python3m-config
python3.5-config
python2.7-config
python-config
python2
Code: Select all
lsb_release -a
Code: Select all
No LSB modules are available.
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 9.3 (stretch)
Release: 9.3
Codename: stretch
Seems i don't have Python 3.4 installed, only Python 2.7 and 3.5 (and more -config listings)...

Maybe you can try to remove the 3.4 version (instead of 3.5)

Last edited by Domoticx on Monday 12 March 2018 6:47, edited 2 times in total.
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!)
- 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!)
- 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: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
Updated OP!! with lots off goodies and links on Modbus to test stuff out!
http://www.domoticz.com/forum/viewtopic ... 65&t=21297
You can even install modbus SLAVE on a ESP8266 Wireless!: http://domoticx.com/esp8266-wifi-modbus-tcp-ip-slave/

You can even install modbus SLAVE on a ESP8266 Wireless!: http://domoticx.com/esp8266-wifi-modbus-tcp-ip-slave/
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!)
- 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!)
Who is online
Users browsing this forum: No registered users and 1 guest