Review of ESP32

Espressif is one of the fewer IoT companies that grows with just one small, simple and powerfull device, the master robust ESP8266. The ESP8266 is a good choice If've never worked with a Wi-Fi module, it's better start developing with the it first before use the ESP32. For those who that didn't know the powerfull ESP8266, look this video and see an application of large telemetry and control of industrial lights developed in a partnership with my company. About ESP32, we have a new revolution, with Wi-Fi+BT+BLE we have a complete setup for many kind of IoT projects, and as in the past by a lower price than many other choices.
ESP32-Device

General Specs

Reviewing the specifications, we can observe some important points and I'll highlight what I consider as differential and significant:
1. Wi-Fi 802.11 b/g/n/e/i (n up to 150Mbps - let's streaming video on network!)
2. Bluetooth v4.2 BR/EDR and BLE (Class 1, 2 and 3)
3. Interfaces SD card, UART, SPI, SDIO, I2C, LED, PWM, Motor PWM, I2S, I2C and IR
4. Operating current average: 80mA
5. Temperature range: -40 ~ +85°C
6. Wi-Fi modes: Station/SoftAP/SoftAP+Station/P2P
7. Security: WPA/WPA2/WPA2-Enterprise/WPS

Ok, let's do some code and test this module with something.

Install, code, flash and run

First, you'll need to install the IoT Development Framework, with libraries and the flash tool to your local environment to construct the SDK from Espressif. This tutorial just cover the Linux installation, if you want to use in Windows, just follow the other procedure. In Linux, open a terminal and digit:

#I'll use the /opt folder as my install dir... 
cd /opt  
sudo git clone --recursive https://github.com/espressif/esp-idf.git  
#install the dependencies
sudo apt-get install git wget make libncurses-dev flex bison gperf python python-serial  

After this moment, you'll need to get the toolchain, therefore you need to download a compatible version to your machine:

#for 64-bit users
wget https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-61-gab8375a-5.2.0.tar.gz  
#for 32-bit users
wget https://dl.espressif.com/dl/xtensa-esp32-elf-linux32-1.22.0-61-gab8375a-5.2.0.tar.gz  
#untar and move to the right folder
sudo mkdir esp  
sudo mv xtensa-esp32-elf/* esp  
#now update the .bash_profile or .profile into ~/ with the path env. variable
export PATH=$PATH:/opt/esp/bin  
#Depending of you Linux version you need to re-login to the $PATH comes up

Now, let's clone the template and test a hello-world example.

#As the SDK uses the esp-idf folder, just export the environment variable to your .bash_profile or .profile
export IDF_PATH=/opt/esp-idf  
# Copy the example to some dir
cd ~/  
cp -r $IDF_PATH/examples/get-started/hello_world .  
cd hello_world  
make  
#Set the USB and other options in the make menuconfig and

Now, hold the RESET button and in the sequence the GPI0 into low level, and after two seconds, leave both. From this moment the ESP32 will enter in the bootloader mode and you can just type:

make flash  

and you'll see:
ESP-32 Output on flash After the ESP32 serial output will be:
ESP-32 Serial Hello World

Improving the example

If you came here, you see a simple message in your terminal, but wait this is very simple. Let's do something a little more interesting, in the code below there is an improvement that blinks the GPIO 33 of ESP32.

#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "driver/gpio.h"
#include "sdkconfig.h"
#include "esp_spi_flash.h"

#define GPIO_LED GPIO_NUM_33

void blinkTask(void *pvParameter){  
  gpio_pad_select_gpio(GPIO_LED);
  gpio_set_direction(GPIO_LED, GPIO_MODE_OUTPUT);
  while (1) {
    gpio_set_level(GPIO_LED, 0);
    vTaskDelay(1000/portTICK_RATE_MS);
    gpio_set_level(GPIO_LED, 1);
    vTaskDelay(1000/portTICK_RATE_MS);
  }
}

void app_main(){  
    esp_chip_info_t chip_info;
    esp_chip_info(&chip_info);
    printf("[Dark Side of the Solder] Blink LED\n");
    xTaskCreate(&blinkTask, "Demo blink", 512, NULL, 5, NULL);
}

Compiling, flashing and running you must see this:
blink-esp

Thank's and subscribe/share for more posts like this!

References

Ânderson Ignacio da Silva

Electrical Engineer with electronic and protocols skills.

Rio Grande do Sul - Brasil http://aignacio.com

Subscribe to @aignacio's blog

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!