Peripherals

In this section you will learn how to work with GPIO pins, and the various peripherals that the ESP32 supports, and an example of how to connect sensors to the ESP32.

The ESP32 supports a wide range of peripherals, many of them supported directly by Toit, like the I2C protocol, the SPI communication interface, and GPIO pins.

Selecting the right protocol

Many chips support both SPI and I2C. While Toit makes it easy to write drivers that are usable by both, there are some clear advantages and disadvantages between the two.

I²C

  • Supports longer distances
  • Only requires two wires

SPI

  • Is significantly faster
  • Frequency configurable per device, not the bus

GPIO

With Toit, working with General-Purpose Input/Output (GPIO) pins is easy and they can be configured and manipulated at runtime. In the GPIO section you'll learn how to use the GPIO pins with Toit.