Thingspeak update with error code 211 from Arduinos

7 visualizzazioni (ultimi 30 giorni)
Hello, I have been encountering several times a day for a few weeks an error when updating my data stored on Thingspeak (computerized hive parameters).
The return code of my Arduinos is 211!
But I can't find the meaning of this code anywhere...
Does anyone know more?
Here is one of my hives: https://thingspeak.mathworks.com/channels/1289244
Thanks
PS: The update continues to be done but it seems to be missing points (those that return the error 211)
  2 Commenti
Vinod
Vinod il 27 Gen 2025

The 211 is the HTTP status code returned from the server. I can't say why you're getting that without knowing the sketch.

Can you share the snippet of code that sets up the connection to ThingSpeak? Specifically what address is being used to connect to the ThingSpeak API server?

Vinod
Vinod il 27 Gen 2025

It will also be useful to know when you started to see this, given your channel is many years old, and what might have changed on your end around the time you noticed the issue.

Accedi per commentare.

Risposte (9)

Gilles
Gilles il 11 Feb 2025
Hello, I have just finished putting my test hive (hive 6) back into service. It currently does not update my server but it updates Thingspeak on the public channel 2159981.
I put the same program as my other hives: I would like to be sure to be able to reproduce the error code 211 before any modifications... If necessary I would create a test hive in my server in case the error code does not occur!
You can access my server from the following address:
https://gilles54.no-ip.info:9443/
Thank you

Gilles Mangin-Voirin
Gilles Mangin-Voirin il 27 Gen 2025
Hello, thank you for your interest in my problem.
Here is what you asked me (extract from my hive program)
I have "normally" not changed anything in my Thingspeak update chain...
Can you tell me what you call the address to connect to the ThingSpeak API server?
Thank you
void thingspeak(float t, float h, float units, int lum, float TempInt, byte eau)
{
unsigned long myChannelNumber= 00000000;
const char * myWriteAPIKey= "XYZ";
/* sets Thingspeak fields with data */
ThingSpeak.setField(1, t); // assigns the value of field 1 to the outside temperature
ThingSpeak.setField(2, h); // assigns the value of field 2 to the outdoor humidity
ThingSpeak.setField(3, units); // assigns the value of field 3 to the weight
if (PresenceCapteurLuminosite == 1 ){ThingSpeak.setField(4, lum);} // assigns the value of field 4 to the exterior brightness
if (PresenceCapteurTemperatureInterieure == 1 ) {ThingSpeak.setField(5,TempInt);} // assigns the value of field 6 to the indoor temperature
if ( PresenceCapteurPluie == 1 ) {ThingSpeak.setField(6, eau); } // assigns the value of field 6 to rain
ThingSpeak.setStatus(F("Update 2 successful!")); // assigns the Status field with the message Update successful:
/* writing fields in ThingSpeak */
int x = ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey); // we actually write the pre-filled fields above
ecritureJdB(rtc.now(), "We are in ThingSpeak:",'0', x , "=return code"); // send to the log writing function on the SD
Serial.print(F("return code things: "));
Serial.println(x);
if(x == 200)
{ // if it went well
reboot = 0; //we have an internet connection so we reinitialize reboot
} // end of ThingSpeak update error step
else {err(6,x); } // if error we go to the error management function
} // end of ThingSpeak function
/* the error code handling function is: */
void err(byte code, byte x)
{
char tY[5]; // character array for outdoor temperature conversion
String tY1; // character string for outdoor temperature conversion
char hygY[5]; // character array for hygrometry conversion
String hygY1; // character string for hygrometry conversion
switch (code)
{
case 6 :{
reboot = reboot + 1; // we store a non-update
testconnexion(); // we test the internet connection via google
CompteAlertServT = CompteAlertServT + 1; // we increment to trigger the sending of a daily email to report the ThingSpeak update problem
if (AlerteThingSpeak == 1 && OKThingSpeak == 0 && CompteAlertServT >= NbAvantAlerteServeur)
{
envoimail(rtc.now(),11,String(x),nbessai); // send the daily email on the malfunction
if (soustraitancemail == 1)
{
FTPMoi(0); // send to the FTP server
}
if (retourmail == 0)
{
OKThingSpeak = 1; CompteAlertServT = 0;
} // if the email sending went well, we set it to send only once a day
}
ecritureJdB(rtc.now(), "retourmail = ",retourmail, OKThingSpeak , " = OKThingSpeak"); // send to the function for writing the logbook on the SD
commentaires = F("Pb ThingSpeak");
break; // we exit!
} // end of error code 6
}
}
/* and the error management that sends me an alert email after 5 failures per day is: */
/* Email sending function */
boolean envoimail(DateTime now,char quel,String NomFichierMonsuel,int nbessai)
{ //nomfichier mensuel contains either the IP address or the name of the monthly file to send depending on the needs...
EMailSender::EMailMessage message; // structure defined in EmailSender.h
/* Definition of email recipients*/
const char* arrayOfEmail[] = {"mail@laposte.net","mail@gmail.com","rolande.mangin@wanadoo.fr","messagerie@orange.fr" }; // email address of your recipients
byte nb_Destinaire_Mail=3; // number of recipients of the mails (count the email addresses of the line above!
String msgsujet1 = F("Hi, this is hive No. "); // assign a default value
String msgcorps1 = F("Hello, this is hive No. "); // assign a default value
String msgcorps6 = F("<br> Sending mail of the day on ");
String msgcorps7 = F(" H");
String msgcorps8 = F(" Mn");
String msgcorps9 = F(" s.");
String msgcorps10 = F(" to ");
switch (which one)
{ // test to know which email to send
case 11 :
{ // send message pb updating ThingSpeak...
piecejointe = 0;
String msgsujet2 = F(". There is a problem updating ThingSpeak");
message.subject = msgsujet1 + numRuche + msgsujet2;
String msgcorps2 = F(".<br>The error code of ThingSpeak is: ");
String msgcorps3 = F(".<br>A problem updating ThingSpeak occurred today!<br> We must check if it is just a fleeting problem or if the problem is long-lasting.");
message.message = msgcorps1 + numRuche + msgcorps2 + NomFichierMonsuel + msgcorps3 + msgcorps6 + now.day() + msgcorps10
+ now.hour() + msgcorps7 + now.minute() + msgcorps8 +now.second() + msgcorps9 ; // here I use nomfichiermensuel to transmit the return error code of ThingSpeak
break;
} // we exit the test
}
......
}
  8 Commenti
