![](/media/cache/group/TVZ_logotip.png.50x50_q85.jpg)
Uploading sensor data (voltage divider, MAX4172, INA219) over Ethernet to Thing Speak service. Uses old mbed revision that is compatible with NetServices library. I2C communication is made with I2CR library.
Dependencies: C12832 I2CR INA219 NetServices mbed
Fork of NetServices_HelloWorld by
Diff: ThingSpeak.h
- Revision:
- 7:1da0a084cd69
- Parent:
- 6:ebbde59c5a1d
- Child:
- 8:9b35ac104ab7
diff -r ebbde59c5a1d -r 1da0a084cd69 ThingSpeak.h --- a/ThingSpeak.h Fri Nov 20 08:28:11 2015 +0000 +++ b/ThingSpeak.h Sun Nov 29 13:41:05 2015 +0000 @@ -1,3 +1,23 @@ +/** Class for sending data to ThingSpeak over ethernet, + * Class is using old mbed library revision and EthernetNetIf from + * https://developer.mbed.org/users/okini3939/notebook/TCPSocket_jp/ + * Example: + * @code + * #include "mbed.h" + * #include "ThingSpeak.h" + * + * ThingSpeak thingSpeak("XXXXXXXXXXXXXXXX"); + * + * int main() { + * int i = 1; + * flot value = 3.14; + * thingSpeak.connect(); + * thingSpeak.setField(value,i) + * thingSpeak.putUp(); + * } + * @endcode +*/ + #ifndef THINGSPEAK_H #define THINGSPEAK_H #define HOSTNAME "mbed" @@ -6,27 +26,48 @@ #include "HTTPClient.h" -class ThingSpeak { - - public: - - ThingSpeak(char*, const int); - void connect(); - void getIP(); - void putUp(); - void setField(float, int); - private: - - char* thingSpeakUrl; - char* thingSpeakKey; - char urlBuffer[511]; - char fieldBuffer[255]; - EthernetNetIf eth; - EthernetErr ethErr; - HTTPClient http; - IpAddr ethIp; - HTTPText resp; - HTTPResult res; +class ThingSpeak +{ + +public: + /** + * @param: write api key provided from ThingSpeak chanell + */ + ThingSpeak(char*); + /** + * Establishing ethernet connection until connected + * + */ + void connect(); + /** + * Should be added + */ + /** + * void getIP(); + */ + /** + * Put up data to thing speak when all fields are set + */ + void putUp(); + /** + *Setting values to the field, they should be set in order. + * It's not required to set them all (example: you can set 1, 2, 3 or 1, 3) + * @param field value to store on + * @param i number of a field + */ + void setField(float field, int i); +private: + + char* thingSpeakUrl; + char* thingSpeakKey; + char urlBuffer[511]; + char fieldBuffer[255]; + EthernetNetIf eth; + EthernetErr ethErr; + HTTPClient http; + IpAddr ethIp; + HTTPText resp; + HTTPResult res; }; -#endif \ No newline at end of file +#endif \ No newline at end of file