0

I am using arduino and ethernet shield with ThingSpeak library to write multi fields. this sample code from docs. it is working good with 4 fields but if I want to write 8 fields in a same time such as:

  // set the fields with the values
  ThingSpeak.setField(1, number1);
  ThingSpeak.setField(2, number2);
  ThingSpeak.setField(3, number3);
  ThingSpeak.setField(4, number4);
  ThingSpeak.setField(5, number5);
  ThingSpeak.setField(6, number6);
  ThingSpeak.setField(7, number7);
  ThingSpeak.setField(8, number8);


  // write to the ThingSpeak channel 
  int x = ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
  if(x == 200){
    Serial.println("Channel update successful.");
  }
  else{
    Serial.println("Problem updating channel. HTTP error code " + String(x));
  }

It gives these errors

Problem updating channel. HTTP error code -301

or

Problem updating channel. HTTP error code -302

How can I write 8 fields in successfully?

  • It might be useful to see where thingspeak tries to redirect you to (as 30x are redirects, where the Location header is the new url). It might be an error page explaining what went wrong. What happens if you only set 5 fields? 6 fields? When doesn't it break. – Gerben Mar 7 at 19:32
  • 1
    Might have run out of memory (SRAM). Only 2K byte on the Arduino Uno and that is for stack and heap. There is a lot of String copy constructors used in the library. – Mikael Patel Mar 7 at 19:41
  • @MikaelPatel So I should try sending at first only 1-4 fields and after delay 20 secs, sending 5-8 fields. or I should buy arduino Mega. isnt it? – mehmet Mar 8 at 3:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.