This project was developed in partnership with Robô Lúdico School and JLCPCB Factory that offers 5 free PCBs of Arduino Compatible Board.

I want to teach you how to communicate with 3 Arduino boards or up to 32 on a communication network. This process is possible thanks to the use of the RS-485 physical layer.

This physical medium is built through the MAX485 integrated circuit, which is responsible for converting the Arduino TTL serial signal to the RS-485 physical medium signal.

What project will you develop?

The project consists of 3 Arduino's. We have an Arduino UNO, a Nano, and a MEGA. The Arduino UNO will control the other 2 and send commands to receive the reading of the analog signal from the potentiometer connected to each Arduino.

He will receive the signal and present it on the LCD screen.

This communication will be developed through the use of RS-485 modules. See the circuit below.

The MAX485 can transmit this data over a distance of 1200 m, in addition, it has high immunity to electromagnetic interference. This is one of the reasons why it is widely used by industrial devices, such as programmable logic controllers.

To make this communication we use the Arduino MAX485 module. This module will allow us to interconnect the devices and carry out our communication. See the photo of the module.

The board presents the complete circuit for you to transfer and receive data between the boards. The connecting pins are quite easy for you to learn.

Observe the figure and see that it is formed by 8 pins: DI, DE, RE,R0,VCC, A, B, and GND.

Shall we understand the function of each of them?

Pins DI and R0 are used to transmit data (DI - Data Input) and receive data (RO - Received Output). Connect the TX pin to the DI and the RX to the RO.

The configuration of the data transfer or reception mode is done through the DE and RE pins. The first thing you must do is connect the pins with a jumper.

Then, you must apply 5V to put the circuit in transfer mode and 0V to receive data. See the circuit in the figure and analyze the connection on the DE and RE pins.

In addition to these pins, we have VCC, A, B, and GND. The VCC and GND are used to supply the module circuit, while A and B will be responsible for transmitting information from one module to another with RS-485 voltage levels.

All pins of Letter A must connect to each other. This rule also applies to B.

Now you will learn the programming logic and the complete circuit for this project.

For this project, we'll use the JLCPCB Arduino Compatible printed circuit board presented below.

You can obtain the Arduino JLCPCB compatible PCB for your projects for $2 in your first order with the link: Earn my PCBs Arduino Compatible.

Use the JLC-RECE coupon,earn a $2 off discount, and earn FREE5 PCBs.

Access the link and download the Gerber files of the JLCPCB Arduino Compatible Printed Circuit Board.

The project control logic

The logic is divided into two parts. We have the control logic of the Arduino Master and that of the slave Arduino's.

What is a master and slaves?

The master Arduino is responsible for the communication control, that is, only he can initiate communication with the slaves. In our project, Arduino UNO is the master of this communication.

Slave Arduino's only obey commands sent by the master. Arduino NANO and MEGA are Arduino's slaves.

See the figure below. We present 2 potentiometers. Each one is connected to each slave.

Now, see the code of the master Arduino.

#include <LiquidCrystal_I2C.h> //Biblioteca I2C do LCD 16x2LiquidCrystal_I2C lcd(0x27,16,2); // Configurando o endereco do LCD 16x2 para 0x27int value1 = 0, value2 = 0;const int LED = 13; const int Enable = 2;void setup() { Serial.begin(9600); Serial.setTimeout(250); pinMode(LED, OUTPUT); pinMode(Enable, OUTPUT); digitalWrite(LED, LOW); digitalWrite(Enable, HIGH); lcd.init(); lcd.backlight();} void loop() { Serial.print("I");...
Read more »