Thiago Moreira
/
Nucleo_comunicacao_ESP8266
Comunicação entre o Nucleo e um módulo WiFi ESP8266.
main.cpp@0:1780d1882c05, 2017-09-14 (annotated)
- Committer:
- thiagofrosty
- Date:
- Thu Sep 14 02:36:05 2017 +0000
- Revision:
- 0:1780d1882c05
Comunica??o b?sica entre o N?cleo e o m?dulo ESP8266.;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
thiagofrosty | 0:1780d1882c05 | 1 | #include "mbed.h" |
thiagofrosty | 0:1780d1882c05 | 2 | |
thiagofrosty | 0:1780d1882c05 | 3 | #define ESP8266_TX PD_5 |
thiagofrosty | 0:1780d1882c05 | 4 | #define ESP8266_RX PD_6 |
thiagofrosty | 0:1780d1882c05 | 5 | |
thiagofrosty | 0:1780d1882c05 | 6 | Serial ESP8266(ESP8266_TX,ESP8266_RX,115200); |
thiagofrosty | 0:1780d1882c05 | 7 | |
thiagofrosty | 0:1780d1882c05 | 8 | DigitalOut myled(LED3); |
thiagofrosty | 0:1780d1882c05 | 9 | |
thiagofrosty | 0:1780d1882c05 | 10 | int main() |
thiagofrosty | 0:1780d1882c05 | 11 | { |
thiagofrosty | 0:1780d1882c05 | 12 | ESP8266.printf("AT\r\n"); |
thiagofrosty | 0:1780d1882c05 | 13 | wait(1); |
thiagofrosty | 0:1780d1882c05 | 14 | |
thiagofrosty | 0:1780d1882c05 | 15 | ESP8266.printf("AT+SYSIOSETCFG=12,3,0\r\n"); |
thiagofrosty | 0:1780d1882c05 | 16 | wait(1); |
thiagofrosty | 0:1780d1882c05 | 17 | |
thiagofrosty | 0:1780d1882c05 | 18 | ESP8266.printf("GPIOAT+SYSGPIODIR=12,1\r\n"); |
thiagofrosty | 0:1780d1882c05 | 19 | wait(1); |
thiagofrosty | 0:1780d1882c05 | 20 | |
thiagofrosty | 0:1780d1882c05 | 21 | ESP8266.printf("AT+SYSGPIOWRITE=12,1\r\n"); |
thiagofrosty | 0:1780d1882c05 | 22 | wait(1); |
thiagofrosty | 0:1780d1882c05 | 23 | |
thiagofrosty | 0:1780d1882c05 | 24 | while(1) |
thiagofrosty | 0:1780d1882c05 | 25 | { |
thiagofrosty | 0:1780d1882c05 | 26 | ESP8266.printf("AT+SYSGPIOWRITE=12,0\r\n"); |
thiagofrosty | 0:1780d1882c05 | 27 | wait(1); |
thiagofrosty | 0:1780d1882c05 | 28 | |
thiagofrosty | 0:1780d1882c05 | 29 | ESP8266.printf("AT+SYSGPIOWRITE=12,1\r\n"); |
thiagofrosty | 0:1780d1882c05 | 30 | wait(1); |
thiagofrosty | 0:1780d1882c05 | 31 | |
thiagofrosty | 0:1780d1882c05 | 32 | myled = !myled; |
thiagofrosty | 0:1780d1882c05 | 33 | } |
thiagofrosty | 0:1780d1882c05 | 34 | } |
thiagofrosty | 0:1780d1882c05 | 35 | |
thiagofrosty | 0:1780d1882c05 | 36 | /* |
thiagofrosty | 0:1780d1882c05 | 37 | int main() |
thiagofrosty | 0:1780d1882c05 | 38 | { |
thiagofrosty | 0:1780d1882c05 | 39 | while(1) |
thiagofrosty | 0:1780d1882c05 | 40 | { |
thiagofrosty | 0:1780d1882c05 | 41 | ESP8266.printf("AT\r\n"); |
thiagofrosty | 0:1780d1882c05 | 42 | wait(1); |
thiagofrosty | 0:1780d1882c05 | 43 | } |
thiagofrosty | 0:1780d1882c05 | 44 | } |
thiagofrosty | 0:1780d1882c05 | 45 | */ |