RS485 Master and Slave using Modbus

Submitted by Mike Dale on Fri, 10/09/2020 - 01:54

I am trying to find a simple example of using Modbus to link several Arduino Boards, simply sending digital and analogue signals from the Master to each Slave.  Modbus seems overkill but the application involves large distances outdoor lighting.  I have worked through the tutorials:

Long Distance Wired Serial Communication with Arduino using RS485 and CAT Cables

I have made this work but this only works for one Slave

RS-485 MODBUS Serial Communication using Arduino UNO as Slave

RS-485 MODBUS Serial Communication with Arduino as Master

Both of these involve a link to a computer and I can't work out how to adapt them to Arduino to Arduino.

Any assistance will be gratefully received

 

PS.  The tutorials are very good with full detail.

Mike

You can google for long-distance serial communication between two or more Arduino boards, I think it will redirect you to the sollution that you are looking for.

  Joined December 02, 2019      117
Monday at 10:02 PM

Hi Debashis

i appreciate your response.  I have tried this and all the responses I can find illustrate for two only.  I do not understand how to do this for more than one slave.  Any ideas?

regards

mike

  Joined October 09, 2020      3
Friday at 01:34 AM

Use two RS485 module in two different arduinos. Make one slave and other one as master. It will work.

  Joined February 12, 2018      696
Monday at 02:11 PM

Hi Sourav

i appreciate your response.  I agree it works for master and one slave but I do not understand how to do this for more than one slave.  Any ideas?

regards

Mike

  Joined October 09, 2020      3
Friday at 01:34 AM

For multiple slaves, you need slave adresses unique for each slaves and by using the slave address you could communicate with each of them one by one. Hope this help.

  Joined February 12, 2018      696
Monday at 02:11 PM

Hi Sourav
Thanks for the response. I am sure you are correct. The trouble is I do not know how to code that!

Regards
Mike.

  Joined October 09, 2020      3
Friday at 01:34 AM