What is a microcontroller?
The easiest way to understand what is a microcontroller is to think about a tiny computer: it includes a processor, memory and input/output (I/O) peripherials to connect small display, buttons, motors, sensors, etc. To “control” a microcontroller, you can put programs onto it and run them. As we will see later in this lesson, we usually write programs using a laptop and then transfer the programs into the microcontroller to execute it.
A microcontroller can look like this:
i.e. very much like what we call an “integrated circuit”.
Look for instance at what we see when we zoom in the previous picture:
A typical microcontroller includes a processor, memory and input/output (I/O) peripherals.
What is an ESP8266?
ESP8266 architecture
An ESP8266 is a microcontroller:
- Low-power, highly-integrated Wi-Fi solution
- A minimum of 7 external components
- Wide temperature range: -40°C to +125°C
- ESP8285 — 8 Mbit flash embedded
Source: https://www.espressif.com/en/products/hardware/esp8266ex/overview
Different kind of ESP8266 can be found on the market so your ESP8266 board may differ slightly from the one shown below:
On the picture above, the ESP8266-12 block is where the processor, memory and WIFI unit are located. The rest ensures communication with external sensors, USB port, voltage regulator, etc.
For those interested in computer architecture, have a look at the functional diagram of an ESP8266-12:
Source: https://www.espressif.com/sites/default/files/documentation/0a-esp8266ex_datasheet_en.pdf
Become familiar with the ESP8266-12 architecture
On the picture above, can you identify:
- the CPU (Central Processing Unit)
- the memory SRAM (Static Random Access Memory)
The ESP8266 uses a 32bit processor with 16 bit instructions. It is Harvard architecture which mostly means that instruction memory and data memory are completely separate.
The ESP8266 has on die program Read-Only Memory (ROM) which includes some library code and a first stage boot loader. All the rest of the code must be stored in external Serial flash memory (provides only serial access to the data - rather than addressing individual bytes, the user reads or writes large contiguous groups of bytes in the address space serially).
Depending on your ESP8266, the amount of available flash memory can vary.
As any other microcontroller, ESP8266 has a set of GPIO pins (General Purpose Input(Output pins) that we can use to “control” external sensors.
Our ESP8266 has 17 GPIO pins but only 11 can be used (among 17 pins, 6 are used for communication with the on-board flash memory chip). It also has an analog input (to convert a voltage level into a digital value that can be stored and processed in the ESP8266).
It also has a WIFI communication to connect your ESP8266 to your WIFI network, connect to the internet, host a web server, let your smartphone connect to it, etc.
Another advantage of an ESP8266 is that is can be programmed as any other microcontroller and especially any Arduino.
Why using Arduino GUI?
There are different ways to program the ESP8266 such as micropython (a subset of python) or using the Arduino IDE.
In this lesson, we will be using the Arduino IDE as it has a simple interface with built-in examples.
How to install Arduino Desktop IDE?
- Download Arduino Desktop IDE at Arduino Software
- Choose and click on the corresponding distribution depending on your Operating System (Windows 7, Windows10, Linux 64 bits, etc.)
- Click on “JUST DOWNLOAD” and follow instructions given
- If you do not have administrator rights, download the “Windows ZIP file for non admin install” and unzip it to the desired location.
- Start Arduino Desktop IDE (if it does not start automatically or you don’t find the Arduino IDE shortcut, click on arduino.exe)
How to program an ESP8266 with Arduino GUI?
Install support for ESP8266
- Select “File –> Preferences”
- Add http://arduino.esp8266.com/stable/package_esp8266com_index.json to “Additional Boards Manager URLs”
- Click on “OK”
Verify that the ESP8266 board is recognized
- Connect the micro USB type B side of the cable to the ESP8266 board as shown on the figure below (mind the direction of the connector!)
- Connect the USB type A side of the cable to your computer.
- Open tab “Tools –> Boards –> Boards Manager” and check “NodeMCU 1.0 (ESP-12E Module)” is available. If it is not available, then you also need to install a driver for USB chip; follow instructions given in the next section and go to 4 to continue your installation.
- Select NodeMCU 1.0 (ESP-12E Module) board
Comments
Post a Comment