ESP8266 won't respond

This is the best code I could find (github) for connecting an ESP-01 to a Uno. However all I get are timeouts. I even have the thing on it's own 3.3V voltage supply. I am very frustrated with these ESP01s. So either I'm using wrong code or the modules are all bad because I've tested 2 of my four.

:frowning:

/*
 WiFiEsp test: BasicTest
 
 Performs basic connectivity test and checks.
*/

#include "WiFiEsp.h"

// Emulate Serial1 on pins 7/6 if not present
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(14, 15); // RX, TX
#endif


char ssid[] = "JMR";     // your network SSID (name)
char pwd[] = "crystal2965";  // your network password
char pwdErr[] = "xxxx";   // wrong password


void setup()
{
  Serial.begin(9600);
  Serial1.begin(9600);
  WiFi.init(&Serial1);
}

void loop()
{
  assertEquals("Firmware version", WiFi.firmwareVersion(), "1.5.2");
  assertEquals("Status is (WL_DISCONNECTED)", WiFi.status(), WL_DISCONNECTED);
  assertEquals("Connect", WiFi.begin(ssid, pwd), WL_CONNECTED);
  assertEquals("Check status (WL_CONNECTED)", WiFi.status(), WL_CONNECTED);
  assertEquals("Check SSID", WiFi.SSID(), ssid);

  IPAddress ip = WiFi.localIP();
  assertNotEquals("Check IP Address", ip[0], 0);
  Serial.print("IP Address: ");
  Serial.println(ip);
  
  byte mac[6]={0,0,0,0,0,0};
  WiFi.macAddress(mac);

  Serial.print("MAC: ");
  Serial.print(mac[5], HEX);
  Serial.print(":");
  Serial.print(mac[4], HEX);
  Serial.print(":");
  Serial.print(mac[3], HEX);
  Serial.print(":");
  Serial.print(mac[2], HEX);
  Serial.print(":");
  Serial.print(mac[1], HEX);
  Serial.print(":");
  Serial.println(mac[0], HEX);
  Serial.println();
  
  assertEquals("Disconnect", WiFi.disconnect(), WL_DISCONNECTED);
  assertEquals("Check status (WL_DISCONNECTED)", WiFi.status(), WL_DISCONNECTED);
  assertEquals("IP Address", WiFi.localIP(), 0);
  assertEquals("Check SSID", WiFi.SSID(), "");
  assertEquals("Wrong pwd", WiFi.begin(ssid, pwdErr), WL_CONNECT_FAILED);

  IPAddress localIp(192, 168, 168, 111);
  WiFi.config(localIp);
  
  assertEquals("Connect", WiFi.begin(ssid, pwd), WL_CONNECTED);
  assertEquals("Check status (WL_CONNECTED)", WiFi.status(), WL_CONNECTED);

  ip = WiFi.localIP();
  assertNotEquals("Check IP Address", ip[0], 0);


  Serial.println("END OF TESTS");
  delay(60000);
}


////////////////////////////////////////////////////////////////////////////////////


void assertNotEquals(const char* test, int actual, int expected)
{
  if(actual!=expected)
    pass(test);
  else
    fail(test, actual, expected);
}

void assertEquals(const char* test, int actual, int expected)
{
  if(actual==expected)
    pass(test);
  else
    fail(test, actual, expected);
}

void assertEquals(const char* test, char* actual, char* expected)
{
  if(strcmp(actual, expected) == 0)
    pass(test);
  else
    fail(test, actual, expected);
}


void pass(const char* test)
{
  Serial.print(F("********************************************** "));
  Serial.print(test);
  Serial.println(" > PASSED");
  Serial.println();
}

void fail(const char* test, char* actual, char* expected)
{
  Serial.print(F("********************************************** "));
  Serial.print(test);
  Serial.print(" > FAILED");
  Serial.print(" (actual=\"");
  Serial.print(actual);
  Serial.print("\", expected=\"");
  Serial.print(expected);
  Serial.println("\")");
  Serial.println();
  delay(10000);
}

void fail(const char* test, int actual, int expected)
{
  Serial.print(F("********************************************** "));
  Serial.print(test);
  Serial.print(" > FAILED");
  Serial.print(" (actual=");
  Serial.print(actual);
  Serial.print(", expected=");
  Serial.print(expected);
  Serial.println(")");
  Serial.println();
  delay(10000);
}

