59 #define PARTICLE_PHOTON
60 #define PARTICLE_PHOTONELECTRON
61 #elif PLATFORM_ID == 10
62 #define PARTICLE_ELECTRON
63 #define PARTICLE_PHOTONELECTRON
64 #elif PLATFORM_ID == 0
69 #include "application.h"
70 #ifdef PARTICLE_PHOTONELECTRON
71 extern char* dtoa(
double val,
unsigned char prec,
char *sout);
73 #include "string_convert.h"
77 extern char * itoa(
int a,
char* buffer,
unsigned char radix);
79 extern char *dtostrf (
double val,
signed char width,
unsigned char prec,
char *sout);
82 #if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_ESP8266)
86 #error Only Arduino Yun, Uno/Mega/Due with either Wired or wi-fi Ethernet shield, ESP8266, and Spark Core/Photon/Electron are supported.
90 #define THINGSPEAK_URL "api.thingspeak.com"
91 #define THINGSPEAK_IPADDRESS IPAddress(184,106,153,149)
92 #define THINGSPEAK_PORT_NUMBER 80
94 #ifdef ARDUINO_ARCH_AVR
95 #ifdef ARDUINO_AVR_YUN
96 #define TS_USER_AGENT "tslib-arduino/1.0 (arduino yun)"
98 #define TS_USER_AGENT "tslib-arduino/1.0 (arduino uno or mega)"
100 #elif defined(ARDUINO_ARCH_ESP8266)
101 #define TS_USER_AGENT "tslib-arduino/1.0 (ESP8266)"
104 #define TS_USER_AGENT "tslib-arduino/1.0 (particle core)"
105 #elif defined(PARTICLE_PHOTON)
106 #define TS_USER_AGENT "tslib-arduino/1.0 (particle photon)"
107 #elif defined(PARTICLE_ELECTRON)
108 #define TS_USER_AGENT "tslib-arduino/1.0 (particle electron)"
110 #define SPARK_PUBLISH_TTL 60 // Spark "time to live" for published messages
111 #define SPARK_PUBLISH_TOPIC "thingspeak-debug"
114 #define FIELDNUM_MIN 1
115 #define FIELDNUM_MAX 8
116 #define FIELDLENGTH_MAX 255 // Max length for a field in ThingSpeak is 255 bytes (UTF-8)
118 #define TIMEOUT_MS_SERVERRESPONSE 5000 // Wait up to five seconds for server to respond
120 #define OK_SUCCESS 200 // OK / Success
121 #define ERR_BADAPIKEY 400 // Incorrect API key (or invalid ThingSpeak server address)
122 #define ERR_BADURL 404 // Incorrect API key (or invalid ThingSpeak server address)
123 #define ERR_OUT_OF_RANGE -101 // Value is out of range or string is too long (> 255 bytes)
124 #define ERR_INVALID_FIELD_NUM -201 // Invalid field number specified
125 #define ERR_SETFIELD_NOT_CALLED -210 // setField() was not called before writeFields()
126 #define ERR_CONNECT_FAILED -301 // Failed to connect to ThingSpeak
127 #define ERR_UNEXPECTED_FAIL -302 // Unexpected failure during write to ThingSpeak
128 #define ERR_BAD_RESPONSE -303 // Unable to parse response
129 #define ERR_TIMEOUT -304 // Timeout waiting for server to respond
130 #define ERR_NOT_INSERTED -401 // Point was not inserted (most probable cause is the rate limit of once every 15 seconds)
141 this->lastReadStatus = OK_SUCCESS;
165 bool begin(Client & client,
const char * customHostName,
unsigned int port)
167 #ifdef PRINT_DEBUG_MESSAGES
168 Serial.print(
"ts::tsBegin (client: Client URL: "); Serial.print(customHostName); Serial.println(
")");
170 this->setClient(&client);
171 this->setServer(customHostName, port);
173 this->lastReadStatus = OK_SUCCESS;
198 bool begin(Client & client, IPAddress customIP,
unsigned int port)
200 #ifdef PRINT_DEBUG_MESSAGES
201 Serial.print(
"ts::tsBegin (client: Client IP: "); Serial.print(customIP); Serial.println(
")");
203 this->setClient(&client);
204 this->setServer(customIP, port);
206 this->lastReadStatus = OK_SUCCESS;
231 #ifdef PRINT_DEBUG_MESSAGES
232 Serial.print(
"ts::tsBegin");
234 this->setClient(&client);
237 this->lastReadStatus = OK_SUCCESS;
257 int writeField(
unsigned long channelNumber,
unsigned int field,
int value,
const char * writeAPIKey)
261 return writeField(channelNumber, field, (
long)value, writeAPIKey);
263 char valueString[10];
264 itoa(value, valueString, 10);
265 return writeField(channelNumber, field, valueString, writeAPIKey);
285 int writeField(
unsigned long channelNumber,
unsigned int field,
long value,
const char * writeAPIKey)
287 char valueString[15];
288 ltoa(value, valueString, 10);
289 return writeField(channelNumber, field, valueString, writeAPIKey);
309 int writeField(
unsigned long channelNumber,
unsigned int field,
float value,
const char * writeAPIKey)
311 #ifdef PRINT_DEBUG_MESSAGES
312 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(
")");
314 char valueString[20];
315 int status = convertFloatToChar(value, valueString);
316 if(status != OK_SUCCESS)
return status;
318 return writeField(channelNumber, field, valueString, writeAPIKey);
342 int writeField(
unsigned long channelNumber,
unsigned int field,
const char * value,
const char * writeAPIKey)
344 return writeField(channelNumber, field, String(value), writeAPIKey);
371 int writeField(
unsigned long channelNumber,
unsigned int field, String value,
const char * writeAPIKey)
374 if(field < FIELDNUM_MIN || field > FIELDNUM_MAX)
return ERR_INVALID_FIELD_NUM;
376 if(value.length() > FIELDLENGTH_MAX)
return ERR_OUT_OF_RANGE;
378 #ifdef PRINT_DEBUG_MESSAGES
380 Particle.publish(SPARK_PUBLISH_TOPIC,
"writeField (" + String(channelNumber) +
", " + String(writeAPIKey) +
", " + String(field) +
", " + String(value) +
")", SPARK_PUBLISH_TTL, PRIVATE);
382 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(
"\")");
385 String postMessage = String(
"field") + String(field) +
"=" + value;
386 return writeRaw(channelNumber, postMessage, writeAPIKey);
425 return setField(field, (
long)value);
427 char valueString[10];
428 itoa(value, valueString, 10);
430 return setField(field, valueString);
467 char valueString[15];
468 ltoa(value, valueString, 10);
469 return setField(field, valueString);
506 char valueString[20];
507 int status = convertFloatToChar(value, valueString);
508 if(status != OK_SUCCESS)
return status;
510 return setField(field, valueString);
544 int setField(
unsigned int field,
const char * value)
546 return setField(field, String(value));
582 #ifdef PRINT_DEBUG_MESSAGES
584 Particle.publish(SPARK_PUBLISH_TOPIC,
"setField " + String(field) +
" to " + String(value), SPARK_PUBLISH_TTL, PRIVATE);
586 Serial.print(
"ts::setField (field: "); Serial.print(field); Serial.print(
" value: \""); Serial.print(value); Serial.println(
"\")");
589 if(field < FIELDNUM_MIN || field > FIELDNUM_MAX)
return ERR_INVALID_FIELD_NUM;
591 if(value.length() > FIELDLENGTH_MAX)
return ERR_OUT_OF_RANGE;
592 this->nextWriteField[field - 1] = value;
632 #ifdef PRINT_DEBUG_MESSAGES
633 Serial.print(
"ts::setLatitude(latitude: "); Serial.print(latitude,3); Serial.println(
"\")");
635 this->nextWriteLatitude = latitude;
675 #ifdef PRINT_DEBUG_MESSAGES
676 Serial.print(
"ts::setLongitude(longitude: "); Serial.print(longitude,3); Serial.println(
"\")");
678 this->nextWriteLongitude = longitude;
718 #ifdef PRINT_DEBUG_MESSAGES
719 Serial.print(
"ts::setElevation(elevation: "); Serial.print(elevation,3); Serial.println(
"\")");
721 this->nextWriteElevation = elevation;
760 int writeFields(
unsigned long channelNumber,
const char * writeAPIKey)
762 String postMessage = String(
"");
763 bool fFirstItem =
true;
764 for(
size_t iField = 0; iField < 8; iField++)
766 if(this->nextWriteField[iField].length() > 0)
770 postMessage = postMessage + String(
"&");
772 postMessage = postMessage + String(
"field") + String(iField + 1) + String(
"=") + this->nextWriteField[iField];
774 this->nextWriteField[iField] =
"";
778 if(!isnan(nextWriteLatitude))
782 postMessage = postMessage + String(
"&");
784 postMessage = postMessage + String(
"lat=") + String(this->nextWriteLatitude);
786 this->nextWriteLatitude = NAN;
789 if(!isnan(this->nextWriteLongitude))
793 postMessage = postMessage + String(
"&");
795 postMessage = postMessage + String(
"long=") + String(this->nextWriteLongitude);
797 this->nextWriteLongitude = NAN;
801 if(!isnan(this->nextWriteElevation))
805 postMessage = postMessage + String(
"&");
807 postMessage = postMessage + String(
"elevation=") + String(this->nextWriteElevation);
809 this->nextWriteElevation = NAN;
815 return ERR_SETFIELD_NOT_CALLED;
818 return writeRaw(channelNumber, postMessage, writeAPIKey);
842 int writeRaw(
unsigned long channelNumber,
const char * postMessage,
const char * writeAPIKey)
844 return writeRaw(channelNumber, String(postMessage), writeAPIKey);
863 int writeRaw(
unsigned long channelNumber, String postMessage,
const char * writeAPIKey)
865 #ifdef PRINT_DEBUG_MESSAGES
866 Serial.print(
"ts::writeRaw (channelNumber: "); Serial.print(channelNumber); Serial.print(
" writeAPIKey: "); Serial.print(writeAPIKey); Serial.print(
" postMessage: \""); Serial.print(postMessage); Serial.println(
"\")");
869 if(!connectThingSpeak())
872 return ERR_CONNECT_FAILED;
875 postMessage = postMessage + String(
"&headers=false");
877 #ifdef PRINT_DEBUG_MESSAGES
879 Particle.publish(SPARK_PUBLISH_TOPIC,
"Post " + postMessage, SPARK_PUBLISH_TTL, PRIVATE);
881 Serial.print(
" POST \"");Serial.print(postMessage);Serial.println(
"\"");
885 postMessage = postMessage + String(
"\n");
888 if(!this->client->print(
"POST /update HTTP/1.1\n"))
return abortWriteRaw();
889 if(!writeHTTPHeader(writeAPIKey))
return abortWriteRaw();
890 if(!this->client->print(
"Content-Type: application/x-www-form-urlencoded\n"))
return abortWriteRaw();
891 if(!this->client->print(
"Content-Length: "))
return abortWriteRaw();
892 if(!this->client->print(postMessage.length()))
return abortWriteRaw();
893 if(!this->client->print(
"\n\n"))
return abortWriteRaw();
894 if(!this->client->print(postMessage))
return abortWriteRaw();
896 String entryIDText = String();
897 int status = getHTTPResponse(entryIDText);
898 if(status != OK_SUCCESS)
903 long entryID = entryIDText.toInt();
905 #ifdef PRINT_DEBUG_MESSAGES
906 Serial.print(
" Entry ID \"");Serial.print(entryIDText);Serial.print(
"\" (");Serial.print(entryID);Serial.println(
")");
911 #ifdef PRINT_DEBUG_MESSAGES
912 Serial.println(
"disconnected.");
917 status = ERR_NOT_INSERTED;
937 String
readStringField(
unsigned long channelNumber,
unsigned int field,
const char * readAPIKey)
939 if(field < FIELDNUM_MIN || field > FIELDNUM_MAX)
941 this->lastReadStatus = ERR_INVALID_FIELD_NUM;
944 #ifdef PRINT_DEBUG_MESSAGES
945 Serial.print(
"ts::readStringField(channelNumber: "); Serial.print(channelNumber);
946 if(NULL != readAPIKey)
948 Serial.print(
" readAPIKey: "); Serial.print(readAPIKey);
950 Serial.print(
" field: "); Serial.print(field); Serial.println(
")");
952 return readRaw(channelNumber, String(String(
"/fields/") + String(field) + String(
"/last")), readAPIKey);
992 float readFloatField(
unsigned long channelNumber,
unsigned int field,
const char * readAPIKey)
994 return convertStringToFloat(
readStringField(channelNumber, field, readAPIKey));
1034 long readLongField(
unsigned long channelNumber,
unsigned int field,
const char * readAPIKey)
1077 int readIntField(
unsigned long channelNumber,
unsigned int field,
const char * readAPIKey)
1118 String
readRaw(
unsigned long channelNumber, String URLSuffix)
1120 return readRaw(channelNumber, URLSuffix, NULL);
1139 String
readRaw(
unsigned long channelNumber, String URLSuffix,
const char * readAPIKey)
1141 #ifdef PRINT_DEBUG_MESSAGES
1142 Serial.print(
"ts::readRaw (channelNumber: "); Serial.print(channelNumber);
1143 if(NULL != readAPIKey)
1145 Serial.print(
" readAPIKey: "); Serial.print(readAPIKey);
1147 Serial.print(
" URLSuffix: \""); Serial.print(URLSuffix); Serial.println(
"\")");
1150 if(!connectThingSpeak())
1152 this->lastReadStatus = ERR_CONNECT_FAILED;
1156 String URL = String(
"/channels/") + String(channelNumber) + URLSuffix;
1158 #ifdef PRINT_DEBUG_MESSAGES
1159 Serial.print(
" GET \"");Serial.print(URL);Serial.println(
"\"");
1163 if(!this->client->print(
"GET "))
return abortReadRaw();
1164 if(!this->client->print(URL))
return abortReadRaw();
1165 if(!this->client->print(
" HTTP/1.1\n"))
return abortReadRaw();
1166 if(!writeHTTPHeader(readAPIKey))
return abortReadRaw();
1167 if(!this->client->print(
"\n"))
return abortReadRaw();
1169 String content = String();
1170 int status = getHTTPResponse(content);
1171 this->lastReadStatus = status;
1174 #ifdef PRINT_DEBUG_MESSAGES
1175 if(status == OK_SUCCESS)
1177 Serial.print(
"Read: \""); Serial.print(content); Serial.println(
"\"");
1182 #ifdef PRINT_DEBUG_MESSAGES
1183 Serial.println(
"disconnected.");
1186 if(status != OK_SUCCESS)
1193 return String(
"") + content;
1231 return this->lastReadStatus;
1237 this->client->stop();
1238 return ERR_UNEXPECTED_FAIL;
1241 String abortReadRaw()
1243 this->client->stop();
1244 #ifdef PRINT_DEBUG_MESSAGES
1245 Serial.println(
"ReadRaw abort - disconnected.");
1247 this->lastReadStatus = ERR_UNEXPECTED_FAIL;
1251 void setServer(
const char * customHostName,
unsigned int port)
1253 #ifdef PRINT_DEBUG_MESSAGES
1254 Serial.print(
"ts::setServer (URL: \""); Serial.print(customHostName); Serial.println(
"\")");
1256 this->customIP = INADDR_NONE;
1257 this->customHostName = customHostName;
1261 void setServer(IPAddress customIP,
unsigned int port)
1263 #ifdef PRINT_DEBUG_MESSAGES
1264 Serial.print(
"ts::setServer (IP: \""); Serial.print(customIP); Serial.println(
"\")");
1266 this->customIP = customIP;
1267 this->customHostName = NULL;
1273 #ifdef PRINT_DEBUG_MESSAGES
1274 Serial.print(
"ts::setServer (default)");
1276 this->customIP = INADDR_NONE;
1277 this->customHostName = NULL;
1278 this->port = THINGSPEAK_PORT_NUMBER;
1281 void setClient(Client * client) {this->client = client;};
1283 Client * client = NULL;
1284 const char * customHostName = NULL;
1285 IPAddress customIP = INADDR_NONE;
1286 unsigned int port = THINGSPEAK_PORT_NUMBER;
1287 String nextWriteField[8];
1288 float nextWriteLatitude;
1289 float nextWriteLongitude;
1290 float nextWriteElevation;
1293 bool connectThingSpeak()
1295 bool connectSuccess =
false;
1296 if(this->customIP == INADDR_NONE && NULL == this->customHostName)
1298 #ifdef PRINT_DEBUG_MESSAGES
1299 Serial.print(
" Connect to default ThingSpeak URL...");
1301 connectSuccess = client->connect(THINGSPEAK_URL,THINGSPEAK_PORT_NUMBER);
1304 #ifdef PRINT_DEBUG_MESSAGES
1305 Serial.print(
"Failed. Try default IP...");
1307 connectSuccess = client->connect(THINGSPEAK_IPADDRESS,THINGSPEAK_PORT_NUMBER);
1312 if(!(this->customIP == INADDR_NONE))
1315 #ifdef PRINT_DEBUG_MESSAGES
1316 Serial.print(
" Connect to ");Serial.print(this->customIP);Serial.print(
"...");
1318 connectSuccess = client->connect(this->customIP,this->port);
1320 if(NULL != this->customHostName)
1323 #ifdef PRINT_DEBUG_MESSAGES
1325 Particle.publish(SPARK_PUBLISH_TOPIC,
"Attempt Connect to URL " + String(this->customHostName), SPARK_PUBLISH_TTL, PRIVATE);
1327 Serial.print(
" Connect to ");Serial.print(this->customHostName);Serial.print(
" ...");
1330 connectSuccess = client->connect(customHostName,this->port);
1334 #ifdef PRINT_DEBUG_MESSAGES
1338 Particle.publish(SPARK_PUBLISH_TOPIC,
"Connection Success", SPARK_PUBLISH_TTL, PRIVATE);
1340 Serial.println(
"Success.");
1346 Particle.publish(SPARK_PUBLISH_TOPIC,
"Connection Failure", SPARK_PUBLISH_TTL, PRIVATE);
1348 Serial.println(
"Failed.");
1352 return connectSuccess;
1355 bool writeHTTPHeader(
const char * APIKey)
1357 if(NULL != this->customHostName)
1359 if (!this->client->print(
"Host: "))
return false;
1360 if (!this->client->print(this->customHostName))
return false;
1361 if (!this->client->print(
"\n"))
return false;
1365 if (!this->client->print(
"Host: api.thingspeak.com\n"))
return false;
1367 if (!this->client->print(
"Connection: close\n"))
return false;
1368 if (!this->client->print(
"User-Agent: "))
return false;
1369 if (!this->client->print(TS_USER_AGENT))
return false;
1370 if (!this->client->print(
"\n"))
return false;
1373 if (!this->client->print(
"X-THINGSPEAKAPIKEY: "))
return false;
1374 if (!this->client->print(APIKey))
return false;
1375 if (!this->client->print(
"\n"))
return false;
1380 int getHTTPResponse(String & response)
1382 long startWaitForResponseAt = millis();
1383 while(client->available() == 0 && millis() - startWaitForResponseAt < TIMEOUT_MS_SERVERRESPONSE)
1387 if(client->available() == 0)
1392 if(!client->find(const_cast<char *>(
"HTTP/1.1")))
1396 Particle.publish(SPARK_PUBLISH_TOPIC,
"ERROR: Didn't find HTTP/1.1", SPARK_PUBLISH_TTL, PRIVATE);
1398 Serial.println(
"ERROR: Didn't find HTTP/1.1");
1401 return ERR_BAD_RESPONSE;
1403 int status = client->parseInt();
1406 Particle.publish(SPARK_PUBLISH_TOPIC,
"Got Status of " + String(status), SPARK_PUBLISH_TTL, PRIVATE);
1408 Serial.print(
"Got Status of ");Serial.println(status);
1411 if(status != OK_SUCCESS)
1416 if(!client->find(const_cast<char *>(
"\r\n")))
1420 Particle.publish(SPARK_PUBLISH_TOPIC,
"ERROR: Didn't find end of status line", SPARK_PUBLISH_TTL, PRIVATE);
1422 Serial.println(
"ERROR: Didn't find end of status line");
1425 return ERR_BAD_RESPONSE;
1429 Particle.publish(SPARK_PUBLISH_TOPIC,
"Found end of status line", SPARK_PUBLISH_TTL, PRIVATE);
1431 Serial.println(
"Found end of status line");
1435 if(!client->find(const_cast<char *>(
"\n\r\n")))
1439 Particle.publish(SPARK_PUBLISH_TOPIC,
"ERROR: Didn't find end of header", SPARK_PUBLISH_TTL, PRIVATE);
1441 Serial.println(
"ERROR: Didn't find end of header");
1444 return ERR_BAD_RESPONSE;
1448 Particle.publish(SPARK_PUBLISH_TOPIC,
"Found end of header", SPARK_PUBLISH_TTL, PRIVATE);
1450 Serial.println(
"Found end of header");
1454 String tempString = client->readStringUntil(
'\r');
1455 response = tempString;
1458 Particle.publish(SPARK_PUBLISH_TOPIC,
"Response: \"" + tempString +
"\"", SPARK_PUBLISH_TTL, PRIVATE);
1460 Serial.print(
"Response: \"");Serial.print(response);Serial.println(
"\"");
1466 int convertFloatToChar(
float value,
char *valueString)
1469 if(0 == isinf(value) && (value > 999999000000 || value < -999999000000))
1472 return ERR_OUT_OF_RANGE;
1475 #ifdef PARTICLE_PHOTONELECTRON
1477 dtoa((
double)value,5, valueString);
1479 dtostrf(value,1,5, valueString);
1484 float convertStringToFloat(String value)
1487 float result = value.toFloat();
1488 if(1 == isinf(result) && *value.c_str() ==
'-')
1490 result = (float)-INFINITY;
1495 void resetWriteFields()
1497 for(
size_t iField = 0; iField < 8; iField++)
1499 this->nextWriteField[iField] =
"";
1501 this->nextWriteLatitude = NAN;
1502 this->nextWriteLongitude = NAN;
1503 this->nextWriteElevation = NAN;
1509 #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:842
String readStringField(unsigned long channelNumber, unsigned int field, const char *readAPIKey)
Read the latest string from a private ThingSpeak channel.
Definition: ThingSpeak.h:937
String readStringField(unsigned long channelNumber, unsigned int field)
Read the latest string from a public ThingSpeak channel.
Definition: ThingSpeak.h:970
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:465
int writeRaw(unsigned long channelNumber, String postMessage, const char *writeAPIKey)
Write a raw POST to a ThingSpeak channel.
Definition: ThingSpeak.h:863
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:198
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:760
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:421
int setLatitude(float latitude)
Set the latitude of a multi-field update. To record latitude, longitude and elevation of a write...
Definition: ThingSpeak.h:630
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:165
int getLastReadStatus()
Get the status of the previous read.
Definition: ThingSpeak.h:1229
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:257
Enables an Arduino, ESP8266, Particle or other compatible hardware to write or read data to or from T...
Definition: ThingSpeak.h:135
long readLongField(unsigned long channelNumber, unsigned int field, const char *readAPIKey)
Read the latest long from a private ThingSpeak channel.
Definition: ThingSpeak.h:1034
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:371
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:544
String readRaw(unsigned long channelNumber, String URLSuffix)
Read a raw response from a public ThingSpeak channel.
Definition: ThingSpeak.h:1118
long readLongField(unsigned long channelNumber, unsigned int field)
Read the latest long from a public ThingSpeak channel.
Definition: ThingSpeak.h:1055
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:309
int readIntField(unsigned long channelNumber, unsigned int field, const char *readAPIKey)
Read the latest int from a private ThingSpeak channel.
Definition: ThingSpeak.h:1077
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:580
int setLongitude(float longitude)
Set the longitude of a multi-field update. To record latitude, longitude and elevation of a write...
Definition: ThingSpeak.h:673
float readFloatField(unsigned long channelNumber, unsigned int field, const char *readAPIKey)
Read the latest float from a private ThingSpeak channel.
Definition: ThingSpeak.h:992
bool begin(Client &client)
Initializes the ThingSpeak library and network settings using the ThingSpeak.com service.
Definition: ThingSpeak.h:229
float readFloatField(unsigned long channelNumber, unsigned int field)
Read the latest float from a public ThingSpeak channel.
Definition: ThingSpeak.h:1013
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:342
int readIntField(unsigned long channelNumber, unsigned int field)
Read the latest int from a public ThingSpeak channel.
Definition: ThingSpeak.h:1098
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:504
String readRaw(unsigned long channelNumber, String URLSuffix, const char *readAPIKey)
Read a raw response from a private ThingSpeak channel.
Definition: ThingSpeak.h:1139
int setElevation(float elevation)
Set the elevation of a multi-field update. To record latitude, longitude and elevation of a write...
Definition: ThingSpeak.h:716
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:285