RESOLVED. 2 problems with ESP-01 and Uno (Thank you pert!)

Please help. I am having 2 problems I can't seem to fix.

#1 wifi connects with static ip and works fine as a webserver.....until it is unplugged and plugged back in, then it does nothing. uploading the code again then checking the serial monitor and it works again until it is unplugged again.

#2 to get the esp-01 to work it requires me to have the uno's reset to jump to ground, making it impossible? to use the uno's analog and digital pins. (unless I'm just doing something wrong)

I had the BME280 and voltage sensor working fine with the uno and an ethernet shield but I want to replace it with wifi to get rid of the cable.

due to post size restrictions I've attached the code as txt files. There are 3 files.

  • Working wifi static ip.txt - this is the code that works fine to get the wifi to connect and act as a webserver until it is unplugged

  • Working Uno W5100 BME280 Volt.txt - works for ethernet shield

-test code.txt - attempt to integrate the 2 codes which works on the wifi end but not the bme280 or volt sensor connected to the uno scl/sda (bme) and analog pin (volt sensor)

the ESP is wired like the picture, except reset is jumped to ground on the UNO and the BME280 on 3V scl/sda and voltage sensor on 3V on analog 0

please help and thank you in advance for reading it and helping.

working wifi static ip.txt (3.32 KB)

Working Uno W5100 BME280 Volt.txt (4.13 KB)

test code.txt (5.02 KB)

BobCatEndeavors's picture:

BobCatEndeavors:
#2 to get the esp-01 to work it requires me to have the uno's reset to jump to ground, making it impossible? to use the uno's analog and digital pins. (unless I'm just doing something wrong)

In that configuration, you're using the Uno as a USB to TTL serial adapter to allow serial communication between your computer and the ESP-01. It's a poor use of an Uno, but if that's all you need it will work.

However, it sounds like you would like to run a program on the Uno and have the Uno communicating with the ESP-01. For that usage, you need different wiring. Instead of your current RX-RX, TX-TX wiring between the Uno and ESP-01, you need to connect them RX-TX, TX-RX. The reason is that RX stands for "receive" and TX stands for "transmit".

Pins 0 and 1 on your Uno are used to communicate with the computer. If you connect the ESP-01 to those pins, it will interfere with uploads to the Uno and you will need to disconnect the ESP-01 every time you want to upload a sketch. Any use of Serial.print(), etc. for things like debug output to the Serial Monitor can interfere with the communication between the Uno and the ESP-01. For this reason, most people will create a software serial port on some other pins of the Uno using the SoftwareSerial library and connect the ESP-01 to those pins. The problem with this is that the default baud rate of the ESP-01's AT firmware is 115200, but the SoftwareSerial library does not work reliably at that speed. So before rewiring your ESP-01, you should use the appropriate AT command to set the baud rate of the AT firmware to a lower speed, like 9600.

Of course, you will need to remove the connection between reset and ground on your Uno once you are ready to use it as a real Arduino board again.

For the usage of controlling an ESP-01 from a regular Arduino board using the AT firmware, I recommend this library:

It has an API that is compatible with that of the Ethernet library, so it will make it very simple for you to adapt your code to work with the ESP-01.

Thanks for the speedy response, it is much appreciated. I'll try that and hopefully post a successful report today.

so far nothing but problems. kept current wiring and used ESPlorer to send AT+CIOBAUD=9600. gave no errors.
changed board in Arduino IDE to uno and removed reset jumper and uploaded software serial code. timed out unable to connect to ESP module. disconnected ESP from uno and connected to FT232 TTL and flashed with ai-thinker-0.9.5.2-9600. tested with ESPlorer again while still on the 232. AT command gives an OK but al other commands gives error. re-flashed with ESP_8266_BIN0.92

ESPlorer gives me this

Communication with MCU..Got answer! Communication with MCU established.
AutoDetect firmware...

