58 #define PARTICLE_PHOTON
59 #elif PLATFORM_ID == 0
64 #include "application.h"
65 #ifdef PARTICLE_PHOTON
66 extern char* dtoa(
double val,
unsigned char prec,
char *sout);
68 #include "string_convert.h"
72 extern char * itoa(
int a,
char* buffer,
unsigned char radix);
74 extern char *dtostrf (
double val,
signed char width,
unsigned char prec,
char *sout);
77 #ifdef ARDUINO_ARCH_AVR
81 #error Only Arduino Yun, Uno/Mega/Due with either Wired or wi-fi Ethernet shield, and Spark Core/Photon are supported.
85 #define THINGSPEAK_URL "api.thingspeak.com"
86 #define THINGSPEAK_IPADDRESS IPAddress(184,106,153,149)
87 #define THINGSPEAK_PORT_NUMBER 80
89 #ifdef ARDUINO_ARCH_AVR
90 #ifdef ARDUINO_AVR_YUN
91 #define TS_USER_AGENT "tslib-arduino/1.0 (arduino uno or mega)"
93 #define TS_USER_AGENT "tslib-arduino/1.0 (arduino yun)"
97 #define TS_USER_AGENT "tslib-arduino/1.0 (particle core or photon)"
98 #define SPARK_PUBLISH_TTL 60 // Spark "time to live" for published messages
99 #define SPARK_PUBLISH_TOPIC "thingspeak-debug"
102 #define FIELDNUM_MIN 1
103 #define FIELDNUM_MAX 8
104 #define FIELDLENGTH_MAX 255 // Max length for a field in ThingSpeak is 255 bytes (UTF-8)
106 #define TIMEOUT_MS_SERVERRESPONSE 5000 // Wait up to five seconds for server to respond
108 #define OK_SUCCESS 200 // OK / Success
109 #define ERR_BADAPIKEY 400 // Incorrect API key (or invalid ThingSpeak server address)
110 #define ERR_BADURL 404 // Incorrect API key (or invalid ThingSpeak server address)
111 #define ERR_OUT_OF_RANGE -101 // Value is out of range or string is too long (> 255 bytes)
112 #define ERR_INVALID_FIELD_NUM -201 // Invalid field number specified
113 #define ERR_SETFIELD_NOT_CALLED -210 // setField() was not called before writeFields()
114 #define ERR_CONNECT_FAILED -301 // Failed to connect to ThingSpeak
115 #define ERR_UNEXPECTED_FAIL -302 // Unexpected failure during write to ThingSpeak
116 #define ERR_BAD_RESPONSE -303 // Unable to parse response
117 #define ERR_TIMEOUT -304 // Timeout waiting for server to respond
118 #define ERR_NOT_INSERTED -401 // Point was not inserted (most probable cause is the rate limit of once every 15 seconds)
129 this->lastReadStatus = OK_SUCCESS;
153 bool begin(Client & client,
const char * customHostName,
unsigned int port)
155 #ifdef PRINT_DEBUG_MESSAGES
156 Serial.print(
"ts::tsBegin (client: Client URL: "); Serial.print(customHostName); Serial.println(
")");
158 this->setClient(&client);
159 this->setServer(customHostName, port);
161 this->lastReadStatus = OK_SUCCESS;
186 bool begin(Client & client, IPAddress customIP,
unsigned int port)
188 #ifdef PRINT_DEBUG_MESSAGES
189 Serial.print(
"ts::tsBegin (client: Client IP: "); Serial.print(customIP); Serial.println(
")");
191 this->setClient(&client);
192 this->setServer(customIP, port);
194 this->lastReadStatus = OK_SUCCESS;
219 #ifdef PRINT_DEBUG_MESSAGES
220 Serial.print(
"ts::tsBegin");
222 this->setClient(&client);
225 this->lastReadStatus = OK_SUCCESS;
245 int writeField(
unsigned long channelNumber,
unsigned int field,
int value,
const char * writeAPIKey)
249 return writeField(channelNumber, field, (
long)value, writeAPIKey);
251 char valueString[10];
252 itoa(value, valueString, 10);
253 return writeField(channelNumber, field, valueString, writeAPIKey);
273 int writeField(
unsigned long channelNumber,
unsigned int field,
long value,
const char * writeAPIKey)
275 char valueString[15];
276 ltoa(value, valueString, 10);
277 return writeField(channelNumber, field, valueString, writeAPIKey);
297 int writeField(
unsigned long channelNumber,
unsigned int field,
float value,
const char * writeAPIKey)
299 #ifdef PRINT_DEBUG_MESSAGES
300 Serial.print(
"ts::writeField (channelNumber: "); Serial.print(channelNumber); Serial.print(
" writeAPIKey: "); Serial.print(writeAPIKey); Serial.print(
" field: "); Serial.print(field); Serial.print(
" value: "); Serial.print(value,5); Serial.println(
")");
302 char valueString[20];
303 int status = convertFloatToChar(value, valueString);
304 if(status != OK_SUCCESS)
return status;
306 return writeField(channelNumber, field, valueString, writeAPIKey);
330 int writeField(
unsigned long channelNumber,
unsigned int field,
const char * value,
const char * writeAPIKey)
332 return writeField(channelNumber, field, String(value), writeAPIKey);
359 int writeField(
unsigned long channelNumber,
unsigned int field, String value,
const char * writeAPIKey)
362 if(field < FIELDNUM_MIN || field > FIELDNUM_MAX)
return ERR_INVALID_FIELD_NUM;
364 if(value.length() > FIELDLENGTH_MAX)
return ERR_OUT_OF_RANGE;
366 #ifdef PRINT_DEBUG_MESSAGES
368 Spark.publish(SPARK_PUBLISH_TOPIC,
"writeField (" + String(channelNumber) +
", " + String(writeAPIKey) +
", " + String(field) +
", " + String(value) +
")", SPARK_PUBLISH_TTL, PRIVATE);
370 Serial.print(
"ts::writeField (channelNumber: "); Serial.print(channelNumber); Serial.print(
" writeAPIKey: "); Serial.print(writeAPIKey); Serial.print(
" field: "); Serial.print(field); Serial.print(
" value: \""); Serial.print(value); Serial.println(
"\")");
373 String postMessage = String(
"field") + String(field) +
"=" + value;
374 return writeRaw(channelNumber, postMessage, writeAPIKey);
413 return setField(field, (
long)value);
415 char valueString[10];
416 itoa(value, valueString, 10);
418 return setField(field, valueString);
455 char valueString[15];
456 ltoa(value, valueString, 10);
457 return setField(field, valueString);
494 char valueString[20];
495 int status = convertFloatToChar(value, valueString);
496 if(status != OK_SUCCESS)
return status;
498 return setField(field, valueString);
532 int setField(
unsigned int field,
const char * value)
534 return setField(field, String(value));
570 #ifdef PRINT_DEBUG_MESSAGES
572 Spark.publish(SPARK_PUBLISH_TOPIC,
"setField " + String(field) +
" to " + String(value), SPARK_PUBLISH_TTL, PRIVATE);
574 Serial.print(
"ts::setField (field: "); Serial.print(field); Serial.print(
" value: \""); Serial.print(value); Serial.println(
"\")");
577 if(field < FIELDNUM_MIN || field > FIELDNUM_MAX)
return ERR_INVALID_FIELD_NUM;
579 if(value.length() > FIELDLENGTH_MAX)
return ERR_OUT_OF_RANGE;
580 this->nextWriteField[field - 1] = value;
620 #ifdef PRINT_DEBUG_MESSAGES
621 Serial.print(
"ts::setLatitude(latitude: "); Serial.print(latitude,3); Serial.println(
"\")");
623 this->nextWriteLatitude = latitude;
663 #ifdef PRINT_DEBUG_MESSAGES
664 Serial.print(
"ts::setLongitude(longitude: "); Serial.print(longitude,3); Serial.println(
"\")");
666 this->nextWriteLongitude = longitude;
706 #ifdef PRINT_DEBUG_MESSAGES
707 Serial.print(
"ts::setElevation(elevation: "); Serial.print(elevation,3); Serial.println(
"\")");
709 this->nextWriteElevation = elevation;
748 int writeFields(
unsigned long channelNumber,
const char * writeAPIKey)
750 String postMessage = String(
"");
751 bool fFirstItem =
true;
752 for(
size_t iField = 0; iField < 8; iField++)
754 if(this->nextWriteField[iField].length() > 0)
758 postMessage = postMessage + String(
"&");
760 postMessage = postMessage + String(
"field") + String(iField + 1) + String(
"=") + this->nextWriteField[iField];
762 this->nextWriteField[iField] =
"";
766 if(!isnan(nextWriteLatitude))
770 postMessage = postMessage + String(
"&");
772 postMessage = postMessage + String(
"lat=") + String(this->nextWriteLatitude);
774 this->nextWriteLatitude = NAN;
777 if(!isnan(this->nextWriteLongitude))
781 postMessage = postMessage + String(
"&");
783 postMessage = postMessage + String(
"long=") + String(this->nextWriteLongitude);
785 this->nextWriteLongitude = NAN;
789 if(!isnan(this->nextWriteElevation))
793 postMessage = postMessage + String(
"&");
795 postMessage = postMessage + String(
"elevation=") + String(this->nextWriteElevation);
797 this->nextWriteElevation = NAN;
803 return ERR_SETFIELD_NOT_CALLED;
806 return writeRaw(channelNumber, postMessage, writeAPIKey);
830 int writeRaw(
unsigned long channelNumber,
const char * postMessage,
const char * writeAPIKey)
832 return writeRaw(channelNumber, String(postMessage), writeAPIKey);
851 int writeRaw(
unsigned long channelNumber, String postMessage,
const char * writeAPIKey)
853 #ifdef PRINT_DEBUG_MESSAGES
854 Serial.print(
"ts::writeRaw (channelNumber: "); Serial.print(channelNumber); Serial.print(
" writeAPIKey: "); Serial.print(writeAPIKey); Serial.print(
" postMessage: \""); Serial.print(postMessage); Serial.println(
"\")");
857 if(!connectThingSpeak())
860 return ERR_CONNECT_FAILED;
863 postMessage = postMessage + String(
"&headers=false");
865 #ifdef PRINT_DEBUG_MESSAGES
867 Spark.publish(SPARK_PUBLISH_TOPIC,
"Post " + postMessage, SPARK_PUBLISH_TTL, PRIVATE);
869 Serial.print(
" POST \"");Serial.print(postMessage);Serial.println(
"\"");
873 postMessage = postMessage + String(
"\n");
876 if(!this->client->print(
"POST /update HTTP/1.1\n"))
return abortWriteRaw();
877 if(!writeHTTPHeader(writeAPIKey))
return abortWriteRaw();
878 if(!this->client->print(
"Content-Type: application/x-www-form-urlencoded\n"))
return abortWriteRaw();
879 if(!this->client->print(
"Content-Length: "))
return abortWriteRaw();
880 if(!this->client->print(postMessage.length()))
return abortWriteRaw();
881 if(!this->client->print(
"\n\n"))
return abortWriteRaw();
882 if(!this->client->print(postMessage))
return abortWriteRaw();
884 String entryIDText = String();
885 int status = getHTTPResponse(entryIDText);
886 if(status != OK_SUCCESS)
891 long entryID = entryIDText.toInt();
893 #ifdef PRINT_DEBUG_MESSAGES
894 Serial.print(
" Entry ID \"");Serial.print(entryIDText);Serial.print(
"\" (");Serial.print(entryID);Serial.println(
")");
899 #ifdef PRINT_DEBUG_MESSAGES
900 Serial.println(
"disconnected.");
905 status = ERR_NOT_INSERTED;
925 String
readStringField(
unsigned long channelNumber,
unsigned int field,
const char * readAPIKey)
927 if(field < FIELDNUM_MIN || field > FIELDNUM_MAX)
929 this->lastReadStatus = ERR_INVALID_FIELD_NUM;
932 #ifdef PRINT_DEBUG_MESSAGES
933 Serial.print(
"ts::readStringField(channelNumber: "); Serial.print(channelNumber);
934 if(NULL != readAPIKey)
936 Serial.print(
" readAPIKey: "); Serial.print(readAPIKey);
938 Serial.print(
" field: "); Serial.print(field); Serial.println(
")");
940 return readRaw(channelNumber, String(String(
"/fields/") + String(field) + String(
"/last")), readAPIKey);
980 float readFloatField(
unsigned long channelNumber,
unsigned int field,
const char * readAPIKey)
982 return convertStringToFloat(
readStringField(channelNumber, field, readAPIKey));
1022 long readLongField(
unsigned long channelNumber,
unsigned int field,
const char * readAPIKey)
1065 int readIntField(
unsigned long channelNumber,
unsigned int field,
const char * readAPIKey)
1106 String
readRaw(
unsigned long channelNumber, String URLSuffix)
1108 return readRaw(channelNumber, URLSuffix, NULL);
1127 String
readRaw(
unsigned long channelNumber, String URLSuffix,
const char * readAPIKey)
1129 #ifdef PRINT_DEBUG_MESSAGES
1130 Serial.print(
"ts::readRaw (channelNumber: "); Serial.print(channelNumber);
1131 if(NULL != readAPIKey)
1133 Serial.print(
" readAPIKey: "); Serial.print(readAPIKey);
1135 Serial.print(
" URLSuffix: \""); Serial.print(URLSuffix); Serial.println(
"\")");
1138 if(!connectThingSpeak())
1140 this->lastReadStatus = ERR_CONNECT_FAILED;
1144 String URL = String(
"/channels/") + String(channelNumber) + URLSuffix;
1146 #ifdef PRINT_DEBUG_MESSAGES
1147 Serial.print(
" GET \"");Serial.print(URL);Serial.println(
"\"");
1151 if(!this->client->print(
"GET "))
return abortReadRaw();
1152 if(!this->client->print(URL))
return abortReadRaw();
1153 if(!this->client->print(
" HTTP/1.1\n"))
return abortReadRaw();
1154 if(!writeHTTPHeader(readAPIKey))
return abortReadRaw();
1155 if(!this->client->print(
"\n"))
return abortReadRaw();
1157 String content = String();
1158 int status = getHTTPResponse(content);
1159 this->lastReadStatus = status;
1162 #ifdef PRINT_DEBUG_MESSAGES
1163 if(status == OK_SUCCESS)
1165 Serial.print(
"Read: \""); Serial.print(content); Serial.println(
"\"");
1170 #ifdef PRINT_DEBUG_MESSAGES
1171 Serial.println(
"disconnected.");
1174 if(status != OK_SUCCESS)
1181 return String(
"") + content;
1219 return this->lastReadStatus;
1225 this->client->stop();
1226 return ERR_UNEXPECTED_FAIL;
1229 String abortReadRaw()
1231 this->client->stop();
1232 #ifdef PRINT_DEBUG_MESSAGES
1233 Serial.println(
"ReadRaw abort - disconnected.");
1235 this->lastReadStatus = ERR_UNEXPECTED_FAIL;
1239 void setServer(
const char * customHostName,
unsigned int port)
1241 #ifdef PRINT_DEBUG_MESSAGES
1242 Serial.print(
"ts::setServer (URL: \""); Serial.print(customHostName); Serial.println(
"\")");
1244 this->customIP = INADDR_NONE;
1245 this->customHostName = customHostName;
1249 void setServer(IPAddress customIP,
unsigned int port)
1251 #ifdef PRINT_DEBUG_MESSAGES
1252 Serial.print(
"ts::setServer (IP: \""); Serial.print(customIP); Serial.println(
"\")");
1254 this->customIP = customIP;
1255 this->customHostName = NULL;
1261 #ifdef PRINT_DEBUG_MESSAGES
1262 Serial.print(
"ts::setServer (default)");
1264 this->customIP = INADDR_NONE;
1265 this->customHostName = NULL;
1266 this->port = THINGSPEAK_PORT_NUMBER;
1269 void setClient(Client * client) {this->client = client;};
1271 Client * client = NULL;
1272 const char * customHostName = NULL;
1273 IPAddress customIP = INADDR_NONE;
1274 unsigned int port = THINGSPEAK_PORT_NUMBER;
1275 String nextWriteField[8];
1276 float nextWriteLatitude;
1277 float nextWriteLongitude;
1278 float nextWriteElevation;
1281 bool connectThingSpeak()
1283 bool connectSuccess =
false;
1284 if(this->customIP == INADDR_NONE && NULL == this->customHostName)
1286 #ifdef PRINT_DEBUG_MESSAGES
1287 Serial.print(
" Connect to default ThingSpeak URL...");
1289 connectSuccess = client->connect(THINGSPEAK_URL,THINGSPEAK_PORT_NUMBER);
1292 #ifdef PRINT_DEBUG_MESSAGES
1293 Serial.print(
"Failed. Try default IP...");
1295 connectSuccess = client->connect(THINGSPEAK_IPADDRESS,THINGSPEAK_PORT_NUMBER);
1300 if(!(this->customIP == INADDR_NONE))
1303 #ifdef PRINT_DEBUG_MESSAGES
1304 Serial.print(
" Connect to ");Serial.print(this->customIP);Serial.print(
"...");
1306 connectSuccess = client->connect(this->customIP,this->port);
1308 if(NULL != this->customHostName)
1311 #ifdef PRINT_DEBUG_MESSAGES
1313 Spark.publish(SPARK_PUBLISH_TOPIC,
"Attempt Connect to URL " + String(this->customHostName), SPARK_PUBLISH_TTL, PRIVATE);
1315 Serial.print(
" Connect to ");Serial.print(this->customHostName);Serial.print(
" ...");
1318 connectSuccess = client->connect(customHostName,this->port);
1322 #ifdef PRINT_DEBUG_MESSAGES
1326 Spark.publish(SPARK_PUBLISH_TOPIC,
"Connection Success", SPARK_PUBLISH_TTL, PRIVATE);
1328 Serial.println(
"Success.");
1334 Spark.publish(SPARK_PUBLISH_TOPIC,
"Connection Failure", SPARK_PUBLISH_TTL, PRIVATE);
1336 Serial.println(
"Failed.");
1340 return connectSuccess;
1343 bool writeHTTPHeader(
const char * APIKey)
1345 if(NULL != this->customHostName)
1347 if (!this->client->print(
"Host: "))
return false;
1348 if (!this->client->print(this->customHostName))
return false;
1349 if (!this->client->print(
"\n"))
return false;
1353 if (!this->client->print(
"Host: api.thingspeak.com\n"))
return false;
1355 if (!this->client->print(
"Connection: close\n"))
return false;
1356 if (!this->client->print(
"User-Agent: "))
return false;
1357 if (!this->client->print(TS_USER_AGENT))
return false;
1358 if (!this->client->print(
"\n"))
return false;
1361 if (!this->client->print(
"X-THINGSPEAKAPIKEY: "))
return false;
1362 if (!this->client->print(APIKey))
return false;
1363 if (!this->client->print(
"\n"))
return false;
1368 int getHTTPResponse(String & response)
1370 long startWaitForResponseAt = millis();
1371 while(client->available() == 0 && millis() - startWaitForResponseAt < TIMEOUT_MS_SERVERRESPONSE)
1375 if(client->available() == 0)
1380 if(!client->find(const_cast<char *>(
"HTTP/1.1")))
1383 Serial.println(
"ERROR: Didn't find HTTP/1.1");
1385 return ERR_BAD_RESPONSE;
1387 int status = client->parseInt();
1389 Serial.print(
"Got Status of ");Serial.println(status);
1391 if(status != OK_SUCCESS)
1396 if(!client->find(const_cast<char *>(
"\n\r\n")))
1399 Serial.println(
"ERROR: Didn't find end of header");
1401 return ERR_BAD_RESPONSE;
1404 Serial.println(
"Found end of header");
1409 long length = client->parseInt();
1410 Serial.print(
"Got length of ");Serial.println(length);
1412 if(!client->find(const_cast<char *>(
"\r\n")))
1415 Serial.println(
"ERROR: Didn't find end of length");
1417 return ERR_BAD_RESPONSE;
1420 Serial.println(
"Found end of length");
1423 String tempString = client->readStringUntil(
'\r');
1424 response = tempString;
1426 Serial.print(
"Response: \"");Serial.print(response);Serial.println(
"\"");
1431 int convertFloatToChar(
float value,
char *valueString)
1434 if(0 == isinf(value) && (value > 999999000000 || value < -999999000000))
1437 return ERR_OUT_OF_RANGE;
1440 #ifdef PARTICLE_PHOTON
1442 dtoa((
double)value,5, valueString);
1444 dtostrf(value,1,5, valueString);
1449 float convertStringToFloat(String value)
1452 float result = value.toFloat();
1453 if(1 == isinf(result) && *value.c_str() ==
'-')
1455 result = (float)-INFINITY;
1460 void resetWriteFields()
1462 for(
size_t iField = 0; iField < 8; iField++)
1464 this->nextWriteField[iField] =
"";
1466 this->nextWriteLatitude = NAN;
1467 this->nextWriteLongitude = NAN;
1468 this->nextWriteElevation = NAN;
1474 #endif //ThingSpeak_h
int writeRaw(unsigned long channelNumber, const char *postMessage, const char *writeAPIKey)
Write a raw POST to a ThingSpeak channel.
Definition: ThingSpeak.h:830
String readStringField(unsigned long channelNumber, unsigned int field, const char *readAPIKey)
Read the latest string from a private ThingSpeak channel.
Definition: ThingSpeak.h:925
String readStringField(unsigned long channelNumber, unsigned int field)
Read the latest string from a public ThingSpeak channel.
Definition: ThingSpeak.h:958
int setField(unsigned int field, long value)
Set the value of a single field that will be part of a multi-field update. To write multiple fields a...
Definition: ThingSpeak.h:453
int writeRaw(unsigned long channelNumber, String postMessage, const char *writeAPIKey)
Write a raw POST to a ThingSpeak channel.
Definition: ThingSpeak.h:851
bool begin(Client &client, IPAddress customIP, unsigned int port)
Initializes the ThingSpeak library and network settings using a custom installation of ThingSpeak...
Definition: ThingSpeak.h:186
int writeFields(unsigned long channelNumber, const char *writeAPIKey)
Write a multi-field update. Call setField() for each of the fields you want to write, setLatitude() / setLongitude() / setElevation(), and then call writeFields()
Definition: ThingSpeak.h:748
int setField(unsigned int field, int value)
Set the value of a single field that will be part of a multi-field update. To write multiple fields a...
Definition: ThingSpeak.h:409
int setLatitude(float latitude)
Set the latitude of a multi-field update. To record latitude, longitude and elevation of a write...
Definition: ThingSpeak.h:618
bool begin(Client &client, const char *customHostName, unsigned int port)
Initializes the ThingSpeak library and network settings using a custom installation of ThingSpeak...
Definition: ThingSpeak.h:153
int getLastReadStatus()
Get the status of the previous read.
Definition: ThingSpeak.h:1217
int writeField(unsigned long channelNumber, unsigned int field, int value, const char *writeAPIKey)
Write an integer value to a single field in a ThingSpeak channel.
Definition: ThingSpeak.h:245
This library enables an Arduino or other compatible hardware to write or read data to or from ThingSp...
Definition: ThingSpeak.h:123
long readLongField(unsigned long channelNumber, unsigned int field, const char *readAPIKey)
Read the latest long from a private ThingSpeak channel.
Definition: ThingSpeak.h:1022
int writeField(unsigned long channelNumber, unsigned int field, String value, const char *writeAPIKey)
Write a String to a single field in a ThingSpeak channel.
Definition: ThingSpeak.h:359
int setField(unsigned int field, const char *value)
Set the value of a single field that will be part of a multi-field update. To write multiple fields a...
Definition: ThingSpeak.h:532
String readRaw(unsigned long channelNumber, String URLSuffix)
Read a raw response from a public ThingSpeak channel.
Definition: ThingSpeak.h:1106
long readLongField(unsigned long channelNumber, unsigned int field)
Read the latest long from a public ThingSpeak channel.
Definition: ThingSpeak.h:1043
int writeField(unsigned long channelNumber, unsigned int field, float value, const char *writeAPIKey)
Write a floating point value to a single field in a ThingSpeak channel.
Definition: ThingSpeak.h:297
int readIntField(unsigned long channelNumber, unsigned int field, const char *readAPIKey)
Read the latest int from a private ThingSpeak channel.
Definition: ThingSpeak.h:1065
int setField(unsigned int field, String value)
Set the value of a single field that will be part of a multi-field update. To write multiple fields a...
Definition: ThingSpeak.h:568
int setLongitude(float longitude)
Set the longitude of a multi-field update. To record latitude, longitude and elevation of a write...
Definition: ThingSpeak.h:661
float readFloatField(unsigned long channelNumber, unsigned int field, const char *readAPIKey)
Read the latest float from a private ThingSpeak channel.
Definition: ThingSpeak.h:980
bool begin(Client &client)
Initializes the ThingSpeak library and network settings using the ThingSpeak.com service.
Definition: ThingSpeak.h:217
float readFloatField(unsigned long channelNumber, unsigned int field)
Read the latest float from a public ThingSpeak channel.
Definition: ThingSpeak.h:1001
int writeField(unsigned long channelNumber, unsigned int field, const char *value, const char *writeAPIKey)
Write a string to a single field in a ThingSpeak channel.
Definition: ThingSpeak.h:330
int readIntField(unsigned long channelNumber, unsigned int field)
Read the latest int from a public ThingSpeak channel.
Definition: ThingSpeak.h:1086
int setField(unsigned int field, float value)
Set the value of a single field that will be part of a multi-field update. To write multiple fields a...
Definition: ThingSpeak.h:492
String readRaw(unsigned long channelNumber, String URLSuffix, const char *readAPIKey)
Read a raw response from a private ThingSpeak channel.
Definition: ThingSpeak.h:1127
int setElevation(float elevation)
Set the elevation of a multi-field update. To record latitude, longitude and elevation of a write...
Definition: ThingSpeak.h:704
int writeField(unsigned long channelNumber, unsigned int field, long value, const char *writeAPIKey)
Write a long value to a single field in a ThingSpeak channel.
Definition: ThingSpeak.h:273