UART Communication Between two Microcontrollers

vv
This content provide you Experience

Using UART (Universal Asynchronous Receiver/Transmitter) communication, two microcontrollers may communicate serially. It is a cheap and effective communication protocol since it enables data transfer between two devices utilising just two cables. UART communication between two microcontrollers has a number of advantages, including:

Simpleness: The UART communication protocol is a straightforward and easy to build one. It is a simple choice for communication between microcontrollers since it only needs two wires to connect the components.

Low cost: UART communication between two microcontrollers is a cost-effective solution since it just needs a few hardware components.

Flexibility: A broad variety of data formats, including text, numbers, and binary data, may be sent through UART communication. Additionally, it is a flexible protocol that works with a range of microcontrollers.

Efficiency: This communication employs a minimal amount of bits for each data transmission, making it an efficient means of data transport. This makes it a fantastic choice for data transfer over greater distances or at faster rates.

This communication has a built-in error checking system, making it a dependable mode of communication. This makes it possible to guarantee accurate and error-free data delivery.

Component Requried

You need two Microcontroller Either Arduino or Either esp32 and Two jumper wire only.

For esp – https://elconics.com/getting-started-withesp32/

Connections

For Arduino – Connect TX to Rx and Rx to Tx

Simmilarly to Esp32

Code for sender

Simply Write Serial.print function in sender controller with specific Baud Rate .

int counter =0;

void setup() {
  Serial.begin(9600);
  
  
}

void loop() {
 Serial.println("This is sender");
 delay(500);

counter++;

Serial.println(counter);
delay(1000);

}

Code for Reciver

#define RXp2 0               // change pin no. for different microcontroller 
#define TXp2 1
void setup() {
 
  Serial.begin(115200);
  Serial2.begin(9600, SERIAL_8N1, RXp2, TXp2);
}
void loop() {
    Serial.println("Message Received at esp32 :  ");
   Serial.println(Serial2.readString());
} 

Open Serial monitor in reciver side and You will notice that sender message and a counter number.

Follow this Youtube video —https://www.youtube.com/watch?v=TGusjcKSNIU

In general, UART communication is a straightforward, affordable, and dependable method of data transmission between two microcontrollers. It is a flexible communication protocol that is supported by many devices and microcontrollers and may be utilised in a variety of applications.

Leave a Comment

Your email address will not be published. Required fields are marked *

Related post