Diaoul / arduino-ESP8266

An Arduino library to manage the ESP8266.
MIT License
68 stars 46 forks source link

Random TIMEOUTs using ESP8266.h library #30

Open rwkiii opened 8 years ago

rwkiii commented 8 years ago

I'm experiencing random TIMEOUT issues and even random data in responses. Sometimes things 'mostly' work, other times it's a complete failure with nothing but TIMEOUT responses. First, my hardware setup:

Arduino UNO with NodeMCU Dev Board v0.90. ESP VCC -> UNO 5v ESP GND -> UNO GND ESP TX -> UNO D2 ESP RX -> UNO D3

Sketch is the 'complete' example provided in this library with both Hardware and software serial ports set to 115200 bps. (I'm not able to get ANY response using 9600 bps on either/both ports).

The uploaded new firmware (all 4 files) using the Expressif files here:

https://github.com/espressif/ESP8266_AT/tree/master/bin

AT commands appear to work fine using a serial console.

THE PROBLEM: From the Arduino IDE I upload the sketch which completes successfully. Using the Arduino Serial Monitor I can see the sketch running. After setting up the serial ports, the very first call made in the example sketch is:

Serial.println(getStatus(wifi.test()));

I would expect this to always return OK, but half of the time it is OK and the other half it is TIMEOUT. I have played with increasing and decreasing the wifi.setTimeout(...) setting. I've tried 500 all the way up to 3000.

Sometimes the version number varies.

Serial.print(getStatus(wifi.getVersion(version, 16)));

Keep in mind, sometimes the version number returns OK, but sometimes it is also a TIMEOUT, but when it does return a value it can be slightly different at random where only a single digit changes.

Here is an example console output from the 'complete' example sketch. Note, I have completely unplugged the power to both the UNO and ESP, then loaded the Arduino serial monitor to view output::

test: OK getVersion: OK : 0820000903 setWifiMode: OK joinAP: TIMEOUT getAP: TIMEOUT : getMAC STA: OK : 18:FD:34:C:2C:36 getIP STA: TIMEOUT : 0.0.0.0 connect: OK send: TIMEOUT createServer: OK deleteServer: ERROR

... Press UNO reset button:

test: OK getVersion: OK : 0820000903 setWifiMode: TIMEOUT joinAP: OK getAP: OK : Home Control getMAC STA: TIMEOUT : 0:0:0:0:0:0 getIP STA: TIMEOUT : 0.0.0.0 connect: TIMEOUT send: OK createServer: ERROR deleteServer: ERROR

...and again. Note initial test is TIMEOUT, version number is 'ok', but different than the one returned above. The getMAC returns TIMEOUT, but getIP succeeds:

test: TIMEOUT getVersion: OK : 0010000903 setWifiMode: TIMEOUT joinAP: OK getAP: OK : Home Control getMAC STA: TIMEOUT : 0:0:0:0:0:0 getIP STA: OK : 192.168.0.130 connect: OK send: OK createServer: TIMEOUT deleteServer: TIMEOUT

The above output is can be the same after resetting the UNO and/or ESP using their reset buttons. The order of reset, or completely repowering seems to have no effect on whether I receive TIMEOUT responses or mostly successful responses.

I don't know what else I can do at this point, but the randomness is never going to work for my application. Anyone know why this might be happening?

thynke commented 8 years ago

rw, check out this search and maybe talk to pete, i'm sure i saw him deal with this in the past: http://tech.scargill.net/?s=timeout

best - thynke