{"id":19129848,"url":"https://github.com/mathworks/thingspeak-particle","last_synced_at":"2025-05-06T00:37:53.055Z","repository":{"id":36727890,"uuid":"41034468","full_name":"mathworks/thingspeak-particle","owner":"mathworks","description":"ThingSpeak Communication Library for Particle","archived":false,"fork":false,"pushed_at":"2025-04-15T16:42:07.000Z","size":350,"stargazers_count":21,"open_issues_count":1,"forks_count":22,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-15T17:42:50.259Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.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","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-08-19T13:10:02.000Z","updated_at":"2025-04-15T16:40:12.000Z","dependencies_parsed_at":"2025-04-20T04:48:02.629Z","dependency_job_id":null,"html_url":"https://github.com/mathworks/thingspeak-particle","commit_stats":{"total_commits":79,"total_committers":4,"mean_commits":19.75,"dds":0.189873417721519,"last_synced_commit":"dd5fef9deac1da149db24078c0d2169e82b37cfc"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks%2Fthingspeak-particle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks%2Fthingspeak-particle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks%2Fthingspeak-particle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks%2Fthingspeak-particle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mathworks","download_url":"https://codeload.github.com/mathworks/thingspeak-particle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252600736,"owners_count":21774647,"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.447Z","updated_at":"2025-05-06T00:37:53.038Z","avatar_url":"https://github.com/mathworks.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ThingSpeak Communication Library for Particle\r\n\r\nThis library enables Particle hardware to write or read data to or from ThingSpeak, an open data platform for the Internet of Things with MATLAB analytics and visualization.\r\n\r\nThingSpeak offers free data storage and analysis of time-stamped numeric or alphanumeric data. Users can access ThingSpeak by visiting https://thingspeak.com and creating a ThingSpeak user account.\r\n\r\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.\r\n\r\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.\r\n\r\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.\r\n\r\n#### Particle Web IDE\r\nIn the Particle Web IDE, click the libraries tab, find ThingSpeak, and choose \"Include in App\"\r\n\r\n## Compatible Hardware:\r\n* Particle (Formally Spark) Core, [Photon](https://www.particle.io/prototype#photon), [Electron](https://www.particle.io/prototype#electron) and [P1](https://www.particle.io/prototype#p0-and-p1).\r\n\r\n# Some Quick Examples\r\n\r\n## Write to a Channel Field\r\n```\r\n#include \"ThingSpeak.h\"\r\n\r\nTCPClient client;\r\n\r\nunsigned long myChannelNumber = 31461;\t// change this to your channel number\r\nconst char * myWriteAPIKey = \"LD79EOAAWRVYF04Y\"; // change this to your channels write API key\r\n\r\nvoid setup() {\r\n\tThingSpeak.begin(client);\r\n}\r\n\r\nvoid loop() {\r\n\t// read the input on analog pin 0:\r\n\tint sensorValue = analogRead(A0);\r\n\t\r\n\t// Write to ThingSpeak, field 1, immediately\r\n\tThingSpeak.writeField(myChannelNumber, 1, sensorValue, myWriteAPIKey);\r\n\tdelay(20000); // ThingSpeak will only accept updates every 15 seconds.\r\n}\r\n\r\n```\r\n## Write to a Multiple Channel fields at once\r\n```\r\n#include \"ThingSpeak.h\"\r\n\r\nTCPClient client;\r\n\r\nunsigned long myChannelNumber = 31461;\t// change this to your channel number\r\nconst char * myWriteAPIKey = \"LD79EOAAWRVYF04Y\"; // change this to your channel write API key\r\n\r\nvoid setup() {\r\n\tThingSpeak.begin(client);\r\n}\r\n\r\nvoid loop(){\r\n\t// read the input on analog pins 1, 2 and 3:\r\n\tint sensorValue1 = analogRead(A1);\r\n\tint sensorValue2 = analogRead(A2);\r\n\tint sensorValue3 = analogRead(A3);\r\n\t\r\n\t// set fields one at a time\r\n\tThingSpeak.setField(1,sensorValue1);\r\n\tThingSpeak.setField(2,sensorValue2);\r\n\tThingSpeak.setField(3,sensorValue3);\r\n\t\r\n\t// set the status if over the threshold\r\n\tif(sensorValue1 \u003e 100){\r\n\t\tThingSpeak.setStatus(\"ALERT! HIGH VALUE\");\r\n\t}\r\n\t\r\n\t// Write the fields that you've set all at once.\r\n\tThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);\r\n\t\r\n\tdelay(20000); // ThingSpeak will only accept updates every 15 seconds.\r\n}\r\n\r\n```\r\n## Read from a Public Channel\r\n```\r\n#include \"ThingSpeak.h\"\r\n\r\nTCPClient client;\r\n\r\nunsigned long weatherStationChannelNumber = 12397;\r\n\r\nvoid setup() { \r\n  ThingSpeak.begin(client);\r\n}\r\n\r\nvoid loop(){\r\n\t\r\n\t// Read latest measurements from the weather station in Natick, MA\r\n\tfloat temperature = ThingSpeak.readFloatField(weatherStationChannelNumber,4);\r\n\tfloat humidity = ThingSpeak.readFloatField(weatherStationChannelNumber,3);\r\n\t\r\n\tParticle.publish(\"thingspeak-weather\", \"Current weather conditions in Natick: \",60,PRIVATE);\r\n\tParticle.publish(\"thingspeak-weather\", String(temperature) + \" degrees F, \" + String(humidity) + \"% humidity\",60,PRIVATE); \r\n\t\r\n\tdelay(60000); // Note that the weather station only updates once a minute\r\n\r\n}\r\n```\r\n## Read from a Private Channel\r\n```\r\n#include \"ThingSpeak.h\"\r\n\r\nTCPClient client;\r\n\r\nunsigned long myChannelNumber = 31461;\r\nconst char * myReadAPIKey = \"NKX4Z5JGO4M5I18A\";\r\n\r\nvoid setup() { \r\n  ThingSpeak.begin(client);\r\n}\r\n\r\nvoid loop(){\r\n\t\r\n\t // Read the latest value from field 1 of channel 31461\r\n\tfloat value = ThingSpeak.readFloatField(myChannelNumber, 1, myReadAPIKey);\r\n\t\r\n\tParticle.publish(\"thingspeak-value\", \"Latest value is: \" + String(value),60,PRIVATE);\r\n\tdelay(30000);\r\n\r\n}\r\n```\r\n\r\n## Read multiple fields from last feed ingested in a Channel\r\n```\r\n#include \"ThingSpeak.h\"\r\n\r\nTCPClient client;\r\n\r\nunsigned long weatherStationChannelNumber = 12397;\r\n\r\nvoid setup() { \r\n  ThingSpeak.begin(client);\r\n}\r\n\r\nvoid loop(){\r\n\r\n  // Read latest measurements from the weather station in Natick, MA\r\n  // when reading from a private channel, pass the channel  ReadApi key\r\n  statusCodeRead = ThingSpeak.readMultipleFields(weatherStationChannelNumber);\r\n\t\r\n  // Wind Direction (North = 0 degrees)\r\n  float windDirection = ThingSpeak.getFieldAsFloat(1);\r\n\r\n  // Wind Speed (mph)\r\n  float windSpeed = ThingSpeak.getFieldAsFloat(2);\r\n\r\n  // Humidity (%)\r\n  float humidity = ThingSpeak.getFieldAsFloat(3);\r\n\r\n  // Temperature (F)\r\n\tfloat temperature = ThingSpeak.getFieldAsFloat(4);\r\n\r\n  // Rain (Inches/minute)\r\n  float rain = ThingSpeak.getFieldAsFloat(5);\r\n\r\n  // Pressure (\"Hg)\r\n\tfloat pressure = ThingSpeak.getFieldAsFloat(6);\r\n\r\n  // Power Level (V)\r\n  float powerLevel = ThingSpeak.getFieldAsFloat(7);\r\n\r\n  // Light Intensity\r\n\tfloat pressure = ThingSpeak.getFieldAsFloat(8);\r\n\t\r\n\tParticle.publish(\"thingspeak-weather\", \"Current weather conditions in Natick: \",60,PRIVATE);\r\n\tParticle.publish(\"thingspeak-weather\", String(temperature) + \" degrees F, \" + String(humidity) + \"% humidity\",60,PRIVATE); \r\n\t\r\n\tdelay(60000); // Note that the weather station only updates once a minute\r\n\r\n}\r\n```\r\n\r\n# \u003ca id=\"documentation\"\u003eDocumentation\u003c/a\u003e\r\n\r\n## begin\r\nInitializes the ThingSpeak library and network settings.\r\n```\r\nbool begin (client)  // defaults to port 80\r\n```\r\n```\r\nbool begin (client, port)\r\n```\r\n| Parameter      | Type         | Description                                            |          \r\n|----------------|:-------------|:-------------------------------------------------------|\r\n| client         | Client \u0026     | TCPClient created earlier in the sketch                |\r\n\r\n| port           | unsigned int | Specific port number to use                            |\r\n\r\n### Returns\r\nAlways returns true. This does not validate the information passed in, or generate any calls to ThingSpeak.\r\n\r\n## writeField\r\nWrite a value to a single field in a ThingSpeak channel.\r\n```\r\nint writeField(channelNumber, field, value, writeAPIKey)\r\n```\r\n| Parameter     | Type          | Description                                                                                     |          \r\n|---------------|:--------------|:------------------------------------------------------------------------------------------------|\r\n| channelNumber | unsigned long | Channel number                                                                                  |\r\n| field         | unsigned int  | Field number (1-8) within the channel to write to.                                              |\r\n| value         | int           | Integer value (from -32,768 to 32,767) to write.                                                |\r\n|               | long          | Long value (from -2,147,483,648 to 2,147,483,647) to write.                                     |\r\n|               | float         | Floating point value (from -999999000000 to 999999000000) to write.                             |\r\n|               | String        | String to write (UTF8 string). ThingSpeak limits this field to 255 bytes.                       |\r\n|               | const char *  | Character array (zero terminated) to write (UTF8). ThingSpeak limits this field to 255 bytes.   |\r\n| writeAPIKey   | const char *  | Write API key associated with the channel. If you share code with others, do not share this key |\r\n\r\n### Returns\r\nHTTP status code of 200 if successful. See Return Codes below for other possible return values.\r\n\r\n### Remarks\r\nSpecial characters will be automatically encoded by this method. See the note regarding special characters below.\r\n\r\n## writeFields\r\nWrite a multi-field update. Call setField() for each of the fields you want to write first. \r\n```\r\nint writeFields (channelNumber, writeAPIKey)\t\r\n```\r\n| Parameter     | Type          | Description                                                                                     |          \r\n|---------------|:--------------|:------------------------------------------------------------------------------------------------|\r\n| channelNumber | unsigned long | Channel number                                                                                  |\r\n| writeAPIKey   | const char *  | Write API key associated with the channel. If you share code with others, do not share this key |\r\n\r\n### Returns\r\nHTTP status code of 200 if successful. See Return Codes below for other possible return values.\r\n\r\n### Remarks\r\nSpecial characters will be automatically encoded by this method. See the note regarding special characters below.\r\n\r\n## writeRaw\r\nWrite a raw POST to a ThingSpeak channel. \r\n```\r\nint writeRaw (channelNumber, postMessage, writeAPIKey)\t\r\n```\r\n\r\n| Parameter     | Type          | Description                                                                                                                                       |          \r\n|---------------|:--------------|:--------------------------------------------------------------------------------------------------------------------------------------------------|\r\n| channelNumber | unsigned long | Channel number                                                                                                                                    |\r\n| postMessage   | const char *  | Raw URL to write to ThingSpeak as a String. See the documentation at https://thingspeak.com/docs/channels#update_feed.                            |\r\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. | \r\n| writeAPIKey   | const char *  | Write API key associated with the channel. If you share code with others, do not share this key                                                   |\r\n\r\n### Returns\r\nHTTP status code of 200 if successful. See Return Codes below for other possible return values.\r\n\r\n### Remarks\r\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.\r\n\r\n## setField\r\nSet the value of a single field that will be part of a multi-field update.\r\n```\r\nint setField (field, value)\r\n```\r\n\r\n| Parameter | Type         | Description                                                                                   |          \r\n|-----------|:-------------|:----------------------------------------------------------------------------------------------|\r\n| field     | unsigned int | Field number (1-8) within the channel to set                                                  |\r\n| value     | int          | Integer value (from -32,768 to 32,767) to write.                                              |\r\n|           | long         | Long value (from -2,147,483,648 to 2,147,483,647) to write.                                   |\r\n|           | float        | Floating point value (from -999999000000 to 999999000000) to write.                           |\r\n|           | String       | String to write (UTF8 string). ThingSpeak limits this field to 255 bytes.                     |\r\n|           | const char * | Character array (zero terminated) to write (UTF8). ThingSpeak limits this field to 255 bytes. |\r\n\r\n### Returns\r\nHTTP status code of 200 if successful. See Return Codes below for other possible return values.\r\n\r\n## setStatus\r\nSet the status of a multi-field update. Use status to provide additonal details when writing a channel update. \r\n```\r\nint setStatus (status)\t\r\n```\r\n\r\n| Parameter | Type      | Description                                                                   |          \r\n|--------|:-------------|:------------------------------------------------------------------------------|\r\n| status | const char * | String to write (UTF8). ThingSpeak limits this to 255 bytes.                  |\r\n|        | String       | const character array (zero terminated). ThingSpeak limits this to 255 bytes. |\r\n\r\n### Returns\r\nHTTP status code of 200 if successful. See Return Codes below for other possible return values.\r\n\r\n## setLatitude\r\nSet the latitude of a multi-field update.\r\n```\r\nint setLatitude\t(latitude)\t\r\n```\r\n\r\n| Parameter | Type  | Description                                                                |          \r\n|-----------|:------|:---------------------------------------------------------------------------|\r\n| latitude  | float | Latitude of the measurement (degrees N, use negative values for degrees S) |\r\n\r\n### Returns\r\nHTTP status code of 200 if successful. See Return Codes below for other possible return values.\r\n\r\n## setLongitude\r\nSet the longitude of a multi-field update.\r\n```\r\nint setLongitude (longitude)\t\r\n```\r\n\r\n| Parameter | Type  | Description                                                                 |          \r\n|-----------|:------|:----------------------------------------------------------------------------|\r\n| longitude | float | Longitude of the measurement (degrees E, use negative values for degrees W) |\r\n\r\n### Returns\r\nHTTP status code of 200 if successful. See Return Codes below for other possible return values.\r\n\r\n## setElevation\r\nSet the elevation of a multi-field update.\r\n```\r\nint setElevation (elevation)\t\r\n```\r\n\r\n| Parameter | Type      | Description                                         |          \r\n|-----------|:------|:--------------------------------------------------------|\r\n| elevation | float | \tElevation of the measurement (meters above sea level) |\r\n\r\n### Returns\r\nHTTP status code of 200 if successful. See Return Codes below for other possible return values.\r\n\r\n## setCreatedAt\r\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\"\r\n```\r\nint setCreatedAt (createdAt)\r\n```\r\n\r\n| Parameter | Type         | Description                                                                                      |          \r\n|-----------|:-------------|:-------------------------------------------------------------------------------------------------|\r\n| createdAt | String       | Desired timestamp to be included with the channel update as a String.                            |\r\n|           | const char * | Desired timestamp to be included with the channel update as a character array (zero terminated). |\r\n\r\n### Returns\r\nHTTP status code of 200 if successful. See Return Codes below for other possible return values.\r\n\r\n### Remarks\r\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.\r\n\r\n## readStringField\r\nRead the latest string from a channel. Include the readAPIKey to read a private channel.\r\n```\r\nString readStringField (channelNumber, field, readAPIKey)\t\r\n```\r\n```\r\nString readStringField (channelNumber, field)\t\r\n```\r\n\r\n| Parameter     | Type          | Description                                                                                    |          \r\n|---------------|:--------------|:-----------------------------------------------------------------------------------------------|\r\n| channelNumber | unsigned long | Channel number                                                                                 |\r\n| field         | unsigned int  | Field number (1-8) within the channel to read from.                                            |\r\n| readAPIKey    | const char *  | Read API key associated with the channel. If you share code with others, do not share this key |\r\n\r\n### Returns\r\nValue read (UTF8 string), or empty string if there is an error.\r\n\r\n## readFloatField\r\nRead the latest float from a channel. Include the readAPIKey to read a private channel.\r\n```\r\nfloat readFloatField (channelNumber, field, readAPIKey)\t\r\n```\r\n```\r\nfloat readFloatField (channelNumber, field)\t\r\n```\r\n\r\n| Parameter     | Type          | Description                                                                                    |          \r\n|---------------|:--------------|:-----------------------------------------------------------------------------------------------|\r\n| channelNumber | unsigned long | Channel number                                                                                 |\r\n| field         | unsigned int  | Field number (1-8) within the channel to read from.                                            |\r\n| readAPIKey    | const char *  | Read API key associated with the channel. If you share code with others, do not share this key |\r\n\r\n### Returns\r\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. \r\n\r\n## readLongField\r\nRead the latest long from a channel. Include the readAPIKey to read a private channel.\r\n```\r\nlong readLongField (channelNumber, field, readAPIKey)\t\r\n```\r\n```\r\nlong readLongField (channelNumber, field)\t\r\n```\r\n\r\n| Parameter     | Type          | Description                                                                                    |          \r\n|---------------|:--------------|:-----------------------------------------------------------------------------------------------|\r\n| channelNumber | unsigned long | Channel number                                                                                 |\r\n| field         | unsigned int  | Field number (1-8) within the channel to read from.                                            |\r\n| readAPIKey    | const char *  | Read API key associated with the channel. If you share code with others, do not share this key |\r\n\r\n### Returns\r\nValue read, or 0 if the field is text or there is an error. Use getLastReadStatus() to get more specific information. \r\n\r\n## readIntField\r\nRead the latest int from a channel. Include the readAPIKey to read a private channel.\r\n```\r\nint readIntField (channelNumber, field, readAPIKey)\t\t\r\n```\r\n```\r\nint readIntField (channelNumber, field)\t\t\r\n```\r\n\r\n| Parameter     | Type          | Description                                                                                    |          \r\n|---------------|:--------------|:-----------------------------------------------------------------------------------------------|\r\n| channelNumber | unsigned long | Channel number                                                                                 |\r\n| field         | unsigned int  | Field number (1-8) within the channel to read from.                                            |\r\n| readAPIKey    | const char *  | Read API key associated with the channel. If you share code with others, do not share this key |\r\n\r\n### Returns\r\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. \r\n\r\n## readStatus\r\nRead the latest status from a channel. Include the readAPIKey to read a private channel.\r\n```\r\nString readStatus (channelNumber, readAPIKey)\t\r\n```\r\n```\r\nString readStatus (channelNumber)\r\n```\r\n\r\n| Parameter     | Type          | Description                                                                                    |          \r\n|---------------|:--------------|:-----------------------------------------------------------------------------------------------|\r\n| channelNumber | unsigned long | Channel number                                                                                 |\r\n| readAPIKey    | const char *  | Read API key associated with the channel. If you share code with others, do not share this key |\r\n\r\n### Returns\r\nReturns the status field as a String.\r\n\r\n## String readCreatedAt()\r\nRead the created-at timestamp associated with the latest update to a channel. Include the readAPIKey to read a private channel.\r\n```\r\nString readCreatedAt (channelNumber, readAPIKey)\r\n```\r\n```\r\nString readCreatedAt (channelNumber)\t\r\n```\r\n\r\n| channelNumber | unsigned long | Channel number                                                                                 |\r\n| readAPIKey    | const char *  | Read API key associated with the channel. If you share code with others, do not share this key |\r\n\r\n### Returns\r\nReturns the created-at timestamp as a String.\r\n\r\n## readRaw\r\nRead a raw response from a channel. Include the readAPIKey to read a private channel.\r\n```\r\nString readRaw (channelNumber, URLSuffix, readAPIKey)\t\r\n```\r\n```\r\nString readRaw\t(channelNumber, URLSuffix)\r\n```\r\n\r\n| Parameter     | Type          | Description                                                                                                        |          \r\n|---------------|:--------------|:-------------------------------------------------------------------------------------------------------------------|\r\n| channelNumber | unsigned long | Channel number                                                                                                     |\r\n| URLSuffix     | String        | Raw URL to write to ThingSpeak as a String. See the documentation at https://thingspeak.com/docs/channels#get_feed |\r\n| readAPIKey    | const char *  | Read API key associated with the channel. If you share code with others, do not share this key.                    |     \r\n\r\n### Returns\r\nReturns the raw response from a HTTP request as a String.\r\n\r\n## getLastReadStatus\r\nGet the status of the previous read.\r\n```\r\nint getLastReadStatus ()\t\r\n```\r\n\r\n## readMultipleFields\r\nRead all the field values, status message, location coordinates, and created-at timestamp associated with the latest feed to a ThingSpeak channel.\r\nThe values are stored in a struct, which holds all the 8 fields data, along with status, latitude, longitude, elevation and createdAt associated with the latest field.\r\nTo retrieve all the values, invoke these functions in order:\r\n1. readMultipleFields\r\n2. readMultipleFields helper functions\r\n\r\n### 1. readMultipleFields\r\n\r\n```\r\nint readMultipleFields (channelNumber, readAPIKey)\t\t\r\n```\r\n```\r\nint readMultipleFields (channelNumber)\t\t\r\n```\r\n\r\n| Parameter     | Type          | Description                                                                                    |          \r\n|---------------|:--------------|:-----------------------------------------------------------------------------------------------|\r\n| channelNumber | unsigned long | Channel number |\r\n| readAPIKey    | const char *  | Read API key associated with the channel. If you share code with others, do not share this key |\r\n\r\n#### Returns\r\nHTTP status code of 200 if successful\r\n\r\n\r\n#### 2. readMultipleFields helper functions\r\n\r\n#### a. getFieldAsString\r\n\r\n```\r\nString getFieldAsString (field)\t\t\r\n```\r\n\r\n| Parameter     | Type          | Description                                                                                    |          \r\n|---------------|:--------------|:-----------------------------------------------------------------------------------------------|\r\n| field         | unsigned int  | Field number (1-8) within the channel to read from.    \r\n\r\n#### Returns\r\nValue read (UTF8 string), empty string if there is an error, or old value read (UTF8 string) if invoked before readMultipleFields().\r\n\r\n\r\n#### b. getFieldAsFloat\r\n\r\n```\r\nfloat getFieldAsFloat (field)\t\t\r\n```\r\n\r\n| Parameter     | Type          | Description                                                                                    |          \r\n|---------------|:--------------|:-----------------------------------------------------------------------------------------------|\r\n| field         | unsigned int  | Field number (1-8) within the channel to read from.    \r\n\r\n#### Returns\r\nValue read, 0 if the field is text or there is an error, or old value read if invoked before readMultipleFields().\r\n\r\n#### c. getFieldAsLong\r\n\r\n```\r\nlong getFieldAsLong (field)\t\t\r\n```\r\n\r\n| Parameter     | Type          | Description                                                                                    |          \r\n|---------------|:--------------|:-----------------------------------------------------------------------------------------------|\r\n| field         | unsigned int  | Field number (1-8) within the channel to read from.    \r\n\r\n#### Returns\r\nValue read, 0 if the field is text or there is an error, or old value read if invoked before readMultipleFields().\r\n\r\n#### d. getFieldAsInt\r\n\r\n```\r\nint getFieldAsInt (field)\t\t\r\n```\r\n\r\n| Parameter     | Type          | Description                                                                                    |          \r\n|---------------|:--------------|:-----------------------------------------------------------------------------------------------|\r\n| field         | unsigned int  | Field number (1-8) within the channel to read from.    \r\n\r\n#### Returns\r\nValue read, 0 if the field is text or there is an error, or old value read if invoked before readMultipleFields().\r\n\r\n#### e. getStatus\r\n\r\n```\r\nString getStatus ()\t\t\r\n```\r\n\r\n#### Returns\r\nValue read (UTF8 string). An empty string is returned if there was no status written to the channel or in case of an error.\r\n\r\n#### f. getLatitude\r\n\r\n```\r\nString getLatitude ()\t\r\n```\r\n\r\n#### Returns\r\nValue read (UTF8 string). An empty string is returned if there was no latitude written to the channel or in case of an error.\r\n\r\n#### g. getLongitude\r\n\r\n```\r\nString getLongitude\t()\r\n```\r\n\r\n#### Returns\r\nValue read (UTF8 string). An empty string is returned if there was no longitude written to the channel or in case of an error.\r\n\r\n#### h. getElevation\r\n\r\n```\r\nString getElevation ()\t\r\n```\r\n\r\n#### Returns\r\nValue read (UTF8 string). An empty string is returned if there was no elevation written to the channel or in case of an error.\r\n\r\n#### i. getCreatedAt\r\n\r\n```\r\nString getCreatedAt ()\r\n```\r\n\r\n#### Returns\r\nValue read (UTF8 string). An empty string is returned if there was no created-at timestamp written to the channel or in case of an error.\r\n\r\n\r\n\r\n## Return Codes\r\n| Value | Meaning                                                                                   |\r\n|-------|:----------------------------------------------------------------------------------------|\r\n| 200   | OK / Success                                                                            |\r\n| 404   | Incorrect API key (or invalid ThingSpeak server address)                                |\r\n| -101  | Value is out of range or string is too long (\u003e 255 characters)                          |\r\n| -201  | Invalid field number specified                                                          |\r\n| -210  | setField() was not called before writeFields()                                          |\r\n| -301  | Failed to connect to ThingSpeak                                                         |\r\n| -302  | Unexpected failure during write to ThingSpeak                                           |\r\n| -303  | Unable to parse response                                                                |\r\n| -304  | Timeout waiting for server to respond                                                   |\r\n| -401  | Point was not inserted (most probable cause is the rate limit of once every 15 seconds) |\r\n|    0  | Other error                                                                             |\r\n\r\n## Special Characters\r\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.\r\n\r\n| Character  | Encoding |\r\n|------------|:---------|\r\n|     \"      | %22      |\r\n|     %      | %25      |\r\n|     \u0026      | %26      |\r\n|     +      | %2B      |\r\n|     ;      | %3B      |\r\n\r\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. \r\n\r\n# Additional Examples\r\n\r\nThe library source includes several examples to help you get started. These are accessible in ThingSpeak library section of the Particle Web IDE.\r\n\r\n* **CheerLights:** Reads the latest CheerLights color on ThingSpeak, and sets an RGB LED.\r\n* **ReadLastTemperature:** Reads the latest temperature from the public MathWorks weather station in Natick, MA on ThingSpeak.\r\n* **ReadPrivateChannel:** Reads the latest voltage value from a private channel on ThingSpeak.\r\n* **ReadWeatherStation:** Reads the latest weather data from the public MathWorks weather station in Natick, MA on ThingSpeak.\r\n* **WriteMultipleVoltages:** Reads analog voltages from pins A1-A6 and writes them to the fields of a channel on ThingSpeak.\r\n* **WriteVoltage:** Reads an analog voltage from pin 0, converts to a voltage, and writes it to a channel on ThingSpeak.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathworks%2Fthingspeak-particle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmathworks%2Fthingspeak-particle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathworks%2Fthingspeak-particle/lists"}