Rs485 Serial communication protocol
Rs485 transmits two differential signals on two different wires, named A and B lines. Since signals are opposite in polarity(90 Degree out of Phase) they can travel to pretty far distance. Transmitted signals are opposite in polarity and any external induced signal during travel can easily be filtered at the output.
Microcontrollers them self can not output rs485 signal caring data. Rather an external device/module is required to be interfaced with microcontroller for achieving rs485 communication. Max485 is popular rs485 transceiver which can be interfaced with any microcontroller for rs485 communication. Microcontroller sends data to max485. Then max485 sends the data out on rs485 lines.
Max485 Pin out and pin description
- DI (Data In) Data on DI pin is transmitted on A & B lines when the module is in transmit mode. To set module in transmit mode make DE=1 and RE=1. DI pin is connected to Tx pin of Host Microcontroller UART.
- RE (Receive Enable) RE pin is Used to configure the module in Receive Mode.
- DE (Data Enable) DE pin is Used to Configure the module in Transmit Mode
- RO (Receive Out) Data Received on A & B pin is given to RO pin. RO pin is connected to Rx pin of microcontroller.
- A & B (Differential Input and Output Pins) Data is transmitted and received on A & B lines.
RS485 Communication between Arduino Mega and Arduino Pro Mini
I use cheap arduino rs485 module in the project. I bought them online from aliexpress. Single arduino rs485 module cost me around $2.3. Pre assembled arduino rs485 modules reduces time of making max485 circuit on bread board and all the other messy wiring stuff. Circuit diagram of the project is below.
Note the function Serial.readString() didn’t worked in Rs485 Communication because the Serial buffer didn’t receive the terminating character. Its because the biasing and terminating resistors they are not calibrated to the impedence of the wire. That’s why i have used the statemnet while(Serial1.available() && getdata!=’d’). Which means if data is available in buffer and its not equal to ‘d’ then read the data. In the while fuction i am reading data one by one character from buffer. Serial.readString() works perfectively in Rs232 communication.
Arduino Mega serial rs485 communication code
Arduino Pro Mini serial rs485 communication code
Watch The Project Video Here
Filed Under: Arduino Projects, Microcontroller Projects
Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.