IoT_practice_lab_1
IoT_practice_lab_1
IoT_practice_lab_1
PRACTICAL LABS
Programming IoT
Applications
Ha Noi, 2023
Getting familiar with ESP8266
Purpose
The aim of this lab is for students to be able to confidently work with a popular develop-
ment KIT, i.e., ESP8266, and an embedded software development environment, i.e., Arduino
IDE.
Important Information
- Please do not power electronic devices, e.g., ESP8266, sensors, actuators, before
getting the confirmation from your tutor,
Preparation
• Hardware: In this practice class, you will be using ESP8266 boards to explore all lab
exercises and develop your own projects for the final exams. Each student group (5
students per group) need to prepare hardware components for the labs in the following
list: https://1drv.ms/x/s!AtpR7GXvzh0wh5Awyxye8faeeNhvnA?e=pNI0xc
Note: If your laptop does not have a USB type A socket, you will need to buy the USB
type C to micro usb cable instead (no. 17 in the list).
• Tools: We will use the Arduino IDE software to program the ESP8266. The first thing
you should do is download the Arduino IDE if you do not already have it installed on
your computer. You can do that from this link: https://www.arduino.cc/en/software/.
The web page will appear as shown in Fig. 1.1. It features that latest version of the
Arduino IDE. Select your operating system and download the latest version that is
available when you access the link (it was 2.0.4 at the time of writing).
Note: Installing Arduino IDE from the repository or Microsoft/Apple store is not
recommended because it might install an outdated/flawed version.
ESP8266 Pinout
The ESP8266 12-E NodeMCU kit pinout diagram is shown below.
• GPIO01 & GPIO03 are TX and RX of UART0 which is used to flash the ESP8266 →
Should not use when flashing,
• GPIO0, GPIO2, GPIO15 are used for mode configuration of ESP8266 → Should not
use when flashing,
• GPIO9 & GPIO10 are used to connect with External Flash of ESP8266 → Should not
use,
• GPIO4 (D2), GPIO5 (D1), GPIO12 (D6), GPIO13 (D7), GPIO14 (D5), & GPIO16 (D0)
can be used for any purpose.
- Open the Boards Manager. You can go to Tools → Board → Boards Manager. . . or
you can simply click the Boards Manager icon in the left-side corner.
The board manager will download the ESP8266 board definition files from the link
provided in the preferences window and install them. When the installation is complete,
the ESP8266 board definitions should appear as shown in the screenshot. Now you
can select your ESP8266 board from the Tools | Board menu:
Note 1: The port number might vary for each computer. So select the one that is
applicable to you.
Note 2: In the case the Port option is disabled, it means the driver of CP2102 chip
to be outdated. So you must update the driver manually:
• First, you need to download the “CP210x Universal Windows Driver” from the
following website: https://www.silabs.com/developers/usb-to-uart-bridge-
vcp-drivers?tab=downloads. Then uncompress the downloaded zip file.
• Then, open the Device Manager window from Search window. You might find
the line with a yellow exclamation mark at the beginning “CP210x....”, right-
click on that line and choose Update Driver. Then choose the “....” and select
the folder that contains the downloaded driver.
4. Go to Files menu on your Arduino IDE → Examples → esp8266 → Select the “Blink”
example to open the first sketch of ESP8266. The sketch allows ESP8266 blink a
built-in LED on ESP8266 board.
5. Next, Verify (Compile) the code using “Sketch” drop-down menu (or verify button tick
symbol ). Upload the code to your Arduino board using the “Upload” option from the
“Sketch” drop-down menu or using the right arrow icon (→) on the Arduino IDE.
6. You should now see the LED on the ESP8266 board blinking. Please ask your tutor for
help if this doesn’t work.