yaacov / ArduinoModbusSlave

Modbus slave library for Arduino
ISC License
204 stars 74 forks source link

Not working with I2C communication #75

Open akshulg opened 3 years ago

akshulg commented 3 years ago

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?

yaacov commented 3 years ago

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.

akshulg commented 3 years ago

@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?

yaacov commented 3 years ago

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

akshulg commented 3 years ago

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

falahati commented 3 years ago

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

akshulg commented 3 years ago

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 commented 3 years ago

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

Apulanta commented 3 years ago

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 (notifications@github.com) 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 .

akshulg commented 3 years ago

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