+ All Categories
Home > Devices & Hardware > Athens IoT Meetup #3 - Introduction to ESP8266 (Pavlos Isaris)

Athens IoT Meetup #3 - Introduction to ESP8266 (Pavlos Isaris)

Date post: 21-Apr-2017
Category:
Upload: athens-iot-meetup
View: 245 times
Download: 1 times
Share this document with a friend
1
Transcript
Page 1: Athens IoT Meetup #3 - Introduction to ESP8266 (Pavlos Isaris)

ESP8266

“Designed for the needs of an increasingly connected world”

Pavlos Isaris

Page 2: Athens IoT Meetup #3 - Introduction to ESP8266 (Pavlos Isaris)

IntroductionThe ESP8266 WiFi Module is a self contained SOC (system on a chip) with integrated

TCP/IP protocol stack that can give any microcontroller access to a WiFi network.

Page 3: Athens IoT Meetup #3 - Introduction to ESP8266 (Pavlos Isaris)

Features● Very low cost ( 3-5$ )

● Pre-programmed with an AT command set firmware

● Growing community

● Enough on-board processing power to deal with sensors

through GPIO

● Operating at 3.3V

● Can draw up to 170 mA of current

● Not breadboard-friendly :-(

Page 4: Athens IoT Meetup #3 - Introduction to ESP8266 (Pavlos Isaris)

Βreadboard friendly version (ESP-12)

Page 5: Athens IoT Meetup #3 - Introduction to ESP8266 (Pavlos Isaris)
Page 6: Athens IoT Meetup #3 - Introduction to ESP8266 (Pavlos Isaris)

Why do we need a Voltage regulator?The ESP8266 may require more than the 35mA supplied by the Arduino 3.3V pin

Page 7: Athens IoT Meetup #3 - Introduction to ESP8266 (Pavlos Isaris)

Baud rate problemThe ESP-8266 comes in various firmware versions, varying also

in the operating baud rate (older operate at 115200 bauds).

My ESP8266 operates in 115200 bauds/second. This means that

we can only use hardware serial to communicate with it

(Arduino Software serial pins handle only 9600 bauds/second)

In such occasion, it is possible to use an Arduino MEGA (4x

Hardware serial couple-pins)

Page 8: Athens IoT Meetup #3 - Introduction to ESP8266 (Pavlos Isaris)

Alternative - Update firmware versionYou can also use an FTDI adapter (like the FT232rl) or FTDI

cable, to communicate via USB with ESP8266

There are plenty of tutorials about how to update the firmware

version

After you have updated the firmware version you can change the

baud rate

Page 9: Athens IoT Meetup #3 - Introduction to ESP8266 (Pavlos Isaris)

Multiple variations

Page 10: Athens IoT Meetup #3 - Introduction to ESP8266 (Pavlos Isaris)

Module GPIO Notes

ESP-01 GPIO0/2/16 Most common module.

ESP-02 GPIO0/2/15

ESP-03 GPIO0/2/12/13/14/15/16 Most popular in esp8266.com poll

ESP-04 GPIO0/2/12/13/14/15/16

ESP-05 None

ESP-06 GPIO0/2/12/13/14/15/16

ESP-07 GPIO0/2/4/5/12/13/14/15/16

ESP-08 GPIO0/2/12/13/14/15/16

ESP-09 GPIO0/2/12/13/14/15 1MB Flash memory

ESP-10 None

ESP-11 GPIO0/1

ESP-12 ADC + GPIO0/2/4/5/12/13/14/15/16

Recently adopted by many due to many GPIOs

Page 11: Athens IoT Meetup #3 - Introduction to ESP8266 (Pavlos Isaris)

Using Arduino IDE Serial Monitor#include <SoftwareSerial.h>SoftwareSerial ESPserial(2, 3); // RX | TX void setup() { Serial.begin(115200); // communication with the host computer ESPserial.begin(115200); Serial.println(""); Serial.println("Remember to to set Both NL & CR in the serial monitor."); Serial.println("Ready"); Serial.println(""); }

Page 12: Athens IoT Meetup #3 - Introduction to ESP8266 (Pavlos Isaris)

Using Arduino IDE Serial Monitorvoid loop() { // listen for communication from the ESP8266 and then write it to the serial monitor if ( ESPserial.available() ) { Serial.write( ESPserial.read() ); } // listen for user input and send it to the ESP8266 if ( Serial.available()) { ESPserial.write( Serial.read() ); }}

Page 13: Athens IoT Meetup #3 - Introduction to ESP8266 (Pavlos Isaris)

Basic AT commands

Page 14: Athens IoT Meetup #3 - Introduction to ESP8266 (Pavlos Isaris)

Checking for available WiFi networks

Page 15: Athens IoT Meetup #3 - Introduction to ESP8266 (Pavlos Isaris)

Connect to Network

Page 16: Athens IoT Meetup #3 - Introduction to ESP8266 (Pavlos Isaris)

See details

Page 17: Athens IoT Meetup #3 - Introduction to ESP8266 (Pavlos Isaris)

Send a requestAllow multiple connections

Start connection

Specify bytes to be sent

In this case it is “GET /

HTTP/1.0\r\n\r\n”

Page 18: Athens IoT Meetup #3 - Introduction to ESP8266 (Pavlos Isaris)

Get the response back

Page 19: Athens IoT Meetup #3 - Introduction to ESP8266 (Pavlos Isaris)

Acting as TCP Server

Page 20: Athens IoT Meetup #3 - Introduction to ESP8266 (Pavlos Isaris)

Acting as a Wifi Access point

Page 21: Athens IoT Meetup #3 - Introduction to ESP8266 (Pavlos Isaris)

ESP8266 core-library#include <Adafruit_ESP8266.h>

#include <SoftwareSerial.h>

#define ARD_RX_ESP_TX 2

#define ARD_TX_ESP_RX 3

#define ESP_RST 4

SoftwareSerial softser(ARD_RX_ESP_TX, ARD_TX_ESP_RX);

Adafruit_ESP8266 wifi(&softser, &Serial, ESP_RST);

#define ESP_SSID "SSIDNAME" // Your network name here

#define ESP_PASS "PASSWORD" // Your network password here

#define HOST "www.adafruit.com" // Host to contact

#define PAGE "/testwifi/index.html" // Web page to request

#define PORT 80 // 80 = HTTP default port

Page 22: Athens IoT Meetup #3 - Introduction to ESP8266 (Pavlos Isaris)

ESP8266 core-librarysoftser.begin(9600); // Soft serial connection to ESP8266

Serial.begin(57600); while(!Serial); // UART serial debug

wifi.connectToAP(F(ESP_SSID), F(ESP_PASS))

Serial.print(F("OK\nRequesting page..."));

if(wifi.requestURL(F(PAGE))) {

Serial.println("OK\nSearching for string...");

if(wifi.find(F("working"), true)) {

Serial.println(F("found!"));

} else {

Serial.println(F("not found."));

}

} else { // URL request failed

Serial.println(F("error"));

}

wifi.closeTCP();

Page 23: Athens IoT Meetup #3 - Introduction to ESP8266 (Pavlos Isaris)

Espert - Development board

http://www.espert.co/ (v2.0 To be released by April 2016.)

Recommended