Skip to content
thelionroars edited this page May 24, 2015 · 15 revisions

Connect all the Things

An introduction to Internet of Things applications using the ESP8266

Authors:

Edwin Wong
Luke Jackson
Adam De Blasio
Edward Gilbert

Introducing the ESP8266

The ESP8266 was released in late 2014 from a Chinese manufacturer (Espressif), and has quickly caught the attention of hackers and makers worldwide. Previous hardware for use with Internet of Things (IoT) devices had been more expensive - but here was a chip with full 2.4GHz Wi-Fi networking capabilities, a workable amount of flash and RAM and all for less than 5 US dollars. Suddenly the ability to connect appliances and devices to the internet is a very cheap prospect.

The ESP8266 features:

  • full Wi-Fi 802.11 b/g/n capabilities
  • An integrated TCP/IP protocol stack
  • the ability to run as a Wi-Fi access point, a wireless client, or both at the same time
  • a 32-bit microprocessor with 32 kilobytes of RAM, and 80 kilobytes of flash memory
  • Input/output functionality: GPIO (Genral Purpose Input/Output), PWM (Pulse Width Modulation), ADC (Analog to Digital Converter) and I2C

Intended audience for this guide

This guide is an attempt to bridge the current knowledge gap surrounding the ESP8266, which is produced by a Chinese company (Espressif) and at the time of writing has limited English support available. It is also intended to be an introduction to working with hardware and making your own circuits for the first time user.

We've assumed the following background for users of this guide:

Programming background

You can perform basic tasks in a programming language (any language): from being able to write a 'Hello World' program to using loops, control statements and functions or methods. This will be sufficient background for learning Lua using the guide.

Networking background

You have a basic understanding of how networking takes place, with enough knowledge to be able to successfully configure a device with a manual IP address.

Electronics background

You've never built a circuit yourself before - no prior experience needed.

What this guide covers

  • How to write programs in Lua, and run them on the ESP8266 using NodeMCU
  • How to build circuits using the ESP8266 to make use of analog and digital sensors
  • The equipment you will need (including the ESP8266 itself) and advice on how and where to purchase it
  • How to program the ESP8266 to be a wireless client, an access point, and a client and server for internet applications
  • How to install the applications we will be using on Windows and Linux
  • How to flash the ESP8266 with new firmware
  • A complete step-by-step guide to 3 example projects.

What this guide doesn't cover

  • Basic instructions on programming for complete beginners
  • How to solder, make use of unpinned ESP8266 boards, make printed circuit boards or make cases for devices - we will be sticking to pinned ESP8266 boards, breadboards and jumper cabling.
  • Electronics theory
  • Introductory networking
  • How to install the toolchain on a Mac - everything we have used is cross-platform and should be fine on Apple PCs and laptops, but we did not have access to OSX devices when creating this guide. Hopefully this can be included in a future iteration.
  • How to program the ESP8266 using other options, which include the native SDK or the newly-released Arduino IDE. You can certainly consider these for any future projects, once you've had some experience of working with NodeMCU and Lua.

A preview of the guides chapters

02 Programming the ESP

This section gives general information on the tools and firmware used.

03 Equipment

Various information on the chip and technologies used is given. A brief crash course in general electronics is offered.

04 Installing the environment

Explains what is included in the install, which can be found in the repository.

05 Communicating with the ESP

Gives instructions on achieving a serial connection with a computer.

06 Flashing the ESP

Gives instructions on flashing new firmware to the ESP8266.

07 A Lua Crash Course

Offers users who haven't used lua before, but already have general programming skill a way to quickly understand lua. an also be used as a reference for various syntax like logic operators.

08 Hello World, blink LED

We'll begin with the 'Hello World!' of hardware projects, which is to turn an LED light on and off. We'll then extend this to get the light turning on and off in response to submission of a web form running on the ESP8266.

Learning Outcomes

  • Connect and flash firmware to an ESP8266.
  • Basic circuitry.
  • Upload and execute code.
  • Connect to ESP8266 through WiFi TCP/IP.

The Home security system

In this project we will build a home security system for about $6 (We take no responsibility if your things get stolen, this is a hobby/proof of concept project!), demonstrating one of the ESP8266's biggest advantages... its darn cheap!

Learning Outcomes

  • Using digital sensors with the ESP8266.
  • Using the PWM functions of NodeMCU.
  • Understanding and using the MQTT protocol for Internet of Things.

Project 3: Cookie Hunt

Our final project will take a sneak peek at the frontier of Internet of Things applications. This will feature a game where several ESP8266 devices all act as one server and each instance must be hunted for and discovered within a geographical area. The game will make use of a Javascript cookie to track the level of completion of the participants.

Learning Outcomes

  • Run the ESP8266 as a Wi-Fi Access Point (AP) and basic web server
  • Upload files other than Lua scripts onto the device
  • Learn how to pre-compile Lua scripts, to reduce their size on the device and to improve performance

Project 4: Music Library

A Security Intrusion Detection System for ESP8266. It aims to prototype and demonstrate the ESP8266 working as a motion detector server for home security (or just motion detection in some local), and to example various abilities of the ESP8266 chip running NodeMCU.

Learning Outcomes

  • Use of a digital sensor.
  • Use of the PWM functions.
  • Use of MQTT protocol.