Showing posts with label SoftwareSerial. Show all posts
Showing posts with label SoftwareSerial. Show all posts

2017/12/07

ESP8266 Software Serial Loopback Test

This is a quick summary of testing the software serial function on a single ESP8266 in loopback mode.

Schematic

For this post, GPIO14 and GPIO12 are used as the RX and TX respectively for Software Serial.

Note,
For ESP8266, GPIO 0 ~ 5, 12 ~ 15 can be used for RX / TX, GPIO 16 cannot be used for RX / TX.



2016/06/07

Simple wireless instant messenger using Arduino + HC-11

This is a quick summary of a simple wireless instant messenger using Arduino + HC-11.

Wiring - Sender (Arduino Uno)




Wiring - Receiver (Arduino Nano)



Code - Sender

#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3); //RX, TX

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

void loop() {


  if (Serial.available() > 0){             //Read from serial monitor and send over HC-11
    String input = Serial.readString();
    mySerial.println(input);  
  }

  if(mySerial.available() > 1){        //Read from HC-11 and send to serial monitor
    String input = mySerial.readString();
    Serial.println(input);  
  }
  delay(5);
}

Code - Receiver

#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3); //RX, TX

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

void loop() {


  if (Serial.available() > 0){             //Read from serial monitor and send over HC-11
    String input = Serial.readString();
    mySerial.println(input);  
  }

  if(mySerial.available() > 1){        //Read from HC-11 and send to serial monitor
    String input = mySerial.readString();
    Serial.println(input);  
  }
  delay(5);
}

Reference

Long range, 1.8km, Arduino to Arduino wireless communication with the HC-12
https://www.youtube.com/watch?v=DGRPqeacJns