I am trying to get my Arduino and ESP8266 to talk to each other. I am trying to send a message from my Arduino to tell my ESP to light an LED, and also get my ESP to tell the Arduino to light an LED.
My Arduino Code:
String message;
void setup() {
Serial.begin(115200);
}
void loop() {
// wait for available serial
if(Serial.available() > 0) {
message = Serial.readStringUntil('\n'); // read until end of line
if (message.equals("led on\n") || message.equals("led on")) {
digitalWrite(13, HIGH);
}
Serial.println("esp led on");
}
}
My ESP Code:
#include <ESP8266WiFi.h>
String message;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
}
void loop() {
if(Serial.available() > 0) {
message = Serial.readStringUntil('\n');
if (message.equals("esp led on\n") || message.equals("esp led on")) {
digitalWrite(2, HIGH);
}
Serial.println("led on");
}
}
My Setup: (Note: Fritzing didn't have a 1.8k resistor. I am getting 3.4V for my RX on my ESP)
Only my Arduino LED lights up, and its TX led is blinking extremely fast. My best guess is that the Serial never becomes available for the ESP, and I'm not sure how I would tackle that.