ThingSpeak Community
Things Speak will sometimes not update the fields (Feather Fona)
最新活动 由 Christopher Stapels
回复于 2022-12-20
Hello!
The fields sometimes will update most of the times but not always. The Serial monitor shows the following output when it does not update:

while when it update it shows the following:

There is no issue with the update rate since it is more than 15 seconds.
Iam using a feather fona and the chunk of the code Iam using to send the data is the following:
if (gprsSerial.available())
Serial.write(gprsSerial.read());
gprsSerial.println("AT");
delay(1000);
gprsSerial.println("AT+CPIN?");
delay(1000);
gprsSerial.println("AT+CREG?");
delay(1000);
gprsSerial.println("AT+CGATT?");
delay(1000);
gprsSerial.println("AT+CIPSHUT");
delay(1000);
gprsSerial.println("AT+CIPSTATUS");
delay(2000);
gprsSerial.println("AT+CIPMUX=0");
delay(2000);
ShowSerialData();
gprsSerial.println("AT+CSTT=\"internet\"");//start task and setting the APN,
delay(1000);
ShowSerialData();
gprsSerial.println("AT+CIICR");//bring up wireless connection
delay(3000);
ShowSerialData();
gprsSerial.println("AT+CIFSR");//get local IP adress
delay(2000);
ShowSerialData();
gprsSerial.println("AT+CIPSPRT=0");
delay(3000);
ShowSerialData();
gprsSerial.println("AT+CIPSTART=\"TCP\",\"api.thingspeak.com\",\"80\"");//start up the connection
delay(6000);
ShowSerialData();
gprsSerial.println("AT+CIPSEND");//begin send data to remote server
delay(8000);
ShowSerialData();
delay(4000);
gprsSerial.println(str3);//begin send data to remote server
delay(8000);
ShowSerialData();
delay(6000);
gprsSerial.println((char)26);//sending
delay(6000);//waitting for reply, important! the time is base on the condition of internet
gprsSerial.println();
ShowSerialData();
gprsSerial.println("AT+CIPSHUT");//close the connection
delay(3000);
ShowSerialData();
delay(3000);
}
Thank you in advance!
7 个评论
My guess is that your device is disconnecting before the server sends a response. Lookng at your code however, you have quite long delays built it. It may also be possible that your device is disconnecting while its waiting for you to do something. I would condsider using loops where you check the time (perhaps with millis()) and consider using yield instead of delay, or even reducing the delay slightly to give the device time to take action. (maybe 1 second instead of 6)
Also, this comment makes me wonder if your connection is poor:
delay(6000);//waitting for reply, important! the time is base on the condition of internet