You are probubly not getting it into flash mode.
I hate these things as I have had the same pain. in the end, i gave up and went for a 32 or the esp01 v12 dev boards and the 01's are just so difficult to program.

No, I don't wish to flash it or change a single thing about the way it functions other than to have it function in passing off WiFi (more importantly data) to the Uno.

Ummm...

If you're trying to put that program on to the ESP, then you're trying to flash it.
You need to put the ESP01 into flashing mode before trying to load that program

Unfortunately, the ESP-01 required you to press buttons in a certain sequence (I seem to recall having to throw a pinch of tobacco to the four winds as well) before it will load a program

See this article.
It's the one I used initially before I tossed my ESP01 and got an ESP12

If you're trying to load that code on to the UNO :o

Just an additional thought.
If what you're trying to do is just access the interwebs and stuff, this device will act as a serial 'modem'
You connect via the serial ports (you can use softserial) and use AT commands to do things like connect to a network

Here is a reference of the command set

darrob:
Ummm…

If you’re trying to put that program on to the ESP, then you’re trying to flash it.
You need to put the ESP01 into flashing mode before trying to load that program

Unfortunately, the ESP-01 required you to press buttons in a certain sequence (I seem to recall having to throw a pinch of tobacco to the four winds as well) before it will load a program

See this article.
It’s the one I used initially before I tossed my ESP01 and got an ESP12

If you’re trying to load that code on to the UNO :o

Did you remember the prayer to the tech gods?
I’m glad I’m not the only one to give up on it.

mattlogue:
either I'm using wrong code or the modules are all bad because I've tested 2 of my four.

The problem is that the AT firmware on the ESP8266 does serial communication at 115200 baud by default. You need to send the appropriate AT+UART_DEF command to the ESP8266 to change the baud rate to the 9600 you have set your software serial communication to run at.

AJB2K3:
You are probubly not getting it into flash mode.

darrob:
If you're trying to put that program on to the ESP, then you're trying to flash it.
You need to put the ESP01 into flashing mode before trying to load that program

mattlogue is NOT trying to flash the ESP8266. They're uploading a sketch to than Uno which is connected to the ESP-01 via software serial to control the ESP-01's AT firmware.

darrob:
If you're trying to load that code on to the UNO :o

What about that code running on an Uno is cause for a funny face?
The WiFiEsp library is written specifically for this usage:

darrob:
Just an additional thought.
If what you're trying to do is just access the interwebs and stuff, this device will act as a serial 'modem'
You connect via the serial ports (you can use softserial) and use AT commands to do things like connect to a network

Here is a reference of the command set

That's exactly what they're doing. But there's no need to learn the command set because the WiFiEsp library wraps it all up in a nice API that's consistent with the standard Arduino network libraries.

pert:

What about that code running on an Uno is cause for a funny face?
The WiFiEsp library is written specifically for this usage:
https://github.com/bportaluri/WiFiEspThat’s exactly what they’re doing. But there’s no need to learn the command set because the WiFiEsp library wraps it all up in a nice API that’s consistent with the standard Arduino network libraries.

I misread the line ’ #include “WiFiEsp.h” ’ . I saw#include <ESP8266WiFi.h>’

My bad :frowning:

We've certainly seen a lot of people trying their best to run the ESP8266WiFi library on an Uno.

Hello pert

I have a problem of language (as French) :
Are you meaning that the O.P. is trying to use an Arduino library on an ESP8266?

Regards,
bidouilleelec

bidouilleelec:
Hello pert

I have a problem of language (as French) :
Are you meaning that the O.P. is trying to use an Arduino library on an ESP8266?

Regards,
bidouilleelec

No

He was telling me that the O.P. is using a library that lets the UNO talk to an ESP-01

It was my mistake to think that the O.P. was trying to use an Arduino library on an ESP8266.
My mistake made me give bad answers :blush:

darrob:
No

He was telling me that the O.P. is using a library that lets the UNO talk to an ESP-01

It was my mistake to think that the O.P. was trying to use an Arduino library on an ESP8266.
My mistake made me give bad answers :blush:

Thanks.

Best Regards,
bidouilleelec