marcoschwartz / aREST

A RESTful environment for Arduino
http://aREST.io/
Other
1.2k stars 279 forks source link

esp8266 #89

Open pickeld opened 8 years ago

pickeld commented 8 years ago

Hey, im using aREST for controlling my relay, all goes fine untill after few hours the esp8266 get bricked and i need to physically unplug and re-plug it. whilee trying to figure out why my esp8266 is no longer responsive i attached the rx and tx to the computer and add the code Serial.println(WiFi.status());

the results are

WiFi Status: 3 WiFi Status: 3 WiFi Status: 3 WiFi Status: 3 WiFi Status: 3 WiFi Status: 3 WiFi Status: 3 WiFi Status: 3 WiFi Status: 3 WiFi Status: 6 WiFi Status: 3 WiFi Status: 3 WiFi Status: 3 WiFi Status: 3 WiFi Status: 3 WiFi Status: 3

does anyone knows whats going on here?

saliehendricks commented 8 years ago

My first guess would be power issues. I experience similar issues when running with a USB cable via pc and those breadboard power adapters. There's not enough current.

What module are you running?

pickeld commented 8 years ago

i was using a poor 5v 500mAh phone charger. while running esp8266 and a relay. now i've changed to 5v 2000mAh . ill update for any change. thank you

pickeld commented 8 years ago

here's an update: i change the power suplly as mentioned above. that DIDNT helped. the power supply mac current is 2000mAh. and it provieds 5v. the esp8266 uses 3.3v so i added an ams1777 to regulate the volage to 3.3. the ams1117-3.3 max current as i read is above 1mA to thats not a problem.

I've read too many articles about preventing the esp8266 reseting, some of them say to attach a 0/1uf - 1uf from the vcc to gnd. that didnt make the trick for me.

should a firmware upgrade will do the work? what should i do then?

hopefully someone here will help me. im lost :(

here is my code & sketch:

// Import required libraries

include

include

// Create aREST instance aREST rest = aREST();

// WiFi parameters const char* ssid = "SSID"; const char* password = "PASSWORD";

// The port to listen for incoming TCP connections

define LISTEN_PORT 80

// Create an instance of the server WiFiServer server(LISTEN_PORT);

// Declare functions to be exposed to the API int ledControl(String command);

void setup(void) { // Function to be exposed rest.function("led", ledControl);

// Connect to WiFi while (WiFi.status() != WL_CONNECTED) { WiFi.begin(ssid, password); delay(10000); } // Start the server server.begin(); }

void loop() { // TRYING TO FORCE ESP8266 RECONNECT WHENEVER THERE IS NO CONNECTION while (WiFi.status() != WL_CONNECTED) { WiFi.begin(ssid, password); delay(7000); server.begin(); }

// Handle REST calls WiFiClient client = server.available(); if (!client) { return; } while (!client.available()) { delay(1); } rest.handle(client);

}

// Custom function accessible by the API int ledControl(String command) {

// Get state from command int state = command.toInt();

digitalWrite(2, state); return 1; }

sketch

sverzulli commented 8 years ago

Hi Marco, I am also experiencing dropouts. I am using the Adafruit Huzzah board with a 5v 2 Amp power supply. I am running your example program controlling a relay from your book. I can see the webserver running with the on and off buttons displayed but after a few hours I cannot get the buttons to appear. The Huzzah appears to still be on line but no webpage. Attached is a screenshot of the buttons as they appear before the text and buttons no longer show up. screenshot from 2016-02-29 13 49 03

Regards,

Steve V

marcoschwartz commented 8 years ago

Hello, from what I know so far it seems like a memory leak problem of the ESP8266 & Arduino IDE. I couldn't find the problems on my own sketch, so it might be an issue with the compiling step with the ESP8266 Arduino library. I'll look more into it.

yomasa commented 8 years ago

Hello, I am having same type of issues, works a for a while then locks or reboots, I have tested 2 nodeMCU v3 and a wemos. Seems like a memory leak somewhere.

pickeld commented 8 years ago

i've changed to mqtt. all works great. hope to change back to aRest soon when the bug is fixed good luck!

yomasa commented 8 years ago

Can someone recommend a more stable platform or hardware, I don't know if I can wait for the Ardino IDE to fix all the issues with the esp8266 ?

marcoschwartz commented 8 years ago

@yomasa I actually released a new version of aREST yesterday that adds the support for the latest board of Arduino, the MKR1000. It's more expensive than the ESP8266 but also has built-in WiFi. No problems so far :)

yomasa commented 8 years ago

@marcoschwartz Thank you for doing that, I just ordered one. I also ordered a LinkIt Smart 7688 Duo looks like it may be also useful and only $15.00 and Arduino Yún compatible http://www.seeedstudio.com/depot/LinkIt-Smart-7688-Duo-p-2574.html

odyslam commented 8 years ago

I would suggest for powering the esp to use a buck-converter like lm2596, it's far more stable than a single regulator.