Use ESP8266 to connect ThingSpeak.com
Drive to connect with ThingSpeak.com,
it`s work well, but it don`t provided return message
you can send "int" "float" "char".
ESP8266和ThingSpeak.com的驱动,工作正常,但是驱动不提供ESP8266的返回消息
main.cpp@1:6df8ccaec251, 2019-02-14 (annotated)
- Committer:
- Yifan_Du
- Date:
- Thu Feb 14 08:00:22 2019 +0000
- Revision:
- 1:6df8ccaec251
- Parent:
- 0:1432a364e32a
Delete personal information
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Yifan_Du | 0:1432a364e32a | 1 | #include "mbed.h" |
Yifan_Du | 0:1432a364e32a | 2 | #include "ThingSpeak_ESP8266.h" |
Yifan_Du | 0:1432a364e32a | 3 | |
Yifan_Du | 1:6df8ccaec251 | 4 | #define SSID "WIFI SSID" |
Yifan_Du | 1:6df8ccaec251 | 5 | #define Password "WIFI PASSWORD" |
Yifan_Du | 1:6df8ccaec251 | 6 | #define API_Key "YOUR API_KEY" |
Yifan_Du | 0:1432a364e32a | 7 | |
Yifan_Du | 0:1432a364e32a | 8 | Serial PC(USBTX, USBRX, 115200); |
Yifan_Du | 0:1432a364e32a | 9 | ESP8266 WIFI(PC_10, PC_11, 115200); |
Yifan_Du | 0:1432a364e32a | 10 | |
Yifan_Du | 0:1432a364e32a | 11 | void WIFI_init(void); |
Yifan_Du | 0:1432a364e32a | 12 | |
Yifan_Du | 0:1432a364e32a | 13 | int main(void) |
Yifan_Du | 0:1432a364e32a | 14 | { |
Yifan_Du | 0:1432a364e32a | 15 | int data = 0; |
Yifan_Du | 0:1432a364e32a | 16 | |
Yifan_Du | 0:1432a364e32a | 17 | WIFI_init(); |
Yifan_Du | 0:1432a364e32a | 18 | WIFI.User_API_Key = API_Key; |
Yifan_Du | 0:1432a364e32a | 19 | |
Yifan_Du | 0:1432a364e32a | 20 | while(1) |
Yifan_Du | 0:1432a364e32a | 21 | { |
Yifan_Du | 0:1432a364e32a | 22 | PC.printf("Send %2d", data); |
Yifan_Du | 0:1432a364e32a | 23 | WIFI.Send_To_ThingSpeak_int(1, data); |
Yifan_Du | 0:1432a364e32a | 24 | PC.printf(" Done\r\n"); |
Yifan_Du | 0:1432a364e32a | 25 | |
Yifan_Du | 0:1432a364e32a | 26 | data++; |
Yifan_Du | 0:1432a364e32a | 27 | wait(5); |
Yifan_Du | 0:1432a364e32a | 28 | } |
Yifan_Du | 0:1432a364e32a | 29 | } |
Yifan_Du | 0:1432a364e32a | 30 | |
Yifan_Du | 0:1432a364e32a | 31 | void WIFI_init(void) |
Yifan_Du | 0:1432a364e32a | 32 | { |
Yifan_Du | 0:1432a364e32a | 33 | printf("\r\nReset ESP..."); |
Yifan_Du | 0:1432a364e32a | 34 | WIFI.Reset(); |
Yifan_Du | 0:1432a364e32a | 35 | |
Yifan_Du | 0:1432a364e32a | 36 | printf("\r\nSet Mode..."); |
Yifan_Du | 0:1432a364e32a | 37 | WIFI.Set_Mode(); |
Yifan_Du | 0:1432a364e32a | 38 | |
Yifan_Du | 0:1432a364e32a | 39 | printf("\r\nConnect WIFI...."); |
Yifan_Du | 0:1432a364e32a | 40 | WIFI.Connect_WIFI(SSID, Password); |
Yifan_Du | 0:1432a364e32a | 41 | } |
Yifan_Du | 0:1432a364e32a | 42 |