uploading multiple fields to thingspeak from arduino | Arduino | Forum


Please consider registering


— Forum Scope —

— Match —

— Forum Options —

Minimum search word length is 3 characters - maximum search word length is 84 characters

Register Lost password?
sp_Feed sp_TopicIcon
uploading multiple fields to thingspeak from arduino
New Member
Forum Posts: 4
sp_UserOfflineSmall Offline
January 30, 2018 - 8:59 am
sp_Permalink sp_Print

Hi all,


i've come slightly unstuck attempting to send data to thingspeak, and was hoping someone with a better knowledge my be able to point me in the right direction.

I'm attempting to send pressure and temperature information collected using a MS5803-14(and later electrical conductivity), and I have been using the write multiple voltage example as a basis.

I was trying to use ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey); to update multiple fields at once. However, when multiple fields have been set using ThingSpeak.setField(1,pressure); nothing is written to thing speak.

The strange element is that if I comment out one of the setField lines, the data will upload normally. This works if I comment out either of the factors i'm trying to upload.


Additionally if I use ThingSpeak.writeField(myChannelNumber, 1, pressure, myWriteAPIKey); with a delay followed by

ThingSpeak.writeField(myChannelNumber, 2, temperature, myWriteAPIKey);

the data will also upload.

the arduino is obviously calculating the data correctly as well, as values will print to serial.

its only in the combination of the data that thinspeak stops receiving the data.


Many thanks


#include "ThingSpeak.h"

#include <OneWire.h>
#include <Wire.h>
#include <MS5803_14.h>




#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
EthernetClient client;


MS_5803 sensor = MS_5803(4096);
float pressure;
float temperature;


unsigned long myChannelNumber = XXXXXXXX;
const char * myWriteAPIKey = "XXXXXXXXXXX";

void setup() {
Serial.begin (9600);







void loop() {


pressure = sensor.pressure();
temperature = sensor.temperature();


ThingSpeak.setField( 1, (float) pressure);
ThingSpeak.setField( 2, (float) temperature);
ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);

delay(20000); // ThingSpeak will only accept updates every 15 seconds.

Forum Posts: 158
sp_UserOfflineSmall Offline
January 31, 2018 - 9:52 am
sp_Permalink sp_Print

Have you downloaded the channel data to make sure its not a scaling problem and your data it updating but you don't see it?  Does the number of entries change after a post, even if you don't see that data?

Your code looks fine to me, but you might want to remove the cast to float in the .setField command.  

ThingSpeak.setField( 1, (float) pressure);


ThingSpeak.setField( 1, pressure);

If that still doesn't work, you could consider converting your variables to a string before uploading it.  ThingSpeak will still interpret the string as a float for plotting as long at there aren't any other characters in the string (like # or ') 

ThingSpeak.setField( 1, String(pressure));

But that method has all the extra problems of bringing along the string class.

One other thing to try is to output pressure and temperature variables to the serial monitor before you write to ThingSpeak just to make sure they read correctly.

Let us know if any that works.  If it doesn't, you can update multiple fields without the library, though its a bit harder.

New Member
Forum Posts: 4
sp_UserOfflineSmall Offline
January 31, 2018 - 11:51 am
sp_Permalink sp_Print

Thanks for looking at it, I'm not going to be able to have a look for a couple of days but I'll update then.

Off the top of my head, I think that nothing being added, they  number of entries was not increasing (but i'll double check this) and I don't think the float setfield command would be causing the issue, as if one of the two lines of setfield was commented out the data would then upload for the other field. 


Anyway, i'll update soon.


thanks again for your help

New Member
Forum Posts: 4
sp_UserOfflineSmall Offline
February 2, 2018 - 7:09 am
sp_Permalink sp_Print

just to update:


It was posting, just with no values.

Converting to a string as suggested worked.


Thanks very much!

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online:
36 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 252

Vinod: 164

cstapels: 96

piajola: 75

vespapierre: 63

Adarsh_Murthy: 59

Newest Members:







Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565


Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Administrators: Hans, lee