Communication Between Two Arduino Using UART
by samiobi in Circuits > Arduino
8635 Views, 0 Favorites, 0 Comments
Communication Between Two Arduino Using UART
The purpose of this project is to make two Arduino Uno devices talk to each other using UART (universal asynchronous receiver-transmitter) communication. This project is useful because it provides a simple solution for engineers to make wired communication to exchange commands with less cables between the devices within a controlled environment.
Supplies
- Two Arduino UNO
- Two LEDs
- Four 1K ohm resistors
- Two push buttons
- Two bread boards
- M/M links
Block Diagram
Initially connect the circuits as in the diagram , the project mainly to connect both Arduinos through UART TX (transmitter) & RX (receiver ), its important to remember that TX in the Arduino number one shall be connected to RX in the second Arduino, in this way when one unit sends the second one will listen and vise versa.
Fabrication Steps
1.First step fit the button with the 1k ohm resistor and the LED with its 1k ohm resistor (as in photos1-3).
2. Second step connect the button and LED to the Arduino and voltage outputs (as in the photos 3-5).
3. Third step make the second Arduino similar to the previous steps then connect them through UART TX and RX (as in the photos 7-8)
4. Fourth step connect power to both devices, because the project uses Vin pin the voltage input is greater than 6V.
The connection map (both Arduino have the same inputs/outputs)
- Arduino one Tx to Arduino two Rx
- Arduino one Rx to Arduino two Tx
- Both Arduinos pin 7 to switch
- Both Arduinos pin 8 to LED
Concept of Operation
When the user pushes the button in first Arduino it sends a command through serial communication UART and once this command received by the second unit it turns on its LED, similarly when the second Arduino pushes the button the first Arduino turns on its LED. In this way both units act as Transceivers when one sends the other one listens and vice versa. However the system can be expanded to host multiple commands based on the design of the circuit, at the end each message should be mapped to the desired function.
Coding
The software coding of the Arduino is done through Arduino IDE program, to download the software visit the website in this link https://www.arduino.cc/en/software. The code is the same for both Arduinos. The code starts by the variables for input, output and message format. Then in the initialization stage the serial UART communication begins (the speed of the link is 9600 bps), also the inputs and outputs are defined in the setup section of the code. Next the void loop function starts by setting the LED to low , after that if the serial is available then read the incoming message , if the message contains the character 1 then turn on the led. The second if statement for the pushes button that will send a message contain the character 1 through the serial communication. As both of the Arduino has the same code they will interact to the command in the same manner The code file contains comments that explains each line.
Downloads
The Result
Finally all the project elements has been connected, and after loading the codes to the Arduinos the project is ready to operate. Start by pushing the button in Arduino one and notice the green LED turns ON as in the figure -6. likewise when the second button is pressed the red LED turns ON as in the photos.
This project is very useful to remotely control any Arduino or Microcontroller also it can be used to monitor data using UART serial communication.
Hope you find this topic useful and implemented in your daily life, if you face any dificullty please do not hesistae to send your enquires and visit my website to read about more topics.