PIR grove sensor that sends the sensed data to Thingspeak.com through the wifi module ESP 8266

Dependencies:   mbed

Committer:
skrawool
Date:
Mon Dec 05 16:39:27 2016 +0000
Revision:
0:3954a906acc2
PIR grove sensor that sends the sensed data to thingspeak through the wifi module ESP 8266

Who changed what in which revision?

UserRevisionLine numberNew contents of line
skrawool 0:3954a906acc2 1 #ifndef ESP8266_H
skrawool 0:3954a906acc2 2 #define ESP8266_H
skrawool 0:3954a906acc2 3
skrawool 0:3954a906acc2 4 #include <string>
skrawool 0:3954a906acc2 5 #include "mbed.h"
skrawool 0:3954a906acc2 6
skrawool 0:3954a906acc2 7 class ESP8266
skrawool 0:3954a906acc2 8 {
skrawool 0:3954a906acc2 9 public:
skrawool 0:3954a906acc2 10 /**
skrawool 0:3954a906acc2 11 * ESP8266 constructor
skrawool 0:3954a906acc2 12 *
skrawool 0:3954a906acc2 13 * @param tx TX pin
skrawool 0:3954a906acc2 14 * @param rx RX pin
skrawool 0:3954a906acc2 15 * @param br Baud Rate
skrawool 0:3954a906acc2 16 */
skrawool 0:3954a906acc2 17 ESP8266(PinName tx, PinName rx, int br);
skrawool 0:3954a906acc2 18
skrawool 0:3954a906acc2 19 /**
skrawool 0:3954a906acc2 20 * ESP8266 destructor
skrawool 0:3954a906acc2 21 */
skrawool 0:3954a906acc2 22 ~ESP8266();
skrawool 0:3954a906acc2 23
skrawool 0:3954a906acc2 24 void SendCMD(char * s);
skrawool 0:3954a906acc2 25 void Reset(void);
skrawool 0:3954a906acc2 26 void RcvReply(char * r, int to);
skrawool 0:3954a906acc2 27 void GetList(char * l);
skrawool 0:3954a906acc2 28 void Join(char * id, char * pwd);
skrawool 0:3954a906acc2 29 void GetIP(char * ip);
skrawool 0:3954a906acc2 30 void SetMode(char mode);
skrawool 0:3954a906acc2 31 void Quit(void);
skrawool 0:3954a906acc2 32 void SetSingle(void);
skrawool 0:3954a906acc2 33 void SetMultiple(void);
skrawool 0:3954a906acc2 34 void GetConnStatus(char * st);
skrawool 0:3954a906acc2 35 void StartServerMode(int port);
skrawool 0:3954a906acc2 36 void CloseServerMode(void);
skrawool 0:3954a906acc2 37
skrawool 0:3954a906acc2 38 private:
skrawool 0:3954a906acc2 39 Serial comm;
skrawool 0:3954a906acc2 40 void AddEOL(char * s);
skrawool 0:3954a906acc2 41 void AddChar(char * s, char c);
skrawool 0:3954a906acc2 42 void itoa(int c, char s[]);
skrawool 0:3954a906acc2 43
skrawool 0:3954a906acc2 44 };
skrawool 0:3954a906acc2 45
skrawool 0:3954a906acc2 46 #endif
skrawool 0:3954a906acc2 47 /*
skrawool 0:3954a906acc2 48 COMMAND TABLE
skrawool 0:3954a906acc2 49 Basic:
skrawool 0:3954a906acc2 50 AT: Just to generate "OK" reply
skrawool 0:3954a906acc2 51 Wifi:
skrawool 0:3954a906acc2 52 AT+RST: restart the module
skrawool 0:3954a906acc2 53 AT+CWMODE: define wifi mode; AT+CWMODE=<mode> 1= Sta, 2= AP, 3=both; Inquiry: AT+CWMODE? or AT+CWMODE=?
skrawool 0:3954a906acc2 54 AT+CWJAP: join the AP wifi; AT+ CWJAP =<ssid>,< pwd > - ssid = ssid, pwd = wifi password, both between quotes; Inquiry: AT+ CWJAP?
skrawool 0:3954a906acc2 55 AT+CWLAP: list the AP wifi
skrawool 0:3954a906acc2 56 AT+CWQAP: quit the AP wifi; Inquiry: AT+CWQAP=?
skrawool 0:3954a906acc2 57 * AT+CWSAP: set the parameters of AP; AT+CWSAP= <ssid>,<pwd>,<chl>,<ecn> - ssid, pwd, chl = channel, ecn = encryption; Inquiry: AT+CWJAP?
skrawool 0:3954a906acc2 58 TCP/IP:
skrawool 0:3954a906acc2 59 AT+CIPSTATUS: get the connection status
skrawool 0:3954a906acc2 60 * AT+CIPSTART: set up TCP or UDP connection 1)single connection (+CIPMUX=0) AT+CIPSTART= <type>,<addr>,<port>; 2) multiple connection (+CIPMUX=1) AT+CIPSTART= <id><type>,<addr>, <port> - id = 0-4, type = TCP/UDP, addr = IP address, port= port; Inquiry: AT+CIPSTART=?
skrawool 0:3954a906acc2 61 * AT+CIPSEND: send data; 1)single connection(+CIPMUX=0) AT+CIPSEND=<length>; 2) multiple connection (+CIPMUX=1) AT+CIPSEND= <id>,<length>; Inquiry: AT+CIPSEND=?
skrawool 0:3954a906acc2 62 * AT+CIPCLOSE: close TCP or UDP connection; AT+CIPCLOSE=<id> or AT+CIPCLOSE; Inquiry: AT+CIPCLOSE=?
skrawool 0:3954a906acc2 63 AT+CIFSR: Get IP address; Inquiry: AT+ CIFSR=?
skrawool 0:3954a906acc2 64 AT+CIPMUX: set mutiple connection; AT+ CIPMUX=<mode> - 0 for single connection 1 for mutiple connection; Inquiry: AT+CIPMUX?
skrawool 0:3954a906acc2 65 AT+CIPSERVER: set as server; AT+ CIPSERVER= <mode>[,<port> ] - mode 0 to close server mode, mode 1 to open; port = port; Inquiry: AT+CIFSR=?
skrawool 0:3954a906acc2 66 * +IPD: received data
skrawool 0:3954a906acc2 67 */