2:41 pm

August 30, 2020

I use esp32 and two sensors. The esp32 wakes up from deep sleep every 2 minutes and updates 2 channels using ThingSpeak lib. I keep have erratic updating problems, i.e. one or more successful updates followed by one or more -304 error codes, then good again and bad again...it's been going on for for 2 days without any apparent pattern or cause. Below is the relevant arduino codes:
ThingSpeak.begin(client);
ThingSpeak.setField(1, f1);
ThingSpeak.setField(2, f2);
httpError = ThingSpeak.writeFields(CHANNEL_ID, CHANNEL_API_KEY);
if(httpError == 200){
Serial.println("Data sent successful. " + String(httpError));
}else{
Serial.println("Problem updating channel. HTTP error code " + String(httpError));
}
delay(15500);//free account data rate 1/15 seconds
ThingSpeak.setField(3, httpError); //previous thingspeak return code
//ThingSpeak.setField(4, NoWifiCount);
httpError = ThingSpeak.writeFields(CHANNEL_ID, CHANNEL_API_KEY);
if(httpError == 200){
Serial.println("Channel udate successful. " + String(httpError));
}else{
Serial.println("Problem updating channel. HTTP error code " + String(httpError));
}
2:26 pm


Moderators
March 7, 2017

From the library doc -304 means the server timed out waiting for a reply. I think this means your network connection is insufficient. Can you try the same code on a different network, or move closer to the hub?
FYI, MATLAB answers is the preferred location for ThingSpeak Community support.
Most Users Ever Online: 166
Currently Online:
23 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
rw950431: 272
Vinod: 240
piajola: 95
turgo: 70
vespapierre: 63
Adarsh_Murthy: 62
Member Stats:
Guest Posters: 1
Members: 8665
Moderators: 1
Admins: 2
Forum Stats:
Groups: 3
Forums: 14
Topics: 1600
Posts: 5760
Newest Members:
estebanmateo93, mikewrite, onlinebusiness, winzy99, Zark_zeugan, StefanWiModerators: cstapels: 460
Administrators: Hans: 405, lee: 457