Post topics, source code that relate to the Arduino Platform

User avatar
By Bruce Markey
#18383 Finally got my esp8266 working. Connects to wifi just fine everything. I'm using an arduino uno with a few sensors and the esp to send that data to mysql. My wifi is N only so the esp is connecting to that.

Like I said everything works just fine except for the fact that the send fails about 77% of the time. I added a couple of counters and let it run overnight. Here is the code , http://pastebin.com/5vNiPwm7 .

I've tried using a short/long delay after line 199 but that just made it worse. The amount of data is short and I only have this running once per minute.

Anything that can be done to troubleshoot why its failing? Or something that needs to be changed to make it send more reliably?

EDIT: I wanted to add a few things that I've since tried. I put in a 470uf capacitor just to make sure it wasn't a power issue, that didn't help. I also swapped out the ESP unit with another just to be sure.

I've also notice that the longer it runs the more it fails. Also, and this might be anecdotal, but the longer it runs the more garbage I get in my secondary serial debug session.

Lastly, I put in a few lines to debug whether it was linking or not. It seems to link every time after running AT+CIPSTART but fails to send the data 75% of the time. ( The 75% figure holds up after 8 hours of continuous running.)

Thanks
User avatar
By ricg
#18563 From your description it sounds like you're saying the 75% fail rate is from not seeing the '>' prompt ? Or does is it fail to send the string? ie.. not getting a Send OK returned by the esp ?
If it's the former:
1. Try a lower baud rate. drop back to 9600 btwn the arduino and the esp. It could be that your sends to esp are getting garbled. In my experience i have not seen any problems at 9600.
2. A delay after line 199. I haven't looked at the softserial code for find, but if it does a string compare and then returns you could miss recv'ing the string if the timing isn't spot on. Checking in a loop with a timeout allows a variation in the timing without forcing a set amount of delay.
ie...
foo(50);
int foo(n) {
ulong t=millis()+n;
do {
if( Serial.find(">") )
return 1 ; // found it
} while( t > millis() );
return 0; // drops thru if not found in timeout
}
User avatar
By Bruce Markey
#18594 I think it is because it's not seeing the '>' prompt. Or at least that's my guess. Thank's for the ideas, I'm running out of patience with this little module. I want to believe that it works...

1. I'm already at 9600 baud.
2. I've played with that delay at line 199 and it seems the higher it goes the worse it gets. I'm going to try that loop code and see if that helps.

Some other information.

1. I am using the 3.3v off of the arduino uno. I've come to learn that might not be the best idea due to current needs. I have a power supply on the way and will test that. I attempted to test off of the 3.3 of my usb/serial but that was a whole other mess. So maybe this whole thing is jsut not enough power.