Connect Wi-Fi

Dependencies:   mbed

Committer:
chanagan2540
Date:
Fri Dec 08 06:08:42 2017 +0000
Revision:
0:3c8c53e45689
Child:
1:c0fbff97b740
esp8266

Who changed what in which revision?

UserRevisionLine numberNew contents of line
chanagan2540 0:3c8c53e45689 1 #include "mbed.h"
chanagan2540 0:3c8c53e45689 2
chanagan2540 0:3c8c53e45689 3 Serial esp(D8, D2);
chanagan2540 0:3c8c53e45689 4 Serial pc(D1, D0);
chanagan2540 0:3c8c53e45689 5
chanagan2540 0:3c8c53e45689 6 void wifi() {
chanagan2540 0:3c8c53e45689 7 uint8_t data;
chanagan2540 0:3c8c53e45689 8
chanagan2540 0:3c8c53e45689 9 while(1) {
chanagan2540 0:3c8c53e45689 10 if(esp.readable()) {
chanagan2540 0:3c8c53e45689 11 data = esp.getc();
chanagan2540 0:3c8c53e45689 12 pc.printf("Data = %d \n",data);
chanagan2540 0:3c8c53e45689 13 }
chanagan2540 0:3c8c53e45689 14 else {
chanagan2540 0:3c8c53e45689 15 pc.printf("Error!! \n");
chanagan2540 0:3c8c53e45689 16 }
chanagan2540 0:3c8c53e45689 17 break;
chanagan2540 0:3c8c53e45689 18 }
chanagan2540 0:3c8c53e45689 19
chanagan2540 0:3c8c53e45689 20 }
chanagan2540 0:3c8c53e45689 21
chanagan2540 0:3c8c53e45689 22 int main() {
chanagan2540 0:3c8c53e45689 23 pc.printf("Hello!! \n");
chanagan2540 0:3c8c53e45689 24 wifi();
chanagan2540 0:3c8c53e45689 25 }