Arduino to Node Communication

by ArjunG32 in Circuits > Arduino

936 Views, 1 Favorites, 0 Comments

Arduino to Node Communication

IMG_20190710_224807.jpg
IMG_20190710_224711.jpg
IMG_20190710_224731.jpg

This instructable is purely for just for a very basic demonstration of how to send and receive data via UART (Serial) between two Arduino compatible boards.

Supplies

Arduino Uno

Node MCU/Arduino Uno/Nano or pretty much any other board with serial capabilities

Make the Connections

IMG_20190710_224807.jpg

We are using the Arduino Uno for this example, it will be transmitting the message, 0 and 1 are the serial ports for this board

In serial communication, The TX of one board goes into the RX of the other and vice versa.

The connections are very trivial and can be seen in the picture

The Code for the Transmitting Device

//arduino code
void setup() {   // put your setup code here, to run once:   
Serial.begin(9600);   
}
void loop() {   // put your main code here, to run repeatedly: 
Serial.println("It is sending"); 
delay(1000); }

Code for the Receiving Device

IMG_20190710_224807.jpg
//node mcu code
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  
}
void loop() {
  // put your main code here, to run repeatedly:
if(Serial.available())
{
  char a=Serial.read();
  Serial.print(a);
  if(a=='\n')//meaning it is the next line
  {
    Serial.println();
    }
  }
}