Gilles Mangin-Voirin
Gilles Mangin-Voirin il 5 Feb 2025
Hello, on February 4, 25 between 0 and 5 errors (email alert not received so less than 6 errors) for the 5 hives. But today alert email for the 5 hives between 2:12 p.m. and 8:13 p.m....
Thanks
Vinod
Vinod il 7 Feb 2025

There have been no changes on the ThingSpeak server side in over a week. There have been no other reports like this from other users either. If there has been no change on the device end, we might have to consider something in the connectivity later - i.e., your Internet provider or router. Any changes in that?

Accedi per commentare.


Gilles Mangin-Voirin
Gilles Mangin-Voirin il 7 Feb 2025
No change of internet service provider, nor cabling, nor box,... The connection works very well at the level of sending my emails (FTP and Email Senders) the update of my personal server (on raspberry) also works well (every 4 minutes)...
And that does not explain the error code 211 either... it is indeed a return value from ThingSpeak...
Thanks
  3 Commenti
Gilles Mangin-Voirin
Gilles Mangin-Voirin il 8 Feb 2025
Hello, I need FTP because otherwise no more emails, no more updates to my server...
AND this version of the Arduino program has been in place since the beginning of 2024 and I have only had these errors for a maximum of 1 month, roughly since 2025...
Thanks
Vinod
Vinod il 10 Feb 2025

Can you try inserting some ethernet.flush() immediately after you send any data over FTP? I think that will point us in the right direction.

Accedi per commentare.


Gilles
Gilles il 10 Feb 2025
yes I can do that, and but in the return of the function:
int x = ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
x is a local variable of the thingspeak update function (not a global variable...)
I will tonight or tomorrow go back to my development hive in my office and see while connected to a portal PC on the serial monitor if I already get the same errors...
I will get back to you as soon as this is done
Thanks
PS: I have a specific Thingspeak channel for this test model...
  1 Commento
Vinod
Vinod il 10 Feb 2025
Modificato: Vinod il 10 Feb 2025
Thank you. I suspect that the network stack is unintentionally crossing information between requests. An FTP request's response is being used by the method inside writeFields() to get the status code. Calling a flush() should commit the network stack and prevent this.

Accedi per commentare.


Gilles
Gilles il 12 Feb 2025
Hello, I have just finished putting my test hive (hive 6) back into service. It currently does not update my server but it updates Thingspeak on the public channel 2159981.
I put the same program as my other hives: I would like to be sure to be able to reproduce the error code 211 before any modifications... If necessary I would create a test hive in my server in case the error code does not occur!
You can access my server from the following address:
https://gilles54.no-ip.info:9443/
Thank you
  3 Commenti
