#include <Adafruit_ESP8266.
h>
#include <SoftwareSerial.h>
#include <LiquidCrystal_I2C.h>
#define ESP_RX 3
#define ESP_TX 4
#define ESP_RST 8
SoftwareSerial softser(ESP_RX, ESP_TX);
LiquidCrystal_I2C lcd(0x27, 20, 4);
// Must declare output stream before Adafruit_ESP8266 constructor; can be
// a SoftwareSerial stream, or Serial/Serial1/etc. for UART.
Adafruit_ESP8266 wifi(&softser, &Serial, ESP_RST);
// Must call begin() on the stream(s) before using Adafruit_ESP8266 object.
#define ESP_SSID "HUAWEI Y5 2019" // Your network name here
#define ESP_PASS "b582058c4d86" // Your network password here
#define PORT 80 // Find/Google your email provider's SMTP outgoing port for unencrypted
email
int count = 0; // we'll use this int to keep track of which command we need to send next
bool send_flag = false; // we'll use this flag to know when to send the email commands
void setup() {
lcd.init();
char buffer[50];
// This might work with other firmware versions (no guarantees)
// by providing a string to ID the tail end of the boot message:
// comment/replace this if you are using something other than v 0.9.2.4!
wifi.setBootMarker(F("Version:0.9.2.4]\r\n\r\nready"));
softser.begin(9600); // Soft serial connection to ESP8266
Serial.begin(57600); while(!Serial); // UART serial debug
// Test if module is ready
lcd.backlight();
Serial.print(F("Hard reset..."));
lcd.print(F("Hard reset..."));
if(!wifi.hardReset()) {
Serial.println(F("no response from module."));
for(;;);
Serial.println(F("OK."));
lcd.print(F("OK."));
Serial.print(F("Soft reset..."));
lcd.print(F("Soft reset..."));
if(!wifi.softReset()) {
Serial.println(F("no response from module."));
for(;;);
}
Serial.println(F("OK."));
lcd.clear();
lcd.print(F("OK."));
Serial.print(F("Checking firmware version..."));
lcd.clear();
lcd.print(F("Checking firmware version..."));
delay(2000);
wifi.println(F("AT+GMR"));
if(wifi.readLine(buffer, sizeof(buffer))) {
Serial.println(buffer);
lcd.clear();
lcd.print(buffer);
delay(2000);
wifi.find(); // Discard the 'OK' that follows
} else {
Serial.println(F("error"));
Serial.print(F("Connecting to WiFi..."));
lcd.clear();
lcd.print(F("Connect to WiFi..."));
delay(2000);
if(wifi.connectToAP(F(ESP_SSID), F(ESP_PASS))) { // Le module wifi ESP8266 est connecté au réseau
// IP addr check isn't part of library yet, but
// we can manually request and place in a string.
Serial.print(F("OK\nChecking IP addr..."));
wifi.println(F("AT+CIFSR"));
if(wifi.readLine(buffer, sizeof(buffer))) {
lcd.clear();
Serial.println(buffer); // afficher l'adresse IP du module wifi ESP8266
lcd.setCursor(0, 0);
lcd.print("IP de ESP8266 ");
lcd.setCursor(0, 1);
lcd.print(buffer);
void loop() {