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
No comments:
Post a Comment