Skip to content

Instantly share code, notes, and snippets.

@contolini
Last active August 2, 2021 21:01
Show Gist options
  • Save contolini/044462462b4beee3dac36743299ebcde to your computer and use it in GitHub Desktop.
Save contolini/044462462b4beee3dac36743299ebcde to your computer and use it in GitHub Desktop.
Beginner's guide to IoT (Internet of Things) and the ESP8266

Beginner's guide to building IoT devices

The gist

Ever heard of an Arduino? It's a $35 microcontroller that lets you write code that interacts with motors and lights and IRL stuff. Well, there's a $2 version that has all the same features and is the size of a postage stamp. It's call the ESP8266.

The ESP8266

ESP8266 is an inexpensive wifi-enabled SoC made by the company Espressif. It was released in 2014 with very little documentation but its low cost motivated hardware hackers around the world to explore and document the module. Online communities formed to discuss the chip and how to build with it. Hobbyists developed software, including Arduino IDE integration, to make the chip easy to program. With the ESP8266 you can build Internet-connected devices for a few dollars.

Beginner's guide to the ESP8266

What to buy to get started:

You'll need an ESP8266 breakout board. An electronics company called WeMos offers the cheapest ESP8266 boards on the market with their D1 line. The D1 is available in a postage stamp-sized "mini" version and a larger R2 board that has a layout identical to the Arduino Uno. I recommend buying one of each. You should also buy a couple D1 mini shields that pique your interest.

WeMos is based in China so it will take anywhere from 2 - 4 weeks for the items to arrive to your doorstep. If you don't want to wait a month, you can buy SparkFun's Thing or Adafruit's HUZZAH. Both Adafruit and SparkFun have some excellent tutorials on how to use their boards.

While you wait a month for everything to arrive:

After it arrives:

The ESP8266 can be programmed using Arduino's IDE. This is the easiest way to get started. Here are some guides on installing the IDE and preparing it for both ESP8266 and D1 programming.

After the IDE is set up, connect the D1 R2 (or the mini) to your laptop with a standard USB micro cable. If you followed the WeMos steps above, you should have some sample D1 sketches available in the Arduino IDE at File > Sketchbook > D1_mini_Examples. Open the Blink sketch and peruse the code to see what it does. Try uploading it to your D1 by clicking the IDE's upload button.

Now attach the DHT22 temperature shield to the top of the D1 mini. Open and upload the DHT22 temperature shield sketch. See if you can get it to log your room's temperature and humidity.

Some awesome ESP8266 projects:

A swiss gentleman named Andreas Spiess has released dozens of exceptional videos on the ESP8266 and IoT in general. Definitely worth checking out.

Notes

  • If you're feeling ambitious you can also load NodeMCU onto the chip and write programs in Lua.
  • If you know what you're doing and don't require a breakout board, standalone ESP8266 modules can be purchased on AliExpress.
  • Espressif recently released an upgraded version of the chip, ESP32, that combines both WiFi and Bluetooth alongside two CPU cores. Breakout boards of the chip are not widely available yet but will hopefully reach AliExpress in a few months.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment