Transmit data from mbed to thingspeak using wifi module
Dependencies: HTTPClient WiflyInterface mbed
Revision 0:2474e21be40b, committed 2018-02-12
- Comitter:
- maman95
- Date:
- Mon Feb 12 05:21:53 2018 +0000
- Commit message:
- Thingspeak connection;
Changed in this revision
diff -r 000000000000 -r 2474e21be40b HTTPClient.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HTTPClient.lib Mon Feb 12 05:21:53 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mamezu/code/HTTPClient/#62fac7f06c8d
diff -r 000000000000 -r 2474e21be40b WiflyInterface.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WiflyInterface.lib Mon Feb 12 05:21:53 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/samux/code/WiflyInterface/#108340829acc
diff -r 000000000000 -r 2474e21be40b main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Feb 12 05:21:53 2018 +0000 @@ -0,0 +1,51 @@ +#include "mbed.h" +#include "WiflyInterface.h" +#include "HTTPClient.h" + + +WiflyInterface wifly(p9, p10, p30, p29, "Don", "don123456", WPA); +Serial pc (USBTX, USBRX); +AnalogIn moisture(p15); +DigitalOut myled1(LED1); +HTTPClient http; +//I2C tempsensor(p28, p27); //sda, sc1 +//const int addr = 0x90; +//char config_t[2]; +//char temp_read[2]; +//float temp; + + + + +int main() { + + wifly.init(); //Use DHCP + + wifly.connect(); + + pc.printf("\nClient IP Address is %s\n\r", wifly.getIPAddress()); + + + + float value=0; + + +while(1) { + + + //char buf[24]; + + char urlBuffer[100]; + //sprintf (buf, value1); + value = moisture; + + int value1 = (int)(value * 1000); + sprintf(urlBuffer, "https://api.thingspeak.com/update?api_key=KQ8Z2C2RTE2B2FWV&field1=%d", value1); //url for update thingspeak data + printf("Send to %s\r\n", urlBuffer); + //http.get + http.get(urlBuffer, urlBuffer, 100); + + wait(16); // limited by ThingSpeak's API + +} +} \ No newline at end of file
diff -r 000000000000 -r 2474e21be40b mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Feb 12 05:21:53 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/7130f322cb7e \ No newline at end of file