![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Simple usage of wifi module ESP826601.
main.cpp@0:47830fe8d357, 2020-11-19 (annotated)
- Committer:
- zvonimir
- Date:
- Thu Nov 19 11:42:27 2020 +0000
- Revision:
- 0:47830fe8d357
Upravljanje wifi modulom esp826601.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
zvonimir | 0:47830fe8d357 | 1 | #include "mbed.h" |
zvonimir | 0:47830fe8d357 | 2 | #include "ESP826601.h" |
zvonimir | 0:47830fe8d357 | 3 | |
zvonimir | 0:47830fe8d357 | 4 | Esp ESP; |
zvonimir | 0:47830fe8d357 | 5 | DigitalOut myled(LED1); |
zvonimir | 0:47830fe8d357 | 6 | Ticker tick; |
zvonimir | 0:47830fe8d357 | 7 | |
zvonimir | 0:47830fe8d357 | 8 | void readData(){ |
zvonimir | 0:47830fe8d357 | 9 | myled = !myled; |
zvonimir | 0:47830fe8d357 | 10 | } |
zvonimir | 0:47830fe8d357 | 11 | |
zvonimir | 0:47830fe8d357 | 12 | int main() { |
zvonimir | 0:47830fe8d357 | 13 | tick.attach(&readData, 0.5); |
zvonimir | 0:47830fe8d357 | 14 | |
zvonimir | 0:47830fe8d357 | 15 | ESP.init(); |
zvonimir | 0:47830fe8d357 | 16 | ESP.send("AT+CIFSR"); |
zvonimir | 0:47830fe8d357 | 17 | ESP.waitResponse(); |
zvonimir | 0:47830fe8d357 | 18 | ESP.send("AT+CIPMUX=1"); |
zvonimir | 0:47830fe8d357 | 19 | ESP.waitResponse(); |
zvonimir | 0:47830fe8d357 | 20 | ESP.send("AT+CIPSERVER=1,80"); |
zvonimir | 0:47830fe8d357 | 21 | ESP.waitResponse(); |
zvonimir | 0:47830fe8d357 | 22 | |
zvonimir | 0:47830fe8d357 | 23 | tick.detach(); |
zvonimir | 0:47830fe8d357 | 24 | myled = 0; |
zvonimir | 0:47830fe8d357 | 25 | |
zvonimir | 0:47830fe8d357 | 26 | while(1){ |
zvonimir | 0:47830fe8d357 | 27 | ESP.waitConnection(); |
zvonimir | 0:47830fe8d357 | 28 | ESP.send("Pozdrav od Zvonimira"); |
zvonimir | 0:47830fe8d357 | 29 | ESP.closeConnection(); |
zvonimir | 0:47830fe8d357 | 30 | } |
zvonimir | 0:47830fe8d357 | 31 | } |
zvonimir | 0:47830fe8d357 | 32 | |
zvonimir | 0:47830fe8d357 | 33 |