Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
ThingSpeak.h
00001 #ifndef THINGSPEAK_H 00002 #define THINGSPEAK_H 00003 #define HOSTNAME "mbed" 00004 #include "mbed.h" 00005 #include "EthernetNetIf.h" 00006 #include "HTTPClient.h" 00007 00008 /** Class for sending data to ThingSpeak over ethernet, 00009 * Class is using old mbed library revision and SensorsThingSpeak from 00010 * https://developer.mbed.org/teams/TVZ-Mechatronics-Team/code/SensorsThingSpeak/ 00011 * Example: 00012 * @code 00013 * #include "mbed.h" 00014 * #include "ThingSpeak.h" 00015 * 00016 * ThingSpeak thingSpeak("XXXXXXXXXXXXXXXX"); 00017 * 00018 * int main() { 00019 * int i = 1; 00020 * flot value = 3.14; 00021 * thingSpeak.connect(); 00022 * thingSpeak.setField(value,i) 00023 * thingSpeak.putUp(); 00024 * } 00025 * @endcode 00026 */ 00027 class ThingSpeak 00028 { 00029 00030 public: 00031 /** Write api key provided from ThingSpek channel. 00032 * @param: write api key provided from ThingSpeak channel. 00033 */ 00034 ThingSpeak(char*); 00035 /** 00036 * Establishing ethernet connection until connected. 00037 * 00038 */ 00039 void connect(); 00040 00041 /** 00042 * Funkcion for pulling data from ThingSpeak. 00043 * @param readKey Channel feed number 00044 * @param Field number. 00045 */ 00046 float pull(long int, int); 00047 00048 00049 void putUp(); 00050 /** 00051 *Setting values to the field, they should be set in order. 00052 * It's not required to set them all (example: you can set 1, 2, 3 or 1, 3) 00053 * @param Field value to store on. 00054 * @param i number of a field. 00055 */ 00056 void setField(float field, int i); 00057 private: 00058 00059 char* thingSpeakUrl; 00060 char* thingSpeakRead; 00061 char* thingSpeakKey; 00062 char urlBuffer[1023]; 00063 char fieldBuffer[1023]; 00064 EthernetNetIf eth; 00065 EthernetErr ethErr; 00066 HTTPClient http; 00067 IpAddr ethIp; 00068 HTTPText resp; 00069 HTTPResult res; 00070 }; 00071 00072 #endif
Generated on Sat Jul 16 2022 20:38:28 by
1.7.2