Can't autodetect firmware, because proper answer not received (may be unknown firmware).
Please, reset module or continue.
AT+RST

OK

ets Jan 8 2013,rst cause:4, boot mode:(3,7)

wdt reset
load 0x40100000, len 212, room 16
tail 4
chksum 0x5e
load 0x3ffe8000, len 788, room 4
tail 0
chksum 0x1c
load 0x3ffe8314, len 72, room 8
tail 0
chksum 0x55
csum 0x55
jump to user1

ready
AT+CIOBAUD=9600
AT+CIOBAUD=9600

ERROR
AT+CWJAP?

+CWJAP:""

OK
AT+CWLAP

ERROR
AT+CWMODE?

+CWMODE:2

OK
AT+CWMODE=1

OK
AT+CWLAP

ERROR

re-flashed with ai-thinker-0.9.5.2
lists available networks and gave ok to CIOBAUD=9600.
testing with uno and serial ino now. will update

unable to connect - timeout

reconnected to TTL to test and make sure change of baud took. ESPlorer gives this

PORT OPEN 9600

Communication with MCU..Got answer! Communication with MCU established.
AutoDetect firmware...

Can't autodetect firmware, because proper answer not received (may be unknown firmware).
Please, reset module or continue.
K
AT+CWMODE?

+CWMODE:1

OK
AT+CWJAP?

No AP

OK
AT+CWJAP="belkin.ba6","*****"

+CWJAP:1

FAIL
AT+CWLAP

+CWLAP:(4,"belkin.ba6",-38,"08:86:3b:fd:4b:a6",1)
+CWLAP:(0,"belkin.ba6.guests",-42,"08:86:3b:fd:4b:a7",1)
+CWLAP:(3,"vsat-24g-98E424",-54,"02:1c:bb:df:dd:00",6)
+CWLAP:(3,"NETGEAR22",-31,"08:bd:63:b5:23:50",11)
+CWLAP:(3,"DIRECT-68-HP DeskJet 3630 series",-60,"fc:3f:db:9f:6a:f0",11)

OK
AT+CWJAP="belkin.ba6","*****"

+CWJAP:1

FAIL
AT+CWMODE=?

+CWMODE:(1-3)

OK
AT+CWMODE?

+CWMODE:1

OK
AT+RST

