GR_Peach_Abhinav_Rahul
/
Wifi_thingspeak
Increments the value by 1
Fork of test_thread_reneproj by
Diff: main.cpp
- Revision:
- 2:52ecf89221d3
- Parent:
- 1:0ceb20b56f7f
- Child:
- 3:e8db31793029
diff -r 0ceb20b56f7f -r 52ecf89221d3 main.cpp --- a/main.cpp Mon Jan 09 10:53:01 2017 +0000 +++ b/main.cpp Mon Jan 09 17:40:15 2017 +0000 @@ -23,32 +23,40 @@ pc.putc(read_data); } } - Wifi.puts("\n"); - pc.puts("\n"); } } void send_to_device(string command){ } +void setup_esp8266(){ + Wifi.baud(9600); + pc.baud(9600); + Wifi.puts("AT\r\n"); + wait(8); + Wifi.puts("AT+RST\r\n"); + wait(8); + Wifi.puts("AT+CWMODE=3\r\n"); + wait(8); + Wifi.puts("AT+CWJAP=\"Googol\",\"sudopass\"\r\n"); + wait(8); + Wifi.puts("AT+CIPMUX=1\r\n"); + wait(8); + Wifi.printf("AT+CIPSTART=0,\"TCP\",\"reneproj.esy.es\""); + wait(4); + Wifi.printf(",80\r\n"); + wait(8); + Wifi.puts("AT+CIPSEND=0,30\r\n"); + wait(8); + Wifi.printf("GET reneproj.esy.es/peach/index.php?device_token=jabv5su2&device_id=gr_peach1&command4u=00 HTTP/1.1\r\n"); + wait(8); + } int main() { - led1 = 1; - led2 = 1; + setup_esp8266(); + Thread thread(reader_thread); uint8_t data[3] = {0x47, 0x32, 0xA7}; - Wifi.puts("AT"); - Wifi.puts("AT+RST"); - wait(2); - Wifi.puts("AT+CWMODE=3"); - wait_ms(100); - Wifi.puts("AT+CWJAP=\"Username\"+\"Password\""); - Wifi.puts("AT+CIPMUX=1"); - Thread thread(reader_thread); - Wifi.puts("AT+CIPSTART=0,\"TCP\",\"localhost/peach/index.php?device_token=jabv5su2&device_id=gr_peach1&command4u=Sent_Something\",80"); - Wifi.puts("AT+CIPSEND=0,30"); - Wifi.puts("GET localhost/peach/index.php?device_token=jabv5su2&device_id=gr_peach1&command4u=Sent_Something HTTP/1.1" ); while (true) { - led1 = !led1; - Thread::wait(500); + wait(10); } }