25
Master Degree in Engineering in Computer Science Dipartimento di Ingegneria Informatica Automatica e Gestio nale "Antonio Ruberti" University of Rome - “La Sapienza” Individual Project of Pervasive Systems Biagio Botticelli 1212666 A.Y. 2015/16 Adafruit Huzzah ESP8266 Wi-Fi Board

Adafruit Huzzah Esp8266 WiFi Board

Embed Size (px)

Citation preview

Page 1: Adafruit Huzzah Esp8266 WiFi Board

Master Degree in Engineering in Computer ScienceDipartimento di Ingegneria Informatica Automatica e Gestionale "Antonio Ruberti"

University of Rome - “La Sapienza”

Individual Project of Pervasive Systems

Biagio Botticelli 1212666

A.Y. 2015/16

Adafruit Huzzah ESP8266 Wi-Fi Board

Page 2: Adafruit Huzzah Esp8266 WiFi Board

Contents

1. Introduction to ESP8266 familyAdafruit Huzzah ESP8266 WiFi

BoardProgramming ESP8266Example of Application

ESP-01 Adafruit Huzzah ESP8266

Page 3: Adafruit Huzzah Esp8266 WiFi Board

Introduction to ESP8266

The ESP8266 is a System-on-a-Chip (SoC) with a full 2,4 GHz WiFi front-end and with integrated TCP/IP protocol stack with DNS support.First version ESP-01 (begin 2014): it allows micro-controllers to connect to a Wi-Fi network and make simple TCP/IP connections using Hayes-style commands.

After few time…• Multiple hardware

versions;• Official SDK (October

2014);• Custom Firmwares;

Intro HuzzahESP8266

Programming

Example

Page 4: Adafruit Huzzah Esp8266 WiFi Board

ESP8266 Family

Adafruit Huzzah

ESP8266

Intro HuzzahESP8266

Programming

Example

Page 5: Adafruit Huzzah Esp8266 WiFi Board

ESP8266: Hardware

• 32-bit CPU running at 80 MHz64 KB of boot ROM64 KB of instruction RAM96 KB of data RAMExternal Flash Memory: 512 KB to up 4 MB2,4 GHz Wi-Fi 802.11 b/g/n

WEP, WPA/WPA2 Authentication or Open Networks16 GPIO pins

SPI, I2CI2S interfaces with DMA (sharing pins with GPIO)UART on dedicated pins + 1 transmit-only UART on

GPIO21 10-bit ADC3 PWM

Intro HuzzahESP8266

Programming

Example

Page 6: Adafruit Huzzah Esp8266 WiFi Board

Why Adafruit Huzzah ESP8266?

WARNING! The ESP8266 operates at 3,3 V!

Most of the first versions do not have an onboard voltage regulator…

Not breadboard friendly…

The Adafruit Huzzah ESP8266 is one of the last versions of the module that make easier to work with.• Integrated high-current capable

500 mA / 3,3 V regulator; • Breadboard friendly.

Intro HuzzahESP8266

Programming

Example

Page 7: Adafruit Huzzah Esp8266 WiFi Board

Why Adafruit Huzzah ESP8266?

Small Dimension: 25x38x5 mm

Very low cost board!

Intro HuzzahESP8266

Programming

Example

Page 8: Adafruit Huzzah Esp8266 WiFi Board

Adafruit Huzzah ESP8266

Power PinsV+: input/output 5V voltage;VBat: input voltage from

Battery;GND: ground;3V: output 3,3V voltage;

Serial Pins• TX: output from the module

(3.3 V);• RX: input into the module (5

V);

Intro HuzzahESP8266

Programming

Example

Page 9: Adafruit Huzzah Esp8266 WiFi Board

Adafruit Huzzah ESP8266

GPIO PinsThere are 9 GPIO pins: #0, #2, #4, #5, #12, #13, #14, #15, #16.GPIO pins are 3,3 V logic level in/out and can be used for any sort of input or output signal.

Many have special functionality:• #0: used to determine when to boot into the bootloader.

If the pin is held LOW during power-up it will start boot-loading.• #2: also used to detect boot-mode.• #15: also used to detect boot-mode.• #16: used to wake up from sleep mode. To awake, connect it to the

RESET pin.

Intro HuzzahESP8266

Programming

Example

Page 10: Adafruit Huzzah Esp8266 WiFi Board

Adafruit Huzzah ESP8266

Analog Pin• A: analog

input.

Other Control Pins• LDO: enable pin;

Easy way to cut power OFF: when connected to GND, it will

turn off the 3,3 V regulator.• RST: reset pin (5 V);

When connected to GND, it will momentarily reset the ESP8266.• EN (CH_PD): reset pin (3,3 V only).

When connected to GND it will momentarily reset the ESP8266.

Intro HuzzahESP8266

Programming

Example

Page 11: Adafruit Huzzah Esp8266 WiFi Board

Programming ESP8266

In order to make them work properly, remember to install the correct driver!

USB-to-SerialTo establish a communication with Adafruit ESP8266, we need an USB to Serial converter which will provide the connectivity between USB port of our PC/Laptop and Serial UART interface of the board.

USB-to-TTL Cable

FTDI Cable

FTDI Breakout

SparkFun FTDI Basic

5V

Intro HuzzahESP8266

Programming

Example

Page 12: Adafruit Huzzah Esp8266 WiFi Board

Programming ESP8266

FirmwaresDifferent options for firmware are available: each one allows to program the chip in a different way.

