Hallo an alle,
ich versuch seit Tagen mittels ESP8266 Daten an ThingSpeak zu senden. Es geht auch überall nur nicht dort wo es soll. Habe es mittlerweile mit 5 verschiedene WLAN-Router probiert alle außer die T-Mobile LTE-BOX senden die Daten problemlos.
//-------------------------------------------------------------------
// Following function setup the esp8266, put it in station made and
// connect to wifi access point.
//------------------------------------------------------------------
void setupEsp8266()
{
if(DEBUG){
Serial.println(F("Reseting esp8266"));
}
esp8266Module.flush();
esp8266Module.println(F("AT+RST"));
delay(7000);
if (esp8266Module.find("OK"))
{
if(DEBUG){
Serial.println(F("Found OK"));
Serial.println(F("Changing espmode"));
}
esp8266Module.flush();
changingMode();
delay(5000);
esp8266Module.flush();
connectToWiFi();
}
else
{
if(DEBUG){
Serial.println(F("OK not found"));
}
}
}
//-------------------------------------------------------------------
// Following function sets esp8266 to station mode
//-------------------------------------------------------------------
bool changingMode()
{
esp8266Module.println(F("AT+CWMODE=1"));
if (esp8266Module.find("OK"))
{
if(DEBUG){
Serial.println(F("Mode changed"));
}
return true;
}
else if(esp8266Module.find("NO CHANGE")){
if(DEBUG){
Serial.println(F("Already in mode 1"));
}
return true;
}
else
{
if(DEBUG){
Serial.println(F("Error while changing mode"));
}
return false;
}
}
//-------------------------------------------------------------------
// Following function connects esp8266 to wifi access point
//-------------------------------------------------------------------
bool connectToWiFi()
{
if(DEBUG){
Serial.println(F("inside connectToWiFi"));
}
String cmd = F("AT+CWJAP=\"");
cmd += network;
cmd += F("\",\"");
cmd += password;
cmd += F("\"");
esp8266Module.println(cmd);
delay(15000);
if (esp8266Module.find("OK"))
{
if(DEBUG){
Serial.println(F("Connected to Access Point"));
}
return true;
}
else
{
if(DEBUG){
Serial.println(F("Could not connect to Access Point"));
}
return false;
}
}
//-------------------------------------------------------------------
// Following function sends sensor data to thingspeak.com
//-------------------------------------------------------------------
void updateTemp(String voltage1,String voltage2,String voltage3,String voltage4,String voltage5,String voltage6)
{
String cmd = "AT+CIPSTART=\"TCP\",\"";
cmd += IP;
cmd += "\",80";
esp8266Module.println(cmd);
delay(5000);
if(esp8266Module.find("Error")){
if(DEBUG){
Serial.println(F("ERROR while SENDING"));
}
return;
}
cmd = GET + "&field1=" + voltage1 + "&field2=" + voltage2 + "&field3=" + voltage3 + "&field4=" + voltage4 + "&field5=" + voltage5 + "&field6=" + voltage6 + "\r\n";
esp8266Module.print("AT+CIPSEND=");
esp8266Module.println(cmd.length());
delay(15000);
if(esp8266Module.find(">"))
{
esp8266Module.print(cmd);
if(DEBUG){
Serial.println(F("Data sent"));
}
}else
{
esp8266Module.println("AT+CIPCLOSE");
if(DEBUG){
Serial.println(F("Connection closed"));
}
}
}
Der Code ist jetzt auch nichts besonderes da alles per AT-Befele gesendet wird.
Hab das ganze auch schon per ESP8266 01 und USB TTL Modul im Serial Monitor getestet. Die Verbindung zur LTE-Box ist OK. Sobald es um das Senden der Daten geht ist irgendwo "der Hund begraben"
Hab auch schon an die Verschlüsselung der LTE-Box gedacht und folgende Einstellung (an der LTE-Box) ohne Erfolg probiert:
- WPA/WPA2
- WPA
- WPA2
- keine Verschlüsselung
Ich hoffe jemand von euch hat noch ne Idee was