Post topics, source code that relate to the Arduino Platform

User avatar
By Franco Picarelli
#26079 Hello there!

I've been trying to connect a ESP8266-01 to Arduino UNO, but I can't get them to communicate trought this simple sketch:

Code: Select all#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.
Last edited by Franco Picarelli on Sun Aug 16, 2015 8:52 am, edited 1 time in total.
User avatar
By tytower
#26144 That runs OK on my Linux machine 32 bit and an ESP-12 chip separately with an LED on Pin 13 but the LED does not light because it has to be taken low to light for me .
Serial terminal to the ESP showed AT repeatedly and the blue LED lit each time it was sent.

Changing its start state to High and the write to /1 ....divide by 1 did it ok for me for a quick test
digitalWrite(LED_PIN,LOW);
digitalWrite(LED_PIN,found_OK/1);
I left the setup writes as were and that worked OK too

Now a far as doing it through an arduino I think you have to have TX to TX and RX to RX between Arduino and ESP but I guess you have that sorted if the code is being loaded to the ESP. I think you are probably trying to light pin 13 on the Arduino so how will the ESP know the Arduino pin numbers? You could put an led on GPIO2 for a test