{"id":19129843,"url":"https://github.com/mathworks/thingspeak-arduino","last_synced_at":"2025-04-05T02:03:37.435Z","repository":{"id":34957252,"uuid":"39032554","full_name":"mathworks/thingspeak-arduino","owner":"mathworks","description":"ThingSpeak Communication Library for Arduino, ESP8266 and ESP32","archived":false,"fork":false,"pushed_at":"2023-06-22T08:03:02.000Z","size":1292,"stargazers_count":449,"open_issues_count":6,"forks_count":235,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-03-29T01:02:46.399Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://thingspeak.com","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mathworks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2015-07-13T19:22:58.000Z","updated_at":"2025-03-12T01:31:46.000Z","dependencies_parsed_at":"2022-09-21T09:31:26.890Z","dependency_job_id":"a7de1a66-16b9-4957-848b-eacf39864e06","html_url":"https://github.com/mathworks/thingspeak-arduino","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks%2Fthingspeak-arduino","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks%2Fthingspeak-arduino/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks%2Fthingspeak-arduino/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks%2Fthingspeak-arduino/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mathworks","download_url":"https://codeload.github.com/mathworks/thingspeak-arduino/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247276159,"owners_count":20912288,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T06:08:41.186Z","updated_at":"2025-04-05T02:03:37.410Z","avatar_url":"https://github.com/mathworks.png","language":"C++","funding_links":[],"categories":["C++"],"sub_categories":[],"readme":"# ThingSpeak Communication Library for Arduino, ESP8266 and ESP32\n\nThis library enables an Arduino or other compatible hardware to write or read data to or from ThingSpeak, an open data platform for the Internet of Things with MATLAB analytics and visualization.\n\nHardware specific \u003ca href=\"http://github.com/mathworks/thingspeak-arduino/tree/master/examples\"\u003eexamples\u003c/a\u003e are found here. But to give you an idea of usage examples for \u003ca href=\"#typical_write\"\u003ewriting\u003c/a\u003e and \u003ca href=\"#typical_read\"\u003ereading\u003c/a\u003e with an ESP8266 are shown below. Complete \u003ca href=\"#documentation\"\u003edocumentation\u003c/a\u003e in also shown below.\n\nThingSpeak offers free data storage and analysis of time-stamped numeric or alphanumeric data. Users can access ThingSpeak by visiting http://thingspeak.com and creating a ThingSpeak user account.\n\nThingSpeak stores data in channels. Channels support an unlimited number of timestamped observations (think of these as rows in a spreadsheet). Each channel has up to 8 fields (think of these as columns in a speadsheet). Check out this [video](https://www.mathworks.com/videos/introduction-to-thingspeak-107749.html) for an overview.\n\nChannels may be public, where anyone can see the data, or private, where only the owner and select users can read the data. Each channel has an associated Write API Key that is used to control who can write to a channel. In addition, private channels have one or more Read API Keys to control who can read from private channel. An API Key is not required to read from public channels.  Each channel can have up to 8 fields. One field is created by default.\n\nYou can visualize and do online analytics of your data on ThingSpeak using the built in version of MATLAB, or use the desktop version of MATLAB to get deeper historical insight. Visit https://www.mathworks.com/hardware-support/thingspeak.html to learn more.\n\nLibraries and examples for Particle devices can be found here: https://github.com/mathworks/thingspeak-particle\n\n## Installation\nIn the Arduino IDE, choose Sketch/Include Library/Manage Libraries.  Click the ThingSpeak Library from the list, and click the Install button.\n\n--- or ---\n\n1. Download the ZIP file (below) to your machine.\n2. In the Arduino IDE, choose Sketch/Include Library/Add Zip Library\n3. Navigate to the ZIP file, and click Open\n\n## Compatible Hardware:\n\n* Arduino/Genuino or compatible using a WiFi Shield\n* Arduino/Genuino or compatible using a WiFi Shield 101 (Use the WiFi101 library version 0.13.0 or older.)\n* Arduino/Genuino or compatible using an Ethernet Shield\n* Arduino/Genuino or compatible using a MKR ETH Shield\n* Arduino MKR1000 \n* Arduino MKR1010\n* Arduino VIDOR 4000\n* Arduino GSM 14000\n* Arduino Uno WiFi Rev2\n* Arduino Yún (Rev1 and Rev2)\n* ESP8266 programming directly (tested with SparkFun ESP8266 Thing - Dev Board and NodeMCU 1.0 module)\n* ESP8266 via AT commands \n* ESP32 (tested with SparkFun ESP32 Thing)\n\n# Examples\n\nThe library includes several \u003ca href=\"http://github.com/mathworks/thingspeak-arduino/tree/master/examples\"\u003eexamples organized by board type\u003c/a\u003e to help you get started. These are accessible in Examples \u003e ThingSpeak menu of the Arduino IDE.\n\n* **ReadField:** Reading from a public channel and a private channel on ThingSpeak.\n* **WriteSingleField:** Writing a value to a single field on ThingSpeak.\n* **WriteMultipleFields:** Writing values to multiple fields and status in one transaction with ThingSpeak.\n* **ReadMultipleFields:** Reading values from multiple fields, status, location, created-at timestamp from a public channel on ThingSpeak\n* **SecureConnect:** Using the above features and connecting securely to ThingSpeak.\n\n## \u003ca id=\"typical_write\"\u003eTypical Write Example\u003c/a\u003e\nIn this case, write to a field with an ESP8266 with an incrementing number.   \n\n```\n#include \u003cESP8266WiFi.h\u003e\n#include \"secrets.h\"\n#include \"ThingSpeak.h\" // always include thingspeak header file after other header files and custom macros\n\nchar ssid[] = SECRET_SSID;   // your network SSID (name) \nchar pass[] = SECRET_PASS;   // your network password\nint keyIndex = 0;            // your network key Index number (needed only for WEP)\nWiFiClient  client;\n\nunsigned long myChannelNumber = SECRET_CH_ID;\nconst char * myWriteAPIKey = SECRET_WRITE_APIKEY;\n\nint number = 0;\n\nvoid setup() {\n  Serial.begin(115200);  // Initialize serial\n  while (!Serial) {\n    ; // wait for serial port to connect. Needed for native USB port only\n  }\n  \n  WiFi.mode(WIFI_STA); \n  ThingSpeak.begin(client);  // Initialize ThingSpeak\n}\n\nvoid loop() {\n\n  // Connect or reconnect to WiFi\n  if(WiFi.status() != WL_CONNECTED){\n    Serial.print(\"Attempting to connect to SSID: \");\n    Serial.println(SECRET_SSID);\n    while(WiFi.status() != WL_CONNECTED){\n      WiFi.begin(ssid, pass);  // Connect to WPA/WPA2 network. Change this line if using open or WEP network\n      Serial.print(\".\");\n      delay(5000);     \n    } \n    Serial.println(\"\\nConnected.\");\n  }\n  \n  // Write to ThingSpeak. There are up to 8 fields in a channel, allowing you to store up to 8 different\n  // pieces of information in a channel.  Here, we write to field 1.\n  int x = ThingSpeak.writeField(myChannelNumber, 1, number, myWriteAPIKey);\n  if(x == 200){\n    Serial.println(\"Channel update successful.\");\n  }\n  else{\n    Serial.println(\"Problem updating channel. HTTP error code \" + String(x));\n  }\n\n  // change the value\n  number++;\n  if(number \u003e 99){\n    number = 0;\n  }\n  \n  delay(20000); // Wait 20 seconds to update the channel again\n}\n```\n\n## \u003ca id=\"typical_read\"\u003eTypical Read Example\u003c/a\u003e\nIn this case, read from a public channel and a private channel with an ESP8266.  The public channel is the temperature(F) at MathWorks headquarters.  The private channel is a counter that increments.\n\n ```\n#include \u003cESP8266WiFi.h\u003e\n#include \"secrets.h\"\n#include \"ThingSpeak.h\" // always include thingspeak header file after other header files and custom macros\n\nchar ssid[] = SECRET_SSID;   // your network SSID (name) \nchar pass[] = SECRET_PASS;   // your network password\nint keyIndex = 0;            // your network key Index number (needed only for WEP)\nWiFiClient  client;\n\n// Weather station channel details\nunsigned long weatherStationChannelNumber = SECRET_CH_ID_WEATHER_STATION;\nunsigned int temperatureFieldNumber = 4;\n\n// Counting channel details\nunsigned long counterChannelNumber = SECRET_CH_ID_COUNTER;\nconst char * myCounterReadAPIKey = SECRET_READ_APIKEY_COUNTER;\nunsigned int counterFieldNumber = 1; \n\nvoid setup() {\n  Serial.begin(115200);  // Initialize serial\n  while (!Serial) {\n    ; // wait for serial port to connect. Needed for native USB port only\n  }\n  \n  WiFi.mode(WIFI_STA); \n  ThingSpeak.begin(client);  // Initialize ThingSpeak\n}\n\nvoid loop() {\n\n  int statusCode = 0;\n  \n  // Connect or reconnect to WiFi\n  if(WiFi.status() != WL_CONNECTED){\n    Serial.print(\"Attempting to connect to SSID: \");\n    Serial.println(SECRET_SSID);\n    while(WiFi.status() != WL_CONNECTED){\n      WiFi.begin(ssid, pass); // Connect to WPA/WPA2 network. Change this line if using open or WEP network\n      Serial.print(\".\");\n      delay(5000);     \n    } \n    Serial.println(\"\\nConnected\");\n  }\n\n  // Read in field 4 of the public channel recording the temperature\n  float temperatureInF = ThingSpeak.readFloatField(weatherStationChannelNumber, temperatureFieldNumber);  \n\n  // Check the status of the read operation to see if it was successful\n  statusCode = ThingSpeak.getLastReadStatus();\n  if(statusCode == 200){\n    Serial.println(\"Temperature at MathWorks HQ: \" + String(temperatureInF) + \" deg F\");\n  }\n  else{\n    Serial.println(\"Problem reading channel. HTTP error code \" + String(statusCode)); \n  }\n  \n  delay(15000); // No need to read the temperature too often.\n\n  // Read in field 1 of the private channel which is a counter  \n  long count = ThingSpeak.readLongField(counterChannelNumber, counterFieldNumber, myCounterReadAPIKey);  \n\n   // Check the status of the read operation to see if it was successful\n  statusCode = ThingSpeak.getLastReadStatus();\n  if(statusCode == 200){\n    Serial.println(\"Counter: \" + String(count));\n  }\n  else{\n    Serial.println(\"Problem reading channel. HTTP error code \" + String(statusCode)); \n  }\n  \n  delay(15000); // No need to read the counter too often.\n  \n}\n ```\n\n# \u003ca id=\"documentation\"\u003eDocumentation\u003c/a\u003e\n\n## begin\nInitializes the ThingSpeak library and network settings, whether performing a secure connection or a normal connection to ThingSpeak.\n```\nbool begin (client) // defaults to ThingSpeak.com\n```\n\n| Parameter      | Type         | Description                                            |          \n|----------------|:-------------|:-------------------------------------------------------|\n| client         | Client \u0026     | TCPClient created earlier in the sketch                |\n\n### Returns\nAlways returns true. This does not validate the information passed in, or generate any calls to ThingSpeak.\n\n### Remarks\nuse ```#define TS_ENABLE_SSL``` before ```#include \u003cthingspeak.h\u003e``` so as to perform a secure connection by passing a client that is capable of doing SSL. See the note regarding secure connection below.\n\n## writeField\nWrite a value to a single field in a ThingSpeak channel.\n```\nint writeField(channelNumber, field, value, writeAPIKey)\n```\n\n| Parameter     | Type          | Description                                                                                     |          \n|---------------|:--------------|:------------------------------------------------------------------------------------------------|\n| channelNumber | unsigned long | Channel number                                                                                  |\n| field         | unsigned int  | Field number (1-8) within the channel to write to.                                              |\n| value         | int           | Integer value (from -32,768 to 32,767) to write.                                                |\n|               | long          | Long value (from -2,147,483,648 to 2,147,483,647) to write.                                     |\n|               | float         | Floating point value (from -999999000000 to 999999000000) to write.                             |\n|               | String        | String to write (UTF8 string). ThingSpeak limits this field to 255 bytes.                       |\n|               | const char *  | Character array (zero terminated) to write (UTF8). ThingSpeak limits this field to 255 bytes.   |\n| writeAPIKey   | const char *  | Write API key associated with the channel. If you share code with others, do not share this key |\n\n### Returns\nHTTP status code of 200 if successful. See Return Codes below for other possible return values.\n\n### Remarks\nSpecial characters will be automatically encoded by this method. See the note regarding special characters below.\n\n## writeFields\nWrite a multi-field update. Call setField() for each of the fields you want to write first. \n```\nint writeFields (channelNumber, writeAPIKey)\t\n```\n\n| Parameter     | Type          | Description                                                                                     |          \n|---------------|:--------------|:------------------------------------------------------------------------------------------------|\n| channelNumber | unsigned long | Channel number                                                                                  |\n| writeAPIKey   | const char *  | Write API key associated with the channel. If you share code with others, do not share this key |\n\n### Returns\nHTTP status code of 200 if successful. See Return Codes below for other possible return values.\n\n### Remarks\nSpecial characters will be automatically encoded by this method. See the note regarding special characters below.\n\n## writeRaw\nWrite a raw POST to a ThingSpeak channel. \n```\nint writeRaw (channelNumber, postMessage, writeAPIKey)\t\n```\n\n| Parameter     | Type          | Description                                                                                                                                       |          \n|---------------|:--------------|:--------------------------------------------------------------------------------------------------------------------------------------------------|\n| channelNumber | unsigned long | Channel number                                                                                                                                    |\n| postMessage   | const char *  | Raw URL to write to ThingSpeak as a String. See the documentation at https://thingspeak.com/docs/channels#update_feed.                            |\n|               | String        | Raw URL to write to ThingSpeak as a character array (zero terminated). See the documentation at https://thingspeak.com/docs/channels#update_feed. | \n| writeAPIKey   | const char *  | Write API key associated with the channel. If you share code with others, do not share this key                                                   |\n\n### Returns\nHTTP status code of 200 if successful. See Return Codes below for other possible return values.\n\n### Remarks\nThis method will not encode special characters in the post message.  Use '%XX' URL encoding to send special characters. See the note regarding special characters below.\n\n## setField\nSet the value of a single field that will be part of a multi-field update.\n```\nint setField (field, value)\n```\n\n| Parameter | Type         | Description                                                                                   |          \n|-----------|:-------------|:----------------------------------------------------------------------------------------------|\n| field     | unsigned int | Field number (1-8) within the channel to set                                                  |\n| value     | int          | Integer value (from -32,768 to 32,767) to write.                                              |\n|           | long         | Long value (from -2,147,483,648 to 2,147,483,647) to write.                                   |\n|           | float        | Floating point value (from -999999000000 to 999999000000) to write.                           |\n|           | String       | String to write (UTF8 string). ThingSpeak limits this field to 255 bytes.                     |\n|           | const char * | Character array (zero terminated) to write (UTF8). ThingSpeak limits this field to 255 bytes. |\n\n### Returns\nHTTP status code of 200 if successful. See Return Codes below for other possible return values.\n\n## setStatus\nSet the status of a multi-field update. Use status to provide additonal details when writing a channel update. Additionally, status can be used by the ThingTweet App to send a message to Twitter.\n```\nint setStatus (status)\t\n```\n\n| Parameter | Type      | Description                                                                   |          \n|--------|:-------------|:------------------------------------------------------------------------------|\n| status | const char * | String to write (UTF8). ThingSpeak limits this to 255 bytes.                  |\n|        | String       | const character array (zero terminated). ThingSpeak limits this to 255 bytes. |\n\n### Returns\nHTTP status code of 200 if successful. See Return Codes below for other possible return values.\n\n## setLatitude\nSet the latitude of a multi-field update.\n```\nint setLatitude\t(latitude)\t\n```\n\n| Parameter | Type  | Description                                                                |          \n|-----------|:------|:---------------------------------------------------------------------------|\n| latitude  | float | Latitude of the measurement (degrees N, use negative values for degrees S) |\n\n### Returns\nHTTP status code of 200 if successful. See Return Codes below for other possible return values.\n\n## setLongitude\nSet the longitude of a multi-field update.\n```\nint setLongitude (longitude)\t\n```\n\n| Parameter | Type  | Description                                                                 |          \n|-----------|:------|:----------------------------------------------------------------------------|\n| longitude | float | Longitude of the measurement (degrees E, use negative values for degrees W) |\n\n### Returns\nHTTP status code of 200 if successful. See Return Codes below for other possible return values.\n\n## setElevation\nSet the elevation of a multi-field update.\n```\nint setElevation (elevation)\t\n```\n\n| Parameter | Type      | Description                                         |          \n|-----------|:------|:--------------------------------------------------------|\n| elevation | float | \tElevation of the measurement (meters above sea level) |\n\n### Returns\nHTTP status code of 200 if successful. See Return Codes below for other possible return values.\n\n## setCreatedAt\nSet the created-at date of a multi-field update. The timestamp string must be in the ISO 8601 format. Example \"2017-01-12 13:22:54\"\n```\nint setCreatedAt (createdAt)\n```\n\n| Parameter | Type         | Description                                                                                      |          \n|-----------|:-------------|:-------------------------------------------------------------------------------------------------|\n| createdAt | String       | Desired timestamp to be included with the channel update as a String.                            |\n|           | const char * | Desired timestamp to be included with the channel update as a character array (zero terminated). |\n\n### Returns\nHTTP status code of 200 if successful. See Return Codes below for other possible return values.\n\n### Remarks\nTimezones can be set using the timezone hour offset parameter. For example, a timestamp for Eastern Standard Time is: \"2017-01-12 13:22:54-05\". If no timezone hour offset parameter is used, UTC time is assumed.\n\n## setTwitterTweet\nSet the Twitter account and message to use for an update to be tweeted.\n```\nint setTwitterTweet\t(twitter, tweet)\t\n```\n\n| Parameter | Type         | Description                                                                      |          \n|-----------|:-------------|:---------------------------------------------------------------------------------|\n| twitter   | String       | Twitter account name as a String.                                                |\n|           | const char * | Twitter account name as a character array (zero terminated).                     |\n| tweet     | String       | Twitter message as a String (UTF-8) limited to 140 character.                    |\n|           | const char * | Twitter message as a character array (zero terminated) limited to 140 character. |\n\n### Returns\nHTTP status code of 200 if successful. See Return Codes below for other possible return values.\n\n### Remarks\nPrior to using this feature, a twitter account must be linked to your ThingSpeak account. To link your twitter account. login to ThingSpeak and go to Apps -\u003e ThingTweet and click Link Twitter Account.\n\n## readStringField\nRead the latest string from a channel. Include the readAPIKey to read a private channel.\n```\nString readStringField (channelNumber, field, readAPIKey)\t\n```\n```\nString readStringField (channelNumber, field)\t\n```\n\n| Parameter     | Type          | Description                                                                                    |          \n|---------------|:--------------|:-----------------------------------------------------------------------------------------------|\n| channelNumber | unsigned long | Channel number                                                                                 |\n| field         | unsigned int  | Field number (1-8) within the channel to read from.                                            |\n| readAPIKey    | const char *  | Read API key associated with the channel. If you share code with others, do not share this key |\n\n### Returns\nValue read (UTF8 string), or empty string if there is an error.\n\n## readFloatField\nRead the latest float from a channel. Include the readAPIKey to read a private channel.\n```\nfloat readFloatField (channelNumber, field, readAPIKey)\t\n```\n```\nfloat readFloatField (channelNumber, field)\t\n```\n\n| Parameter     | Type          | Description                                                                                    |          \n|---------------|:--------------|:-----------------------------------------------------------------------------------------------|\n| channelNumber | unsigned long | Channel number                                                                                 |\n| field         | unsigned int  | Field number (1-8) within the channel to read from.                                            |\n| readAPIKey    | const char *  | Read API key associated with the channel. If you share code with others, do not share this key |\n\n### Returns\nValue read, or 0 if the field is text or there is an error. Use getLastReadStatus() to get more specific information. Note that NAN, INFINITY, and -INFINITY are valid results. \n\n## readLongField\nRead the latest long from a channel. Include the readAPIKey to read a private channel.\n```\nlong readLongField (channelNumber, field, readAPIKey)\t\n```\n```\nlong readLongField (channelNumber, field)\t\n```\n\n| Parameter     | Type          | Description                                                                                    |          \n|---------------|:--------------|:-----------------------------------------------------------------------------------------------|\n| channelNumber | unsigned long | Channel number                                                                                 |\n| field         | unsigned int  | Field number (1-8) within the channel to read from.                                            |\n| readAPIKey    | const char *  | Read API key associated with the channel. If you share code with others, do not share this key |\n\n### Returns\nValue read, or 0 if the field is text or there is an error. Use getLastReadStatus() to get more specific information. \n\n## readIntField\nRead the latest int from a channel. Include the readAPIKey to read a private channel.\n```\nint readIntField (channelNumber, field, readAPIKey)\t\t\n```\n```\nint readIntField (channelNumber, field)\t\t\n```\n\n| Parameter     | Type          | Description                                                                                    |          \n|---------------|:--------------|:-----------------------------------------------------------------------------------------------|\n| channelNumber | unsigned long | Channel number                                                                                 |\n| field         | unsigned int  | Field number (1-8) within the channel to read from.                                            |\n| readAPIKey    | const char *  | Read API key associated with the channel. If you share code with others, do not share this key |\n\n### Returns\nValue read, or 0 if the field is text or there is an error. Use getLastReadStatus() to get more specific information. If the value returned is out of range for an int, the result is undefined. \n\n## readStatus\nRead the latest status from a channel. Include the readAPIKey to read a private channel.\n```\nString readStatus (channelNumber, readAPIKey)\t\n```\n```\nString readStatus (channelNumber)\n```\n\n| Parameter     | Type          | Description                                                                                    |\n|---------------|:--------------|:-----------------------------------------------------------------------------------------------|\n| channelNumber | unsigned long | Channel number                                                                                 |\n| readAPIKey    | const char *  | Read API key associated with the channel. If you share code with others, do not share this key |\n\n### Returns\nReturns the status field as a String.\n\n## String readCreatedAt()\nRead the created-at timestamp associated with the latest update to a channel. Include the readAPIKey to read a private channel.\n```\nString readCreatedAt (channelNumber, readAPIKey)\n```\n```\nString readCreatedAt (channelNumber)\t\n```\n\n| Parameter     | Type          | Description                                                                                    |\n|---------------|:--------------|:-----------------------------------------------------------------------------------------------|\n| channelNumber | unsigned long | Channel number                                                                                 |\n| readAPIKey    | const char *  | Read API key associated with the channel. If you share code with others, do not share this key |\n\n### Returns\nReturns the created-at timestamp as a String.\n\n## readRaw\nRead a raw response from a channel. Include the readAPIKey to read a private channel.\n```\nString readRaw (channelNumber, URLSuffix, readAPIKey)\t\n```\n```\nString readRaw\t(channelNumber, URLSuffix)\n```\n\n| Parameter     | Type          | Description                                                                                                        |\n|---------------|:--------------|:-------------------------------------------------------------------------------------------------------------------|\n| channelNumber | unsigned long | Channel number                                                                                                     |\n| URLSuffix     | String        | Raw URL to write to ThingSpeak as a String. See the documentation at https://thingspeak.com/docs/channels#get_feed |\n| readAPIKey    | const char *  | Read API key associated with the channel. If you share code with others, do not share this key.                    |     \n\n### Returns\nReturns the raw response from a HTTP request as a String.\n\n## readMultipleFields\nRead all the latest fields, status, location, and created-at timestamp; and store these values locally. Use ```getField``` functions mentioned below to fetch the stored values. Include the readAPIKey to read a private channel.\n```\nint readMultipleFields (channelNumber, readAPIKey)\n```\n```\nint readMultipleFields (channelNumber)\n```\n\n| Parameter     | Type          | Description                                                                                    |\n|---------------|:--------------|:-----------------------------------------------------------------------------------------------|\n| channelNumber | unsigned long | Channel number                                                                                 |\n| readAPIKey    | const char *  | Read API key associated with the channel. If you share code with others, do not share this key |\n\n### Returns\nHTTP status code of 200 if successful. See Return Codes below for other possible return values.\n\n### Remarks\nThis feature not available in Arduino Uno due to memory constraints.\n\n## getFieldAsString\nFetch the stored value from a field as String. Invoke this after invoking ```readMultipleFields```.\n```\nString getFieldAsString (field)\n```\n| Parameter     | Type          | Description                                                                                    |\n|---------------|:--------------|:-----------------------------------------------------------------------------------------------|\n| field         | unsigned int  | Field number (1-8) within the channel to read from.                                            |\n\n### Returns\nValue read (UTF8 string), empty string if there is an error, or old value read (UTF8 string) if invoked before readMultipleFields().  Use getLastReadStatus() to get more specific information.\n\n### Remarks\nThis feature not available in Arduino Uno due to memory constraints.\n\n## getFieldAsFloat\nFetch the stored value from a field as Float. Invoke this after invoking ```readMultipleFields```.\n```\nfloat getFieldAsFloat (field)\n```\n| Parameter     | Type          | Description                                                                                    |\n|---------------|:--------------|:-----------------------------------------------------------------------------------------------|\n| field         | unsigned int  | Field number (1-8) within the channel to read from.                                            |\n\n### Returns\nValue read, 0 if the field is text or there is an error, or old value read if invoked before readMultipleFields(). Use getLastReadStatus() to get more specific information. Note that NAN, INFINITY, and -INFINITY are valid results. \n\n### Remarks\nThis feature not available in Arduino Uno due to memory constraints.\n\n## getFieldAsLong\nFetch the stored value from a field as Long. Invoke this after invoking ```readMultipleFields```.\n```\nlong getFieldAsLong (field)\n```\n| Parameter     | Type          | Description                                                                                    |\n|---------------|:--------------|:-----------------------------------------------------------------------------------------------|\n| field         | unsigned int  | Field number (1-8) within the channel to read from.                                            |\n\n### Returns\nValue read, 0 if the field is text or there is an error, or old value read if invoked before readMultipleFields(). Use getLastReadStatus() to get more specific information.\n\n### Remarks\nThis feature not available in Arduino Uno due to memory constraints.\n\n## getFieldAsInt\nFetch the stored value from a field as Int. Invoke this after invoking ```readMultipleFields```.\n```\nint getFieldAsInt (field)\n```\n| Parameter     | Type          | Description                                                                                    |\n|---------------|:--------------|:-----------------------------------------------------------------------------------------------|\n| field         | unsigned int  | Field number (1-8) within the channel to read from.                                            |\n\n### Returns\nValue read, 0 if the field is text or there is an error, or old value read if invoked before readMultipleFields(). Use getLastReadStatus() to get more specific information.\n\n### Remarks\nThis feature not available in Arduino Uno due to memory constraints.\n\n## getLastReadStatus\nGet the status of the previous read.\n```\nint getLastReadStatus ()\t\n```\n\n### Returns\nSee Return Codes below for other possible return values.\n\n## Return Codes\n| Value | Meaning                                                                                 |\n|-------|:----------------------------------------------------------------------------------------|\n| 200   | OK / Success                                                                            |\n| 404   | Incorrect API key (or invalid ThingSpeak server address)                                |\n| -101  | Value is out of range or string is too long (\u003e 255 characters)                          |\n| -201  | Invalid field number specified                                                          |\n| -210  | setField() was not called before writeFields()                                          |\n| -301  | Failed to connect to ThingSpeak                                                         |\n| -302  | Unexpected failure during write to ThingSpeak                                           |\n| -303  | Unable to parse response                                                                |\n| -304  | Timeout waiting for server to respond                                                   |\n| -401  | Point was not inserted (most probable cause is the rate limit of once every 15 seconds) |\n|    0  | Other error                                                                             |\n\n## Secure Connection\nSecurely connect to ThingSpeak API to use the above features and functionalities.\n\n### HTTPS\nHTTPS ensures confidentiality as well as authenticity.\nConfidentiality: SSL Encryption using public-key cryptography.\nAuthenticity: creates \"trust\", the device knows whether it's connected to the actual api.thingkspeak.com and not a spoof of it.\n\n### User Sketch Requirements\nAlways use ```#define TS_ENABLE_SSL``` before ```#include \u003cthingspeak.h\u003e``` so as to perform a secure connection. If not, then the default connection would be insecured HTTP.\n\n#### Confidentiality without Authenticity\nCase 1: TS_ENABLE_SSL macro defined + Client capable of doing SSL = Secure HTTPS Connection \u003cbr\u003e\nCase 2: TS_ENABLE_SSL macro defined + Client not capable of SSL = Defualt HTTP connection with a warning message sent to the user \u003cbr\u003e\nCase 3: TS_ENABLE_SSL macro undefined + Client capable of doing SSL = Error connecting to ThingSpeak status code returned to user \u003cbr\u003e\nCase 4: TS_ENABLE_SSL macro undefined + Client not capable of SSL =  HTTP connection\n\n#### Confidentiality + Authenticity\nDifferent client libraries have different methods of performing authenticity. \u003cbr\u003e\nSome ways: Root Certificate Check, Certificate Fingerprint Check. \u003cbr\u003e\nPerform the fingerprint and/or certificate check prior to invoking the ```begin()``` function. \u003cbr\u003e\nThe certificate has an expiration date associated with it, and hence it's the user's responsibility to fetch the updated certificate for the Confidentiality + Authenticity HTTPS connection to be established. \u003cbr\u003e\nSee the ReadMultipleFieldsSecure example on Fingerprint check HTTPS connection using ESP8266.\nSee the ReadMultipleFieldsSecure example on Root Certificate check HTTPS connection using ESP32.\n\n## Special Characters\nSome characters require '%XX' style URL encoding before sending to ThingSpeak.  The writeField() and writeFields() methods will perform the encoding automatically.  The writeRaw() method will not.\n\n| Character  | Encoding |\n|------------|:---------|\n|     \"      | %22      |\n|     %      | %25      |\n|     \u0026      | %26      |\n|     +      | %2B      |\n|     ;      | %3B      |\n\nControl characters, ASCII values 0 though 31, are not accepted by ThingSpeak and will be ignored.  Extended ASCII characters with values above 127 will also be ignored. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathworks%2Fthingspeak-arduino","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmathworks%2Fthingspeak-arduino","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathworks%2Fthingspeak-arduino/lists"}