ESP8266 crashs
Posted: Wed Oct 21, 2015 2:28 pm
Hey guys,
some weeks ago I decided to create a control for a RGB-LED Strip. As I heard of the ESP8266 module I was totally impressed. How cool is that to use your Smartphone to controle that strip? So I started to practice with this beautifull little module.
So I wrote a little smartphoneapp which has two sliders. One to control the brightness and one for the colour.(min value is 0 and max is 255 for each) If the value of the slider changes the Information will be send via URL. For example for the colour 210 the Website http://192.168.xxx.xxx/F210 will be opened in the Background. For the brightness it would be the same but the "F" would be replaced by a "H".
This works quite good for lower frequencies like 1hz. But I want that the changes effect in real time. So that the colour changes immediately if you wipe over the slider. Therefore I need higher frequencies. Currently I run the ESP module as Accesspoint. In this Setting I reach about 10hz. If I go lower the ESP first doesnt react for about a second and then restarts with a wdt reboot. I also want to run it in stationmode but there it is even worse. Here it may reach about 3hz (I didnt tested it but it is definitely less stable).
So my question is: How can i avoid the crashes and how can I reach higher frequencies? (my target is about 20hz stable in each mode)
I wrote the program with the Arduino IDE. This is my code:
I hope you can help me. Thank you very much in advance.
Greetings Daniel
some weeks ago I decided to create a control for a RGB-LED Strip. As I heard of the ESP8266 module I was totally impressed. How cool is that to use your Smartphone to controle that strip? So I started to practice with this beautifull little module.
So I wrote a little smartphoneapp which has two sliders. One to control the brightness and one for the colour.(min value is 0 and max is 255 for each) If the value of the slider changes the Information will be send via URL. For example for the colour 210 the Website http://192.168.xxx.xxx/F210 will be opened in the Background. For the brightness it would be the same but the "F" would be replaced by a "H".
This works quite good for lower frequencies like 1hz. But I want that the changes effect in real time. So that the colour changes immediately if you wipe over the slider. Therefore I need higher frequencies. Currently I run the ESP module as Accesspoint. In this Setting I reach about 10hz. If I go lower the ESP first doesnt react for about a second and then restarts with a wdt reboot. I also want to run it in stationmode but there it is even worse. Here it may reach about 3hz (I didnt tested it but it is definitely less stable).
So my question is: How can i avoid the crashes and how can I reach higher frequencies? (my target is about 20hz stable in each mode)
I wrote the program with the Arduino IDE. This is my code:
Code: Select all
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
String html1 = "<html>\n<head>\n<title>LED-Steuerung</title>\n<script language=\"JavaScript\" type=\"text/javascript\">\nfunction GetFarbe(){\nvar Farbe = document.getElementById(\"schieber1\").value;\ndocument.getElementById(\"iframe\").src=\"http://192.168.178.38/F\"+Farbe;\n}\nfunction GetHell(){\nvar Helligkeit = docu";
String html2 = "ment.getElementById(\"schieber2\").value;\ndocument.getElementById(\"iframe\").src=\"http://192.168.178.38/H\"+Helligkeit;\n}\n</script>\n</head>\n<body>\n<p align=\"center\">\n<table>\n<tr><th colspan=\"3\"><p align=\"center\">Steuerung der LED-Lichtleiste</p></th></tr>\n<tr></tr>\n<tr><td></td><td align=";
String html3 = "center>Farbe</td><td></td></tr>\n<tr><td></td><td align=center><input type=\"range\" min=\"15\" max=\"255\" id=\"schieber1\" onclick=\"GetFarbe()\" value=\"120\"/></td><td></td></tr>\n<tr></tr>\n<tr><td></td><td align=center>Helligkeit</td><td></td></tr>\n<tr><td></td><td align=center><input type=\"range\" min=\"0\" max=\"255\" id=\"schieber2\" onclick=\"GetHell()\" value=\"120\"/></td><td></td></tr>\n</table>\n</p>\n<iframe height=\"0\" width=\"0\" frameborder=\"0\" id=\"iframe\"></iframe>\n</body>\n</html>";
ESP8266WebServer server(80);// Serverport hier einstellen
// Daten Accesspoint
const char* ssid = "ESP";
const char* password = "";
// Daten Station
char ssids[11] = "ssid"; //Variable fuer Wlan Name
char passwords[17] = "pass"; //Variable fuer Passwort
// Netzwerkkonfiguration
IPAddress ip(192,168,178,38);
IPAddress gateway(192,168,178,1);
IPAddress subnet(255,255,255,0);
void setup() // Wird 1 Mal beim Start ausgefuehrt
{
WiFiconnect();
server.on("/", Ereignis_Index);
server.on("/favicon.ico", Ereignis_Null);
server.onNotFound(notFoundHandler);
server.begin(); // Starte den Server
}
void Ereignis_Index() // Wird ausgeuehrt wenn "http://<ip address>/" aufgerufen wurde
{
server.send(200, "text/html", html1 + html2 + html3);
}
void loop() //Hautprogramm
{
if (Serial.available()); // Wenn Seriell etwas empfangen
server.handleClient();// Serverereignisse abarbeiten
}
void notFoundHandler() {
server.send(200, "text/html", "0");
String Rec = server.uri();
Serial.println(Rec.substring(1));
delay(50);
}
void Ereignis_Null() {
server.send(200, "text/html", "0");
}
void WiFiconnect() {
Serial.begin(115200);
Serial.println();
Serial.println("Starting WiFi...");
WiFi.mode(WIFI_STA); //STA
WiFi.begin(ssids, passwords);
if (WiFi.waitForConnectResult() == WL_CONNECTED) {
WiFi.config(ip,gateway,subnet);
Serial.println("WiFi erfolgreich verbunden...");
Serial.print("Verbunden mit ");
Serial.println(ssids);
Serial.print("IP address: "); // Aktuelle IP des ESP8266-servers zeigen
Serial.println(WiFi.localIP());
}
else {
// WiFi Setup
Serial.println("Stationmode failed!");
Serial.println("Starting Accesspoint...");
WiFi.mode(WIFI_AP); // Für Server und Client WIFI_AP_STA
WiFi.softAP(ssid,password);
WiFi.softAPConfig(ip, gateway, subnet);
// Verbindung gestartet
Serial.printf("Accesspoint unter dem Namen ");
Serial.println(ssid);
Serial.print("IP-Addresse: "); // Aktuelle IP des ESP8266-servers zeigen
Serial.println(WiFi.softAPIP());
Serial.print("Mac-Addresse: "); // Mac Adresse zeigen
Serial.println(WiFi.softAPmacAddress());
}
}
I hope you can help me. Thank you very much in advance.
Greetings Daniel