Can't connect to ESP8266

I'm working with an Arduino UNO and an ESP8266.

I have the following code:

//Debut WIFI
#include<stdlib.h>
#include <SoftwareSerial.h>
#include <OneWire.h>
#define SSID "#####" //SSID DE WIFI
#define PASS "#####"  // Mode de passe Wifi

#define IP "#######" // thingspeak.com
SoftwareSerial esp82(6, 7); // RX, TX
boolean connect;
//Fin WIFI

void loop() {
  
}

void setup() {
  Serial.begin(9600);
  
  //Wifi
  esp82.begin(115200);
  //esp82.begin(9600);
  connect = false;
  sendDebug("AT+RST");
  delay(5000);
  
  while (!connect)
  {
   sendDebug("AT");
   delay(1000);
   if (esp82.find("OK"))
      { 
        Serial.println("ESP : OK");
        sendDebug("AT+CWMODE=1");
        delay(5000);
        if (connectWiFi())
        {
          Serial.println("Wifi : OK");
          connect = true;
        }
      }
     else
      {
         Serial.println("ESP : NOT OK");
      }
  
   
   }
//Wifi

}
//WIFI


void sendDebug(String cmd){
  Serial.print("SEND: ");
  Serial.println(cmd);
  esp82.println(cmd);

} 
 
boolean connectWiFi(){
  
  String cmd="AT+CWJAP=\"";
  cmd+=SSID;
  cmd+="\",\"";
  cmd+=PASS;
  cmd+="\"";
  sendDebug(cmd);
  delay(10000);
  if(esp82.find("OK")){
    Serial.println("Connected: OK");
    return true;
  }else{
    Serial.println("Connected: Error");
    return false;
  }
}

//WIFI

Using the following schematic:


(I use pins 6 and 7 instead of 10 and 11)

I get this:

image

What am I doing wrong?

I added the schematic and full code. Is it clear now?

What should I do instead?

buy a makerfriendly ESP8266 like a NodeMCU or a Wemos D1 and program the ESP8266 on it.
If you run out of pins (NodeMCU / Wemos D1 have plenty) - use port expanders.

Where's the error? what's wrong with it?

This is my only option :confused: Why shoudln't I use an Arduino to control an esp?

No, not yet..

I don't have this option for many reasons:1) I don't have money to buy it and ship it. 2) I'm working within a team, and our team leader insists upon using an ESP with an Arduino..

Set aside the fancy code for now. Load the SerialPassthrough sketch and change it for the pins you are using. Type AT commands manually and see what you get back.

Also what happened when you had the baud rate set to 9600?

I've tried uploading this:

#include <SoftwareSerial.h>
SoftwareSerial esp82(6, 7);

void setup() {
  Serial.begin(9600);
  esp82.begin(9600);
}

void loop() {
  if (Serial.available()) {      // If anything comes in Serial (USB),
    esp82.write(Serial.read());   // read it and send it out Serial1 (pins 0 & 1)
  }

  if (esp82.available()) {     // If anything comes in Serial1 (pins 0 & 1)
    Serial.write(esp82.read());   // read it and send it out Serial (USB)
  }
}

Not sure if it's what you meant tho...
I get nothing when I send AT+RST.
I fiddled with the baud rate, nothing "happens".
What am I supposed to get on the monitor?

Maybe try this
https://www.instructables.com/Get-Started-With-ESP8266-Using-AT-Commands-Via-Ard/

If you send, "AT\n" you should get back "OK".

but your diagram shows that you're using UNO 10 and 11

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.