I've been trying to connect a ESP8266-01 to Arduino UNO, but I can't get them to communicate trought this simple sketch:
#define LED_PIN 13
bool found_OK = 0;
void setup() {
Serial.begin(115200);
delay(200);
Serial.setTimeout(1000);
delay(200);
pinMode(LED_PIN,OUTPUT);
// Testing the LED
digitalWrite(LED_PIN,HIGH);
delay(300);
digitalWrite(LED_PIN,LOW);
delay(300);
digitalWrite(LED_PIN,HIGH);
delay(300);
digitalWrite(LED_PIN,LOW);
delay(300);
}
void loop() {
// LED is OFF
digitalWrite(LED_PIN,LOW);
delay(200);
// Sends the AT Command
Serial.print("AT\r\n");
// Looks for the answer
found_OK = Serial.find("OK");
// If "OK" is found, lights up the LED
digitalWrite(LED_PIN,found_OK);
delay(1000);
}
The LED on pin 13 doesn't light up during the loop, neither does the blue LED on the ESP.
I tested the hardware setup using the BareMinimun example and Serial Monitor, so i guess the problem is the code itself.
Can someone help me? I have a feeling I'm missing some little detail...
Thank You!
Franco
EDITED:
For some reason, using the serial port on Arduino Uno (pins 0 and 1) to talk to the ESP does not work on Sketchs.
So I just used the SoftwareSerial function on pins 10 and 11 and it started working right away.
Thinking it through, this might be a known fact, since lots of Libs actually use SoftwareSerial to talk to the ESP, but took me forever to figure it out.