ArduinoModbusSlave icon indicating copy to clipboard operation
ArduinoModbusSlave copied to clipboard

Not working with I2C communication

Open akshulg opened this issue 4 years ago • 9 comments

I had successfully implemented this library with Arduino as an I2c slave. So one arduino modbus slave + I2c slave works. But right now I have interfaced a I2C sensor with arduino, and modbus is not working, not able to scan registry on a modbus master end. Arduino modbus slave + I2C master won't work. I have tried with some flags but still not working. Any ideas on what might be the issue?

akshulg avatar Mar 01 '21 06:03 akshulg

Hi, thank you for the issue.

Both I2C and Modbus are buses that solve the problem of master/slaves communication, so when using the same line you will have two masters, one for I2C and one for Modbus, My guess guess is that they want to talk/recive the same time and interfere.

yaacov avatar Mar 01 '21 06:03 yaacov

@yaacov yes that's what I observe, that both are trying to communicate and hence there is conflict. Is there any way to implement both things?

I am trying external interrupt right now. So I have connected the INT1 (pin 3) of arduino to RX of arduino. RX pin is connected to TTL to RS485 converter pin. So when arduino receive the request from a modbus master then interrupt should trigger and sensor (which is on I2C) data should poll. But what I observe is that the RX pin is always on. Any idea on this method?

akshulg avatar Mar 01 '21 08:03 akshulg

Is there any way to implement both things?

I don't think so, even if you can shut down one server, it's clients will continue to interfere with the other bus communication

yaacov avatar Mar 01 '21 08:03 yaacov

@yaacov Do you have any other idea that I can try and implement?

akshulg avatar Mar 01 '21 11:03 akshulg

use a virtual serial library for the Modbus's line if you can afford one set of additional wires. (e.g. AltSoftSerial)

falahati avatar Mar 01 '21 13:03 falahati

I am already using AltSoftSerial for debugging and programming purpose. Programming of slave id, baud rate and other parameters. But can interchange Serial and AtlSoftSerial purpose. Will try that.

akshulg avatar Mar 01 '21 14:03 akshulg

@falahati It's not working with AltSoftSerial as well. I am stuck now with no ideas!

akshulg avatar Mar 02 '21 07:03 akshulg

I have used a working solution Arduino Nano Modbus TX (0), 1 / RX (1), and the I2C bus A4 (13) of the SDA, A5, (14), SCL

ti 2. maalisk. 2021 klo 9.14 Akshul Goyal ([email protected]) kirjoitti:

@falahati https://github.com/falahati It's not working with AltSoftSerial as well. I am stuck now with no ideas!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/yaacov/ArduinoModbusSlave/issues/75#issuecomment-788676164, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJBO6U73S3X5F7FEAPNEKZDTBSF5XANCNFSM4YL7PSWQ .

Apulanta avatar Mar 02 '21 16:03 Apulanta

@Apulanta That's the same configuration I am using with Arduino UNO. But it's not working.

akshulg avatar Mar 03 '21 06:03 akshulg