I want to communicate between Arduino Uno R3 and Esp8266 Esp-01. in this case, I want to communicate or want to send a data (string using serial software) from esp8266 esp-01 to arduino uno.
the problem is, how to insert RX and TX pins in softwareserial settings, I have tried using the sample code that has been provided, but it can't.
my code as below
FOR ESP8266 ESP-01
#include <SoftwareSerial.h>
SoftwareSerial mhaUno(12, 12, false, 256);
void setup() {
Serial.begin(9600);
pinMode(0, OUTPUT);
}
void loop() {
Serial.write("hello from esp");
delay(1000);
String IncomingString = "";
boolean StringReady = false;
while(mhaUno.available()){
IncomingString = mhaUno.readString();
StringReady = true;
}
if(StringReady) {
if(IncomingString == "hello from uno") {
digitalWrite(0, HIGH);
} else {
digitalWrite(0, LOW);
}
}
}
FOR ARDUINO UNO R3
#include <SoftwareSerial.h>
SoftwareSerial esp8266(2,3); //RX, TX
void setup() {
Serial.begin(9600);
pinMode(13, OUTPUT);
}
void loop() {
Serial.write("hello from uno");
delay(1000);
String IncomingString = "";
boolean StringReady = false;
while(esp8266.available()){
IncomingString = esp8266.readString();
StringReady = true;
}
if(StringReady) {
if(IncomingString == "hello from esp") {
digitalWrite(13, HIGH);
} else {
digitalWrite(13, LOW);
}
}
}
can you help me find a problem in my case?
thank you ^_^