Gilles
Gilles il 13 Feb 2025
Hello, yes indeed since the reactivation of my hive 6 on channel 2159981 no worries only codes 200! But currently I no longer receive alerts on my other channels either (in any case less than 6 errors per 24 hours... since no more alert emails.
I give you a real channel that led me to contact you about this error: 1633674.
I tried to create it myself by pasting your code into the page:
https://thingspeak.mathworks.com/apps/matlab_analyses/360798/edit
but I get an error:
Cannot use MATLAB visualization code 'plot(t(2:end), medfilt1(seconds(diff(t)),1))' in the MATLAB Analysis app. You must create a <a target='_blank' rel="nofollow noopener noreferrer" href='/apps/matlab_visualizations/templates'>MATLAB Visualization</a>.
I was not able (I am new to math lab) to create the template of visualization...
Thanks
Vinod
Vinod il 13 Feb 2025
You can click the "Open in MATLAB Online" button above and execute the code directly in MATLAB.

Accedi per commentare.


Gilles
Gilles il 14 Feb 2025
Hello, I put your expression in matlab basic, we extract the data from the chain over the last 2 days but it does not display if there were error codes (211 or 208...). You have to manually check if we have a regular update of the chain...
And for several days no more errors on my 5 hives in operation....
I continue my research I will go update my hive 5 with a new sketch of error tracking log... It works well on my test hive!
A+
Thanks

Gilles
Gilles il 18 Feb 2025
Hello, I finally found the origin of error 211 which is actually a -301 error....
This error does not occur often at the moment so I had trouble tracking it down.
I modified a few days ago my hive 5 (operational) and the test hive 6 both sent me around 1:20-1:21 (French time) an error code -301 (which appeared as error code 211 in my emails because my error management and mail sending function converted the integer into a byte... (programming error on my part, sorry)
However I did not find an error code -301 on the list of possible errors of ThingSpeak!
Thanks
  14 Commenti
Gilles
Gilles il 23 Feb 2025
Hello in my error tracking this time I had a code -304 (Timeout waiting for server to respond) on my test hive on 05/23/25 at 3:56 a.m. French time....
A+
Vinod
Vinod il 26 Feb 2025
A 304 means the value is the same as it was last time it was requested. This typically happens when the device may be updating the channel at a rate higher than allowed and intermediate values are dropped until the next time the channel is eligible to be updated, OR, latency in the internet resulted in two writes, though being sent at appropriate intervals, are actually only hitting the server very close to each other, making it appear at the server as them exceeding the rate limit. I think it is safe to ignore this unless it happens very frequently.

Accedi per commentare.


Gilles
Gilles il 26 Feb 2025
Hello, yesterday 02/25/25 I had a lot of -301 errors on all my hives, so my test hive too.
So I have on this hive a specific Ethernet client for ThingSpeak, I detected 10 -301 errors between 9:44 p.m. and 11:16 p.m. (French time)
When this error occurred I stopped the Thingspeak client, waited 1 second then tried to rewrite the ThingSpeak fields on the 10 errors.
Only 3 returned a 200 code after stopping and restarting the ThingSpeak client (is this due to chance or to this action?...)
Sometimes between 2 failures I had an OK update normally then an error again, this gives this:
9:44 p.m. -301, reset then -301
9:51 p.m. -301, reset then -301
9:56 p.m. 200
10:02 p.m. -301, reset then -301
10:07 p.m. -301, reset then -301
22:13 -301, reset then -301
22:15 200
22:24 200
22:29 200
22:34 -301, reset then 200
22:55 -301, reset then -301
23:00 -301, reset then -301
23:06 200
23:11 -301, reset then 200
23:16 -301, reset then 200
the rest all OK (200)
What do you think?
Knowing that my 5 operational hives presented the same update problem at the same times...
Thanks

Gilles
Gilles il 10 Mar 2025
Hello, I finally (or unfortunately) got an error code -301 on my test hive today at 6:49 PM
10/3/2025 6:43:53 PM 7, 200, =ThingSpeak return code
6, 10/3/2025 6:49:10 PM 7, -301, =ThingSpeak return code
6, 10/3/2025 6:49:26 PM 7, -301, We just reset ThingSpeak
6, 10/3/2025 6:49:43 PM 7, -301, We just reset ThingSpeak
6, 10/3/2025 6:49:59 PM 7, -301, We just reset ThingSpeak
6, 10/3/2025 18:50:15 7, -301, We just reinitialized ThingSpeak
6, 10/3/2025 18:56:10 7, 200, =ThingSpeak return code
When the error -301 appears even stopping the client dedicated to ThingSpeak, waiting a second and then trying again does not seem to change anything...
Thanks
  2 Commenti
Vinod
Vinod il 10 Mar 2025
Modificato: Vinod il 10 Mar 2025
Did it autoresolve on its own? if not, what did you need to do to resolve it? Did all your hives see a 301, or just a few?
Gilles
Gilles il 10 Mar 2025
Only hives 1, 2 and 6 hive 4 nothing this month. 3 and 5 nothing today.
The problem solves itself later (but not by cutting and the client dedicated to ThingSpak, see logbook extract of hive 6 in the previous message)
They are all on the same ethernet network.

Accedi per commentare.

Community

Più risposte nel  ThingSpeak Community

Categorie

Scopri di più su Read Data from Channel in Help Center e File Exchange

Prodotti

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by