Hello!
I am new to OpenHab and ModBus. I have OH2.3 and installed latest ModBus add-on version. I have clean OH install. I want to connect my arduino UNO with OH. I did all the ModBus settings in Paper UI and it works with mod_RSsim simulator. But when I try to connect to arduino I have errors. Arduino is set using Modbus-Master-Slave-for-Arduino library with simple slave example:
/**
* Modbus slave example 1:
* The purpose of this example is to link a data array
* from the Arduino to an external device.
*
* Recommended Modbus Master: QModbus
* http://qmodbus.sourceforge.net/
*/
#include <ModbusRtu.h>
// data array for modbus network sharing
uint16_t au16data[16] = {
3, 1415, 9265, 4, 2, 7182, 28182, 8, 0, 0, 0, 0, 0, 0, 1, -1 };
/**
* Modbus object declaration
* u8id : node id = 0 for master, = 1..247 for slave
* u8serno : serial port (use 0 for Serial)
* u8txenpin : 0 for RS-232 and USB-FTDI
* or any pin number > 1 for RS-485
*/
Modbus slave(1,0,0); // this is slave @1 and RS-232 or USB-FTDI
void setup() {
slave.begin( 9600 ); // baud-rate at 9600
}
void loop() {
slave.poll( au16data, 16 );
}
In Paper UI I set a Modbus serial slave, Regular poll that is bridged to slave and modbus data that is bridget to poll. This setup works well with simulator. But I can not connect to my arduino bord.
Here is my openhab.log:
2018-07-28 12:20:13.572 [INFO ] [er.internal.HomeBuilderDashboardTile] - Started Home Builder at /homebuilder
2018-07-28 12:20:14.896 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at http://192.168.0.127:8090
2018-07-28 12:20:14.897 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at https://192.168.0.127:8443
2018-07-28 12:20:16.632 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'home.items'
2018-07-28 12:20:17.217 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'home.rules'
2018-07-28 12:20:17.226 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'home.rules' is either empty or cannot be parsed correctly!
2018-07-28 12:20:17.272 [INFO ] [thome.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007
2018-07-28 12:20:17.423 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'home.sitemap'
2018-07-28 12:20:17.922 [INFO ] [basic.internal.servlet.WebAppServlet] - Started Basic UI at /basicui/app
2018-07-28 12:20:17.951 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui
2018-07-28 12:20:17.975 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel
2018-07-28 12:20:17.987 [INFO ] [sysfs.internal.SysfsUsbSerialScanner] - Cannot perform scans with this configuration: sysfsTtyDevicesDirectory: /sys/class/tty, devDirectory: /dev
2018-07-28 12:20:17.991 [INFO ] [sfs.internal.PollingUsbSerialScanner] - Do not start background scanning, as the configured USB-Serial scanner cannot perform scans on this system
2018-07-28 12:20:17.992 [INFO ] [sfs.internal.PollingUsbSerialScanner] - Do not start background scanning, as the configured USB-Serial scanner cannot perform scans on this system
2018-07-28 12:20:18.010 [INFO ] [rt.modbus.internal.ModbusManagerImpl] - Modbus manager activated
2018-07-28 12:20:18.022 [INFO ] [modbus.internal.ModbusHandlerFactory] - Setting manager: org.openhab.io.transport.modbus.internal.ModbusManagerImpl@322920b9
2018-07-28 12:20:20.197 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 01 02 00 00 00 04 79 c9
2018-07-28 12:20:20.197 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: Error reading response (EOF)
2018-07-28 12:20:20.202 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 1/1 error: I/O exception: IOException Error reading response (EOF). Request: net.wimpi.modbus.msg.ReadInputDiscretesRequest@2b36d1f (unit id 1 & transaction 1). Serial parameters: SerialParameters@7272913e[portName=COM3,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=1500]
2018-07-28 12:20:20.203 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute reached max tries 1, throwing last error: I/O exception: IOException Error reading response (EOF). Request: net.wimpi.modbus.msg.ReadInputDiscretesRequest@2b36d1f (unit id 1 & transaction 1). Serial parameters: SerialParameters@7272913e[portName=COM3,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=1500]
2018-07-28 12:20:20.203 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 1 out of 3 failed when executing request (ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@4869194a[slaveId=1,functionCode=READ_INPUT_DISCRETES,start=0,length=4,maxTries=3]). Will try again soon. Error was I/O error, so reseting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O exception: IOException Error reading response (EOF) [operation ID 3c517d51-d9a3-40f3-b113-294f1f980048]
2018-07-28 12:20:21.746 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 01 02 00 00 00 04 79 c9
2018-07-28 12:20:21.746 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: Error reading response (EOF)
2018-07-28 12:20:21.747 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 1/1 error: I/O exception: IOException Error reading response (EOF). Request: net.wimpi.modbus.msg.ReadInputDiscretesRequest@4af92f2e (unit id 1 & transaction 2). Serial parameters: SerialParameters@7272913e[portName=COM3,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=1500]
2018-07-28 12:20:21.747 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute reached max tries 1, throwing last error: I/O exception: IOException Error reading response (EOF). Request: net.wimpi.modbus.msg.ReadInputDiscretesRequest@4af92f2e (unit id 1 & transaction 2). Serial parameters: SerialParameters@7272913e[portName=COM3,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=1500]
2018-07-28 12:20:21.747 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 1 out of 3 failed when executing request (ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@4869194a[slaveId=1,functionCode=READ_INPUT_DISCRETES,start=0,length=4,maxTries=3]). Will try again soon. Error was I/O error, so reseting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O exception: IOException Error reading response (EOF) [operation ID 61d5810f-e3cb-48c9-a548-42631eaf3f9d]
Can you please help? Where is the problem? Maybe i should use different arduino library? During this process my arduino blinks all the time.
Thank you!
UPDATE:when using mod_RSsim ModBus simulator it is not possible to write data into holding register using my setup. Why is it so?