smarmengol / Modbus-Master-Slave-for-Arduino

Modbus Master-Slave library for Arduino
GNU Lesser General Public License v2.1
473 stars 328 forks source link

Modbus-Master-Slave-for-Arduino library with OpenHab 2 - Modbus binding 2.3 #39

Closed ViktorLi closed 6 years ago

ViktorLi commented 6 years ago

Modbus-Master-Slave-for-Arduino works fine with Modbus Master simulators, but when I try to connect my arduino UNO using serial to OpenHab Modbus binding 2.3 it throws connection timeout error. When trying to connect my arduino uno blue led blinks periodically. I use simple slave example code for my arduino sketch. Maybe you know about this issue? I still can not figure out where is the problem. I can connect my openhab modbus master to modbus slave simulator and everything works great aswell.

Thank you for your great work!

ViktorLi commented 6 years ago

UPDATE: I installed my setup on Ubuntu and everything works now. I can read and write registers to arduino as a slave. I do not know what was the problem with windows. It was suggested that it was a timing issue.

For anyone trying to use OpenHab modbus binding on ubuntu it is necessary to give openhab permision to use serial:

Add openhab to some groups:

sudo adduser openhab dialout sudo adduser openhab tty # ?

You need to edit openhab2 file aswell: sudo nano /etc/default/openhab2 EXTRA_JAVA_OPTS="-Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0:/dev/ttyS0:/dev/ttyS2:/dev/ttyACM0:/dev/ttyAMA0"

I did all the OpenHab bindings using paper UI which is pretty simple step. Arduino sketch and library was the same.

Thank you!