This blinky project shows how to interface LED to the ESP32 and write a simple program to make the LED blink. The full code is on Github, click here.
Parts List
- ESP-WROOM-32 module
- USB<->TTL converter (3.3.V)
- Efficient power supply (3.3V)
- R1 – resistor 560Ω, see LED Resistor Calculator
- LED1 – basic LED
Circuit Diagram
Firmware
This code is written in C and can be compiled using xtensa-esp32-elf-gcc. Don’t know how to start ? Please read about how to compile and upload program into ESP32.
#include "freertos/FreeRTOS.h" #include "esp_event.h" #include "driver/gpio.h" #define LED_GPIO_PIN GPIO_NUM_4 void app_main(void) { int level = 0; /* setup */ gpio_set_direction(LED_GPIO_PIN, GPIO_MODE_OUTPUT); /* loop */ while (true) { gpio_set_level(LED_GPIO_PIN, level ^= 1); vTaskDelay(500 / portTICK_PERIOD_MS); } }
gpi0 ? reset? How do you bring esp32 in upload firmware mode?
Yes. The ESP32 will enter the serial bootloader when GPIO0 is held low on reset. Otherwise it will run the program in flash. More info here – https://github.com/espressif/esptool/wiki/ESP32-Boot-Mode-Selection.