2
votes

I'm using an Arduino Uno Rev3 with ESP8266 to connect into a network and send some data through TCP sockets. I'm using the following code to establish a connection

boolean connectWifi() {
  String cmd =  "AT+CWJAP=\"";
         cmd += SSID;
         cmd += "\",\"";
         cmd += PASS;
         cmd += "\"";
  Serial.flush();
  Serial.println(cmd);
  delay(5000);
  if(Serial.find("OK")) {
    Serial.println("Connected");
    return true;
  } else {
    Serial.println("Not connected");
    return false;
  }
}

but everytime I call this function inside the arduino loop(), I receive "Not connected".

I have already tried to connect direct from serial monitor running an empty code on Arduino and this AT command worked very well. Someone have any idea about what is wrong?

Connections:

(Used when I need to send commands right from arduino code)
Arduino ------------ ESP8266
3.3v --------------------- vcc
gnd ---------------------- gnd
3.3v ------------------- CH_PD
TX ------------------------ RX
RX ------------------------ TX

(Used when I need to send commands right from arduino serial monitor)
Arduino ------------ ESP8266
3.3v --------------------- vcc
gnd ---------------------- gnd
3.3v ------------------- CH_PD
TX ------------------------ TX
RX ------------------------ RX

3
I'm having the same issue. Did you figure it out?jaimers
@user3232194 sometimes it works, sometimes not. Arduino Uno Rev3 wasn't designed to provide as much current as ESP8266 needs... I'm thinking that this is making the ESP8266 to be unstable.Leandro

3 Answers

2
votes

I just uploaded blank.bin into ESP and everything worked fine. There was some example code in conflict with Arduíno.

0
votes

You will need more power to make it work properly. Maybe this will help:

http://makezine.com/2015/04/01/installing-building-arduino-sketch-5-microcontroller/

(check out the: build a voltage divider out of resistors, from the article)

0
votes

i also have the same problem, try the code below maybe it works (the esp should be connected to arduino's pins except rx and tx , i use pin number 7 and pin number 8)

#include <SoftwareSerial.h>

SoftwareSerial esp(7, 8);// TX, RX

void setup()
{
esp.begin(115200);

Serial.begin(9600);
}

void loop()
{
//put your code here
}