OK
cŸÇÏR˜vfJ[zâFjS&J„ÂGÇWË@
Ai-Thinker Technology Co. Ltd.

ready
AT+CWJAP="belkin.ba6","***"

+CWJAP:1

FAIL
AT+CWLAP

+CWLAP:(4,"belkin.ba6",-36,"08:86:3b:fd:4b:a6",1)
+CWLAP:(0,"belkin.ba6.guests",-39,"08:86:3b:fd:4b:a7",1)
+CWLAP:(3,"vsat-24g-98E424",-58,"02:1c:bb:df:dd:00",6)
+CWLAP:(3,"NETGEAR22",-31,"08:bd:63:b5:23:50",11)
+CWLAP:(3,"DIRECT-68-HP DeskJet 3630 series",-60,"fc:3f:db:9f:6a:f0",11)

OK
AT+CWJAP="Netgear22","*****"

+CWJAP:3

FAIL

flashed with ai-thinker-v1.1.1
ESPlorer ok'd baud rate change to 9600. closed and reopened ESPlorer as 9600 baud. sees AP list and connects to wifi
however arduino software serial still times out unable to connect to ESP

reflashed following these instructions

tried changing baud rate with ESPlorer

PORT OPEN 115200

Communication with MCU..Got answer! Communication with MCU established.
AutoDetect firmware...

Can't autodetect firmware, because proper answer not received (may be unknown firmware).
Please, reset module or continue.
AT+CIOBAUD=9600
AT+CIOBAUD=9600

OK

PORT CLOSED

PORT OPEN 9600

Communication with MCU..Got answer! Communication with MCU established.
AutoDetect firmware...

Can't autodetect firmware, because proper answer not received (may be unknown firmware).
Please, reset module or continue.

OK
AT+RST

OK
WIFI DISCONNECT
c_ÇRSöfJ[:fJ[|êóêvBfâf–Ë“cèëëë
PORT CLOSED

PORT OPEN 9600

Communication with MCU..
PORT OPEN 9600

Communication with MCU..
PORT CLOSED

PORT OPEN 115200

Communication with MCU..Got answer! Communication with MCU established.
AutoDetect firmware...

Can't autodetect firmware, because proper answer not received (may be unknown firmware).
Please, reset module or continue.

AT+CIOBAUD=9600
AT+CIOBAUD=9600

OK

PORT CLOSED

PORT OPEN 9600

Communication with MCU..Got answer! Communication with MCU established.
AutoDetect firmware...

Can't autodetect firmware, because proper answer not received (may be unknown firmware).
Please, reset module or continue.

OK
AT+RST

OK
WIFI DISCONNECT
c_ÇRSöfJ[:fJ“zêóêvBfâfVËScèëïë8—†þ‚›‡ � Žƒú‡e–‚’›’˜–š0‡8‚ ƒ�“e–†þcàëëë
PORT CLOSED

PORT OPEN 9600

Communication with MCU..
PORT CLOSED

PORT OPEN 9600

Communication with MCU..
PORT CLOSED

PORT OPEN 115200

Communication with MCU..Got answer! Communication with MCU established.
AutoDetect firmware...

Can't autodetect firmware, because proper answer not received (may be unknown firmware).
Please, reset module or continue.
AT+RST

OK
WIFI DISCONNECT

ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x40100000, len 1396, room 16
tail 4
chksum 0x89
load 0x3ffe8000, len 776, room 4
tail 4
chksum 0xe8
load 0x3ffe8308, len 540, room 4
tail 8
chksum 0xc0
csum 0xc0

2nd boot version : 1.4(b1)
SPI Speed : 40MHz
SPI Mode : QIO
SPI Flash Size & Map: 8Mbit(512KB+512KB)
jump to run user1 @ 1000

ŒeÕ(¤SQS�(RQ¨)HT¨)SHHHC…äÿrŽeùô
Ai-Thinker Technology Co. Ltd.

invalid
WIFI CONNECTED
AT+CWJAP?

No AP

OK

convinced the flash until from those instructions suck. going back to the ESP8266 flasher I was using. tried these bins.
ai-thinker-0.9.5.2
ai-thinker-0.9.5.2-9600
ai-thinker-v1.1.1
ESP_8266_BIN0.92
v0.9.2.2 AT Firmware
v1.1.1.1 AT Firmware
v1.3.0.2 AT Firmware

the only one that works, doesn't give errors in ESPlorer and actually connects to an AP is ai-thinker-0.9.5.2

still arduino software serial says

[WiFiEsp] Initializing ESP module
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] Cannot initialize ESP module
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] No tag found
WiFi shield not present

here is a probably stupid question. how come I can't add #include <ESP8266WiFi.h> to the sketch unless i change the board to generic 8266 module?

When I was trying to find an example that would work before the ESPwifi examples did not work, only the ESP8266WiFi.h did.

I'm thinking that ESPWifi.h does not like my ESP-01S and that if I could get it to use ESP8266Wifi instead it would detect the module.

getting closer. found this : GitHub - ekstrand/ESP8266wifi: ESP8266 Arduino library with built in reconnect functionality

#include <SoftwareSerial.h>
#include <SerialESP8266wifi.h>

#define sw_serial_rx_pin 4 //  Connect this pin to TX on the esp8266
#define sw_serial_tx_pin 6 //  Connect this pin to RX on the esp8266
#define esp8266_reset_pin 5 // Connect this pin to CH_PD on the esp8266, not reset. (let reset be unconnected)

SoftwareSerial swSerial(sw_serial_rx_pin, sw_serial_tx_pin);

// the last parameter sets the local echo option for the ESP8266 module..
SerialESP8266wifi wifi(swSerial, swSerial, esp8266_reset_pin, Serial);//adding Serial enabled local echo and wifi debug

String inputString;
boolean stringComplete = false;
unsigned long nextPing = 0;

void setup() {
  inputString.reserve(20);
  swSerial.begin(9600);
  Serial.begin(9600);
  while (!Serial)
    ;
  Serial.println("Starting wifi");

  wifi.setTransportToTCP();// this is also default
  // wifi.setTransportToUDP();//Will use UDP when connecting to server, default is TCP

  wifi.endSendWithNewline(true); // Will end all transmissions with a newline and carrage return ie println.. default is true

  wifi.begin();

  //Turn on local ap and server (TCP)
  wifi.startLocalAPAndServer("MY_CONFIG_AP", "password", "5", "2121");

  wifi.connectToAP("wifissid", "wifipass");
  wifi.connectToServer("192.168.0.28", "2121");
  wifi.send(SERVER, "ESP8266 test app started");
}

void loop() {

  //Make sure the esp8266 is started..
  if (!wifi.isStarted())
    wifi.begin();

  //Send what you typed in the arduino console to the server
  static char buf[20];
  if (stringComplete) {
    inputString.toCharArray(buf, sizeof buf);
    wifi.send(SERVER, buf);
    inputString = "";
    stringComplete = false;
  }

  //Send a ping once in a while..
  if (millis() > nextPing) {
    wifi.send(SERVER, "Ping ping..");
    nextPing = millis() + 10000;
  }

  //Listen for incoming messages and echo back, will wait until a message is received, or max 6000ms..
  WifiMessage in = wifi.listenForIncomingMessage(6000);
  if (in.hasData) {
    if (in.channel == SERVER)
      Serial.println("Message from the server:");
    else
      Serial.println("Message a local client:");
    Serial.println(in.message);
    //Echo back;
    wifi.send(in.channel, "Echo:", false);
    wifi.send(in.channel, in.message);
    nextPing = millis() + 10000;
  }

  //If you want do disconnect from the server use:
  // wifi.disconnectFromServer();

}

//Listen for serial input from the console
void serialEvent() {
  while (Serial.available()) {
    char inChar = (char)Serial.read();
    inputString += inChar;
    if (inChar == '\n') {
      stringComplete = true;
    }
  }
}

serial monitor gives error in screenshot

BobCatEndeavors:
here is a probably stupid question. how come I can't add #include <ESP8266WiFi.h> to the sketch unless i change the board to generic 8266 module?

When I was trying to find an example that would work before the ESPwifi examples did not work, only the ESP8266WiFi.h did.

I'm thinking that ESPWifi.h does not like my ESP-01S and that if I could get it to use ESP8266Wifi instead it would detect the module.

The ESP8266WiFi library can only be used when you are directly programming the ESP8266 microcontroller. The library is written to directly use the WiFi functionality of the ESP8266 and thus can't be used with any other type of microcontroller. Please don't try to use it with your Uno. You'll only waste time.

BobCatEndeavors:
getting closer. found this : GitHub - ekstrand/ESP8266wifi: ESP8266 Arduino library with built in reconnect functionality

Despite the similar name, that library is completely different from ESP8266WiFi. It is similar to the WiFiEsp library I recommended in that it is meant to run on an Arduino board that is connected via serial to an ESP8266 running the AT firmware. The reason I don't recommend the ekstrand/ESP8266wifi library is because, unlike the WiFiEsp library, it doesn't use a compatible API. You would need to do a lot more work to modify your Ethernet code to work with the ekstrand/ESP8266wifi library.

but that WifiEsp didn't work at all, it doesn't see the module.
I flashed the module with ai-thinker-0.9.5 and that got rid of the bad characters and it works just fine with SerialESP8266wifi, it connects to the router and didn't give any errors at all, its just not webserver code.
So at this point what choice do I have? I have no idea why ESPWifi doesn't work and this one does.

got espwifi to kinda work. says unsupported firmware and won't connect, but at least it sees the module now.
going to try flashing the firmware and see if I can find one to work with that code

ok, the only firmware that seems to work is that 9.5 (all others I try ESPWifi doesn't even see the module.
using 9.5 the scan network example works fine and displays the networks. The web server and any that connect to an AP all fail. No I had this same problem in ESPlorer until i set the mode to 1 (station) then it works.
so now my question is this, is there an equivalent to WiFi.mode(WIFI_STA); for this library? (tried and said class has no member named 'mode')

read that this library is always in station mode, in which case I'm stuck. I can connect using ESPlorer but not with ESPWifi. (also, how can I assign a static IP once I do get it to connect>)

I uploaded the basictest example and got this

[WiFiEsp[WiFiEsp] Initializing ESP module
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] Warning: Unsupported firmware
********************************************** Firmware version > FAILED (actual="", expected="1.5.2")

********************************************** Status is (WL_DISCONNECTED) > FAILED (actual=0, expected=3)

[WiFiEsp] Failed connecting to belkin.ba6
********************************************** Connect > FAILED (actual=2, expected=1)

********************************************** Check status (WL_CONNECTED) > PASSED

********************************************** Check SSID > PASSED

********************************************** Check IP Address > PASSED

IP Address: 192.168.2.11
MAC: 18:FE:34:32:9:D0

********************************************** Disconnect > PASSED

********************************************** Check status (WL_DISCONNECTED) > PASSED

********************************************** IP Address > PASSED

********************************************** Check SSID > PASSED

[WiFiEsp] Failed connecting to belkin.ba6
********************************************** Wrong pwd > PASSED

[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] Failed connecting to belkin.ba6
********************************************** Connect > FAILED (actual=2, expected=1)

********************************************** Check status (WL_CONNECTED) > PASSED

********************************************** Check IP Address > FAILED (actual=0, expected=0)

END OF TESTS

BobCatEndeavors:
read that this library is always in station mode, in which case I'm stuck.

That's incorrect. The library includes an example of using it in AP mode:

BobCatEndeavors:
how can I assign a static IP once I do get it to connect

That's demonstrated in the comments of the above example sketch:

  // uncomment these two lines if you want to set the IP address of the AP
  //IPAddress localIp(192, 168, 111, 111);
  //WiFi.configAP(localIp);

I don't know what's going on with those unsupported firmware issues. The library documentation says "AT version 0.25 and above". I've never gotten a good understanding of the AI-Thinker AT firmware, since the last I checked there was no English documentation available. I've always flashed the Espressif firmware for this reason, though I have used ESP8266 modules that came with the AI-Thinker AT firmware.

I haven't used the WiFiEsp library for a few years now, but I had no problems with it at that time.

[WiFiEsp[WiFiEsp] Initializing ESP module
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] Warning: Unsupported firmware
Attempting to start AP belkin.ba6
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] Failed to set AP mode belkin.ba6
Access point started
IP Address: 0.0.0.0

To see this page in action, connect to belkin.ba6 and open a browser to http://0.0.0.0

[WiFiEsp] Server started on port 80
Server started

ok. so after flashing the ESP with ai-thinker-v1.3.0.2-115200.bin and changing the baud to 9600 through ESPlorer it looks like it works, but when I try to access it from a computer it times out or says unavailable (I see no activity(flashing lights) on the ESP when trying to access

[WiFiEsp] Initializing ESP module
[WiFiEsp] Initilization successful - 1.3.0
Attempting to start AP belkin.ba6
[WiFiEsp] IP address set 192.168.2.101
[WiFiEsp] Access point started belkin.ba6
Access point started
IP Address: 192.168.2.101

To see this page in action, connect to belkin.ba6 and open a browser to http://192.168.2.101

[WiFiEsp] Server started on port 80
Server started