1. AT+ Command Processor (default for ESP8266);2. Node MCU Lua (default for Adafruit Huzzah ESP8266);3. Custom Firmware (using Arduino IDE to upload);4. esp-open-SDK (direct programming on ESP8266);5. Firmware by Espruino community (Javascript);6. Firmware by MicroPython community (Python);

Only one firmware at a time could be loaded in ESP8266!

Intro HuzzahESP8266

Programming

Example

Page 13: Adafruit Huzzah Esp8266 WiFi Board

Firmware: Installation

To load the firmware in the chip, it’s needed to use:• Flashing Tool: esptool, a Python-based cross-platform ESP8266 flashing tool;• Image of Firmware: any image of firmware to install.

Requirement: the programmer must be able to use esptool.In order to make esptool working, pySerial must be present in the system.Supposing that esptool and pySerial are correctly installed and the firmware image is available, it’s possible to begin the installation of the firmware on the module.

The ESP8266 must be in Bootloader Mode! Otherwise, flashing process will not work!

The command for the installation of the firmware using esptool is:sudo esptool.py --port /dev/tty.device_name write_flash 0x00000 /path_to_firmware_image

• /dev/tty.device_name: name assigned by the OS to the ESP8266 device;• /path_to_firmware_image: location of the image of the firmware.

Intro HuzzahESP8266

Programming

Example

Page 14: Adafruit Huzzah Esp8266 WiFi Board

AT+ CommandsMaybe the quickest way to get started with the ESP8266!

It allows ESP8266 to process AT+ Commands received over Serial UART interface.

Pros: useful for beginners: the user does not need not be familiar with any

programming language or framework to use it; he can simply send a series of commands to achieve his goal.

Cons: USB-to-Serial Connection: the module must be always connected to the

computer.Low-Level Programming: AT+ Commands operate at very low level.There are different ways of sending serial messages over the computer's USB. The most used are:• Serial Terminal Softwares:

• PuTty for Windows;• CoolTerm for Windows/MacOS/Unix;

• Arduino IDE's Serial Monitor.

Intro HuzzahESP8266

Programming

Example

Page 15: Adafruit Huzzah Esp8266 WiFi Board

AT+ Commands Set Intro HuzzahESP8266

Programming

Example

Page 16: Adafruit Huzzah Esp8266 WiFi Board

AT+ Commands Set Intro HuzzahESP8266

Programming

Example

Page 17: Adafruit Huzzah Esp8266 WiFi Board

NodeMCU LuaNodeMCU Lua is the most popular alternative firmware to AT+

Commands!NodeMCU runs an interpreter able to execute commands in the Lua scripting language.

• Memory Storage: store the code in flash memory and instruct the module to run the application every time it restarts!

ESPlorer: NodeMCU tool

Pro: • Good for developers: environment that allows to run commands

for controlling both board's WiFi interface and GPIO functionalities.

Cons: • Lua Language: not

very spread with lack of official documentation;

Intro HuzzahESP8266

Programming

Example

Page 18: Adafruit Huzzah Esp8266 WiFi Board

Arduino IDE

Whereas the Adafruit Huzzah Board is pre-programmed with the NodeMCU firmware, it’s possible to replace it with a custom firmware using the Arduino IDE.

WARNING! This method erases the previous firmware from the ESP8266's flash!(To come back to initial configuration of the board, there would be executed the steps described before)

Maybe it’s the easiest way to design a custom firmware for the ESP8266 module!

It would be the best choice for those users which want to use the latest versions of ESP8266 that allows to use it as a regular micro-controller.

Intro HuzzahESP8266

Programming

Example

Page 19: Adafruit Huzzah Esp8266 WiFi Board

Arduino IDE

The Arduino IDE will not initially recognize the ESP8266!

ESP8266 in the Arduino IDE• Open Preferences window of the Arduino IDE;• Enter in the Additional Boards Manager URLs field the URL:

http://arduino.esp8266.com/stable/package_esp8266com_index.json• Go in the Boards Manager and install the last release for esp8266

module by the ESP8266 Web Community;• Restart the Arduino IDE;• After restarting the Arduino IDE, we can find a specific menu of the

different models of ESP8266 boards.• Selecting the model of the board, the IDE will automatically set the

correct parameters in order to make feasible the USB-to-Serial communication.

If all the previous configuration steps are been made correctly, we are now ready to write our custom firmware with the Arduino IDE.

Intro HuzzahESP8266

Programming

Example

Page 20: Adafruit Huzzah Esp8266 WiFi Board

Example

Steps: 1. Build the hardware circuit on which the application is based;2. Develop the custom firmware with the Arduino IDE, that makes

the ESP8266 board the core of the project;3. Use Blynk app for iOS/Android to implement the remote control;

Idea: Create an application for the remote control of the temperature/humidity in the room with the possibility to turn on/off the light by using the smartphone.

Intro HuzzahESP8266

Programming

Example

Page 21: Adafruit Huzzah Esp8266 WiFi Board

Example: Hardware Intro HuzzahESP8266

Programming

Example

Page 22: Adafruit Huzzah Esp8266 WiFi Board

Example: Blynk Front-EndBlynk: IoT Control User Interface for ESP8266 module

Intro HuzzahESP8266

Programming

Example

User Interface:

• Switch for the Remote Control of the light;

• Gauge for the representation of the Temperature of the room;

• Gauge for the representation of the Humidity of the room;

Page 23: Adafruit Huzzah Esp8266 WiFi Board

Example: Arduino IDE Intro HuzzahESP8266

Programming

Example

Page 24: Adafruit Huzzah Esp8266 WiFi Board

Example: Arduino IDE Intro HuzzahESP8266

Programming

Example