Update multiple fields with one write | ThingSpeak API | Forum

Avatar

Please consider registering
Guest

Search

— 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
Update multiple fields with one write
Avatar
tina.mir
New Member
Forum Posts: 2
sp_UserOfflineSmall Offline
1
June 21, 2017 - 3:01 pm
sp_Permalink sp_Print

Hello Everyone,

 

I am pretty new in arduino and thingSpeak. The project that I am currently working on is to collect Temperature and Humidity using Arduino Uno and DH11 and transfer both values into a channel at ThingSpeak using SIM900 (GPRS communication).

I was able to transfer one parameter (either Temperature or Humidity) . Could anyone help and show me how is this possible to update multiple fields with one write using the following command:

String str2="GET https://api.thingspeak.com/update?api_key=Write API KEY &field2=0" + String(humi);

I have search a lot but all examples are either for Ethernet Shield or not working properly.

 

Thanks, 

Avatar
tina.mir
New Member
Forum Posts: 2
sp_UserOfflineSmall Offline
2
June 22, 2017 - 8:34 am
sp_Permalink sp_Print

Never mind, I found the solution:Cool

In the function you have to define all parameters you are willing to send:

int temperature = dht.readTemperature();
int humidity = dht.readHumidity();

And then use the following command:

String str="GET https://api.thingspeak.com/update?api_key=writeAPIkey&field1=" + String(temperature)+"&field2=" +String(humidity);

(substitute "writeAPIkey" with your channel's)

Avatar
Aitorto8
New Member
Forum Posts: 2
sp_UserOfflineSmall Offline
3
July 4, 2017 - 8:45 am
sp_Permalink sp_Print

Hi!

Could you share your code with us? I'm working on the same project and I have some problems with the sketch.

Thank you.Laugh

Avatar
melanogaster

Silver
Forum Posts: 5
sp_UserOfflineSmall Offline
4
July 4, 2017 - 4:20 pm
sp_Permalink sp_Print

Aitorto8 said
Hi!

Could you share your code with us? I'm working on the same project and I have some problems with the sketch.

Thank you.Laugh  

//"Update a Channel Feed" https://de.mathworks.com/help/thingspeak/update-channel-feed.html

#include <WiFi.h>

//WIFI Stuff

const char* ssid = "XXXXX";

const char* pwd = "XXXXX";

WiFiClient Client;

//Thingspeak Stuff

String channelID = "XXXXX";

String apiKeyChannel = "XXXXXXXXXXXXXXXXX";

String apiKeyUser = "XXXXXXXXXXXXXXXXX";

const char* server = "api.thingspeak.com";

void setup() {

//WIFI Connection

WiFi.begin(ssid, pwd);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println("");
Serial.println("WiFi Connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());

}

void loop() {

if (millis() - thingspeakPreviousTime >= 20000 && client.connect(server,80)) { // "184.106.153.149" or api.thingspeak.com
thingspeakPreviousTime = millis();

String str_sensor = "12345";

String str_sensor2 = "67890";

String postStr = "api_key="+apiKeyChannel+"&field1="+str_sensor+"&field2="+str_sensor2;

client.println("POST /update HTTP/1.1");

client.println("Host: api.thingspeak.com");

client.println("Connection: close");

client.println("Content-Type: application/x-www-form-urlencoded");

client.print("Content-Length: ");

client.println(postStr.length());

client.println();

client.print(postStr);

}

client.stop();

}

Avatar
assignmenthelpexperts
New Member
Forum Posts: 1
sp_UserOfflineSmall Offline
5
July 27, 2017 - 2:11 am
sp_Permalink sp_Print
thingSpeakPlot(timeStamps,dewPointData,'xlabel','TimeStamps',...
    'ylabel','Measured Values','title','Dew Point Measurement',...
    'Legend',{'Temperature','Humidity','Dew Point'},'grid','on');
Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online: jacktheripper125, pudderz
24 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:

bbruno22

pudderz

Utkya

Poornak26

LindasHed

reddysiva

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

 

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Administrators: Hans, lee