2

(sharon) #1
FORGE

be extended with a Board Manager to work with
the ESP8266. Many hackers will have experience
of the Arduino IDE in other projects. Many sketches
and libraries developed for the Arduino series of
computers can be used on the ESP8266 – a huge
advantage, given the wealth of Arduino applications.
The Arduino IDE runs on PCs using the Linux,
Windows, and macOS operating systems. Go the
Arduino site arduino.cc and download the appropriate
version for your computer.
To set up the Arduino IDE for ESP8266 boards,
follow the straightforward instructions at
hsmag.cc/AmcDAQ.
Once this is complete, select the correct board
in the IDE by using Tools / Board and choosing
NodeMCU 1.0.
The two libraries are needed for this project –
SSD1306.h for the OLED and VL53L0X.h for the
IR rangefinder.


The first must be downloaded from GitHub at
hsmag.cc/xGrpjJ.



  1. On the webpage, select Clone or download,
    then Download .ZIP.

  2. Note where the .ZIP file is downloaded.

  3. In the Arduino IDE, use the feature at Sketch

    Include Library > Add .ZIP library to install it.





The second library can be directly loaded in the
Arduino IDE using:



  1. In the Arduino IDE, select Sketch > Include
    Library > Manage Libraries.

  2. This will display a new window. The IDE


will contact a server to update a reasonably
comprehensive list of libraries available. Once
this has finished, type VL53L0X in the filter
box to find library for this project, the VL53L0X
library from Pololu.


  1. Click More Info, select the latest version, and
    then Install.


LOOKING SKETCHY
The sketch, IOT-IRdistance.ino, is available to
download from the GitHub repository at
hsmag.cc/dtJPRT.
In this sketch, libraries used are included first.
#include “SSD1306.h”
// library for display
#include <Wire.h>
// I2C library
#include <VL53L0X.h>
// laser rangefinder library

The I^2 C connections used are detailed.
//I2C connections
#define SDA 0
//GPIO0 / D3
#define SCL 2
//GPIO2 / D4

Above
There are loads of
add-ons available
to give more
capabilities to the
basic Arduino IDE

Boards based on the ESP8266 are not only very
cheap, but have the essentials for an Internet of
Things project:


  • General Purpose Input / Output pins

  • Integrated WiFi with TCP/IP stack

  • EEPROM for program storage

  • Low-power mode

  • I^2 C and SPI interfaces

  • Programmed via the Arduino IDE


The ESP01 is a basic board with few GPIOs, and no
direct access to the low-power mode. The ESP12E
board is easier to use, has more GPIOs, an analogue
input, and low-power mode. The NodeMCU V1.0
board adds to the ESP12E all the necessary external
components and a micro-USB interface for direct
connection to a PC for programming, making it ideal
for a first project.

ESP8266 BOARDS


YOU’LL NEED
NodeMCU v.1.0
VL53L0X sensor
module
0.96”, 128 × 64
pixel, OLED
display
Two mini
breadboards
Free download pdf