ESP32: 26 Free Guides for Sensors and Modules

There is a wide variety of sensors, modules, and peripherals compatible with the ESP32 boards. We have tutorials for the most popular components. This article is a compilation of 26 free guides for ESP32 sensors and modules. Most guides cover programming the ESP32 using the Arduino core, but we also have tutorials for MicroPython.

ESP32: Free Guides for Sensors and Modules

We have a similar article for the ESP8266: 20 Free Guides for Sensors and Modules [ESP8266].

Here’s a quick list of the sensors/modules:

Environmental Sensors:

  1. DS18B20 Temperature Sensor
  2. Type-K Thermocouple Temperature Sensor
  3. DHT11/DHT22 Temperature and Humidity Sensor
  4. BME280 Temperature, Humidity, and Pressure Sensor
  5. BME680 Environmental Sensor (Gas, Pressure, Humidity, Temperature)
  6. BMP388 Altimeter Sensor (Pressure, Altitude, Temperature)
  7. BMP180 Barometric Sensor (Pressure, Altitude, Temperature)
  8. BH1750 Light Sensor
  9. TDS Sensor (Total Dissolved Solids)

Motion-Related Sensors:

  1. PIR Motion Sensor
  2. Door Sensor (reed switch)
  3. HC-SR04 Ultrasonic Sensor
  4. MPU6050 Accelerometer and Gyroscope
  5. RCWL-0516 Microwave Radar Proximity Sensor

Other Sensors/Modules/Peripherals:

  1. microSD Card Module
  2. Potentiometer
  3. Relay Module
  4. Load Cell with HX711 Amplifier

Displays:

  1. OLED Display (SSD1306)
  2. I2C LCD (Liquid Crystal Display)
  3. RGB LED Strip

Communication:

  1. LoRa Transceiver
  2. I2C Multiplexer (TCA9548A)

Motors:

  1. Servo Motor
  2. DC Motor
  3. Stepper Motor

Environmental Sensors

1. DS18B20 Temperature Sensor

DS18B20 Temperature Sensor Tutorial for ESP32

The DS18B20 temperature sensor is a one-wire digital temperature sensor. This means that it just requires one data line (and GND) to communicate with your ESP32. Each DS18B20 temperature sensor has a unique 64-bit serial code. This allows you to wire multiple sensors to the same data wire. So, you can get temperature from multiple sensors using just one GPIO.

The DS18B20 temperature sensor is also available in waterproof version.

DS18B20 Temperature Sensor Tutorial for ESP32

To get started, you can follow the next tutorials:

Arduino core:

MicroPython:

Get a DS18B20 Temperature Sensor.

Get a DS18B20 Temperature Sensor (waterproof version).

2. Type-K Thermocouple Temperature Sensor

K-Type thermocouple with MAX6675 Amplifier Tutorial for ESP32

A K-type thermocouple is a type of temperature sensor with a wide measurement range like −200 to 1260ºC (−326 to 2300ºF). To get the temperature from the thermocouple we need a thermocouple amplifier. We use the MAX6675 amplifier that is sold together with the thermocouple, but you can use any other amplifier, like the MAX31855.

To get started, follow the next tutorial:

Arduino core:

Get the Type-K Thermocouple temperature sensor.

3. DHT11/DHT22 Temperature and Humidity Sensor

DHT11 and DHT22 Sensor Tutorial for ESP32

The DHT11 and DHT22 sensors are used to measure temperature and relative humidity. These sensors contain a chip that does analog to digital conversion and spits out a digital signal with the temperature and humidity. This makes them very easy to use with any microcontroller.

To get started, follow the next tutorials:

Arduino Core:

MicroPython:

Get a DHT22 temperature and humidity sensor.

Get a DHT11 temperature and humidity sensor.

4. BME280 Temperature, Humidity, and Pressure Sensor

BME280 Sensor Tutorial for ESP32

The BME280 sensor module reads barometric pressure, temperature, and humidity. Because pressure changes with altitude, you can also estimate altitude. There are several versions of this sensor module: some can communicate using only I2C communication protocol, and others have the additional option to use the SPI communication protocol. We usually use the I2C protocol with this sensor. This sensor is very versatile and we use it in many of our tutorials.

To get started, follow the next tutorials:

Arduino core:

MicroPython:

Get a BME280 temperature, humidity, and pressure sensor.

5. BME680 Environmental Sensor (Gas, Pressure, Humidity, Temperature)

BME680 Sensor Tutorial for ESP32

The BME680 is an environmental sensor that combines gas, pressure, humidity, and temperature sensors. The gas sensor can detect a broad range of gases like volatile organic compounds (VOC). For this reason, the BME680 can be used in indoor air quality control.

To get started, follow the next tutorials:

Arduino core:

MicroPython:

Get a BME680 environmental sensor.

6. BMP388 Altimeter Sensor (Pressure, Altitude, Temperature)

BMP388 Altimeter Tutorial for ESP32

The BMP388 is a precise, low-power, low-noise absolute barometric pressure sensor that measures absolute pressure and temperature. Because pressure changes with altitude, we can also estimate altitude with great accuracy. For this reason, this sensor is handy for drone navigation and other applications like vertical velocity calculation; internet of things; weather forecast, and weather stations; health care applications; fitness applications; and much more.

To get started, follow the next tutorial:

Arduino core:

Get a BMP388 altimeter sensor.

7. BMP180 Barometric Sensor (Pressure, Altitude, Temperature)

BMP180 Barometric Sensor Tutorial for ESP32

The BMP180 is a digital pressure sensor and it measures the absolute pressure of the air around it. It features a measurement range from 300 to 1100hPa with an accuracy down to 0.02 hPa. Because temperature affects the pressure, the sensor comes with a temperature sensor to give temperature compensated pressure readings.

Additionally, because the pressure changes with altitude, you can also estimate the altitude based on the current pressure measurement. The sensor communicates with a microcontroller using I2C communication protocol.

To get started, follow the next tutorial:

Arduino core:

Get a BMP180 barometric sensor.

8. BH1750 Light Sensor

BH1750 Light Sensor Tutorial for ESP32

The BH1750 is a 16-bit ambient light sensor that communicates via I2C protocol. It outputs luminosity measurements in lux (SI-derived unit of illuminance). It can measure a minimum of 1 lux and a maximum of 65535 lux. It can be used in a wide variety of projects. For example: to detect if it is day or night; to adjust or turn on/off LED’s brightness accordingly to ambient light; to adjust LCDs and screen’s brightness; to detect if an LED is lit; etc.

To get started, follow the next tutorial:

Arduino core:

Get a BH1750 ambient light sensor.

9. TDS Sensor (Total Dissolved Solids)

TDS Sensor Tutorial for ESP32

A TDS meter indicates the total dissolved solids like salts, minerals, and metals, in a solution. This parameter can be used to give you an idea of water quality and compare water from different sources. One of the main applications of a TDS meter is aquarium water quality monitoring.

To get started, follow the next tutorial:

Arduino core:

Get a TDS (total dissolved solids) sensor.


Motion Related Sensors

10. PIR Motion Sensor

PIR motion sensor with the ESP32 tutorial

The PIR motion sensor is ideal to detect movement. PIR stands for “Passive Infrared” and it measures infrared light from objects in its field of view. So, it can detect motion based on changes in infrared light in the environment. It is ideal to detect if a human or animal has moved in or out of the sensor range.

Get started with the following tutorials:

Arduino core:

MicroPython:

Get a PIR Motion Sensor (HC-SR501).

11. Door Sensor (reed switch)

A magnetic contact switch is a reed switch encased in a plastic shell so that you can easily apply it on a door, a window, or a drawer to detect if it is open or closed.

We have several tutorials with the ESP32 that use a reed switch and send notifications when the door is opened or closed:

Get a magnetic reed switch.

12. HC-SR04 Ultrasonic Sensor

HC-SR04 Ultrasonic Sensor tutorial with ESP32

The HC-SR04 ultrasonic sensor uses sonar to determine the distance to an object. This sensor reads from 2cm to 400cm (0.8inch to 157inch) with an accuracy of 0.3cm (0.1inches), which is good for most hobbyist projects. In addition, this particular module comes with ultrasonic transmitter and receiver modules.

Get started with one of the following tutorials:

Arduino core:

MicroPython:

Get an HC-SR04 ultrasonic sensor.

13. MPU6050 Accelerometer and Gyroscope

MPU6050 Accelerometer Gyroscope Tutorial for ESP32

The MPU-6050 IMU (Inertial Measurement Unit) is a 3-axis accelerometer and 3-axis gyroscope sensor. The accelerometer measures the gravitational acceleration and the gyroscope measures the rotational velocity. Additionally, this module also measures temperature. This sensor is ideal to determine the orientation of a moving object.

To get started, follow the next tutorial:

Arduino core:

Get an MPU6050 accelerometer and gyroscope.

14. RCWL-0516 Microwave Radar Proximity Sensor

The RCWL-0516 is a small, inexpensive sensor that uses microwave radar to detect the presence of moving objects. The RCWL-0516 sensor has a single output pin that goes HIGH when it detects movement. It outputs LOW when no motion is detected. This sensor is many times used as an alternative to the PIR motion sensor.

Get started with the following tutorial:

Get an RCWL-0516 Microwave Radar Proximity Sensor.


Other Sensors/Modules/Peripherals

15. microSD Card Module

microSD card module tutorial with ESP32

The microSD card module allows you to interface the ESP32 with a microSD card. You can use the microSD card with the ESP32 to create, write, read, and delete files. It can be very useful for datalogging, to save configuration files or save files to serve to clients via a web server.

To get started, follow the next tutorial:

Arduino core:

Get a microSD card module.

16. Potentiometer

potentiometer tutorial for ESP32

A potentiometer, also referred to as a pot, is a manually adjustable resistor that can be used in numerous applications: adjust the speed of a DC motor, adjust the position of a stepper or servo motor, adjust threshold values, adjust light intensity, and much more.

To get a value from a potentiometer, you need to know how to read analog signals with the ESP32. Get started with the following tutorials:

Arduino core:

MicroPython:

To learn how a potentiometer works, we recommend taking a quick look at the following guide:

Get a potentiometers assortment kit.

17. Relay Module

relay module with ESP32 tutorial

A relay is an electrically operated switch and like any other switch, it that can be turned on or off, letting the current go through or not. It can be controlled with low voltages, like the 3.3V provided by the ESP32 GPIOs, and allows us to control high voltages like 12V, 24V, or mains voltage (230V in Europe and 120V in the US).

Using a relay with the ESP32 is a great way to control AC household appliances remotely. Get started with the following tutorials:

Arduino core:

MicroPython:

Get a relay module:

18. Load Cell with HX711 Amplifier

Load cell with HX711 amplifier tutorial for ESP32

The load cell you see in the picture above is a strain gauge load cell. A strain gauge is an electrical sensor that measures force or strain on an object. The resistance of the strain gauge varies when an external force is applied to an object, which results in a deformation of the object’s shape (in this case, the metal bar). The change of the resistance is proportional to the load applied, which allows us to calculate the weight of objects.

Get started with the following tutorial:

Arduino core:

Get a load cell with the HX711 amplifier.


Displays

19. OLED Display (SSD1306)

The organic light-emitting diode (OLED) display is a monocolor display that doesn’t require backlight, which results in a very nice contrast in dark environments. Additionally, its pixels consume energy only when they are on, so the OLED display consumes less power when compared with other displays. It’s available with different drivers, but we recommend getting the one with the SSD1306 driver, which is the most supported. There is also a wide variety of OLED sizes. We usually use the 0.96-inch display with 128×64 pixels.

There are also ESP32 boards with a built-in OLED display. This is very useful because you don’t need any extra circuitry if you want to add a physical visual interface to your project: ESP32 Built-in OLED Board (Wemos Lolin32): Pinout, Libraries and OLED Control.

Arduino core:

MicroPython:

Get an 0.96inch SSD1306 OLED display.

20. I2C LCD (Liquid Crystal Display)

LCD I2C tutorial for ESP32

The simplest and cheapest display screen around is the liquid crystal display (LCD). LCDs are found in everyday electronics devices like vending machines, calculators, parking meters, and printers, and are ideal for displaying text or small icons.

LCDs are measured according to the number of rows and columns of characters that fit on the screen. You’ll find sizes ranging from 8×1 to 40×4. A 16×2 LCD can display 2 rows of 16 characters each and this is the one we use most in our projects. We recommend getting one that supports I2C because it makes wiring and coding even easier.

Get started with the following tutorial:

Arduino core:

Get an I2C LCD display.

21. RGB LED Strip

RGB LED Strip ESP32 tutorial

LED strips are just amazing, and there are a wide variety of LED strips to choose from. They can be analog, or digital, and vary in the density and number of LEDs, power supply, etc. To learn more about the main differences between LED strips, I recommend taking a look at the following article: What’s the Best LED Strip For Your Project?

Analog LED strips have their LEDs wired in parallel. The whole strip works as a giant RGB LED. So, you can light up your whole strip in many different colors, but you can’t control LEDs individually. This means your strip can only be one color at a time. This type of LED strips are cheaper than the digital ones and easier to use. You can follow the next tutorial that shows how to use those LED strips:

Arduino core:

When it comes to digital LED strips, you can control each LED individually – these are also called addressable LED strips. You can chose each LED color, its brightness and when they should be on and off. This allows you to do all sorts of crazy and awesome effects. Our favorite addressable RGB LED strip is the WS2812B. We have a MicroPython guide showing how to control an addressable RGB LED strip and produce amazing effects.

MicroPython:

Get an Analog RGB LED Strip.

Get a WS2812B addressable RGB LED Strip.


Communication

22. LoRa Transceiver

RFM95 LoRa Transceiver module tutorial for ESP32

LoRa is a wireless data communication technology that uses a radio modulation technique that can be generated by Semtech LoRa transceiver chips. This modulation technique allows long-range communication of small amounts of data (which means a low bandwidth), and high immunity to interference while minimizing power consumption. So, it allows long-distance communication with low power requirements.

To use LoRa in your projects, you can use a transceiver like the RFM95 or use an ESP32 with a built-in LoRa transceiver module.

Get started with the following tutorials:

Arduino core:

Get an RFM95 LoRa transceiver module.

Get an ESP32 with a built-in LoRa chip.

23. TCA9548A I2C Multiplexer

TCA9548A I2C Multiplexer Tutorial for ESP32

The I2C communication protocol allows you to communicate with multiple I2C devices on the same I2C bus as long as each device has a unique I2C address. However, it will not work if you want to connect multiple I2C devices with the same address.

The TCA9548A I2C multiplexer allows you to communicate with up to 8 I2C devices with the same I2C bus. The multiplexer communicates with a microcontroller using the I2C communication protocol. Then, you can select which I2C bus on the multiplexer you want to address.

Get started with the following tutorial:

Arduino core:

Get a TCA9584A I2C multiplexer.


Motors

24. Servo Motor

Learn how to control a servo motor with the ESP32 remotely using a web server:

Get a micro servo motor.

25. DC Motor and L298N Motor Driver

DC motor with 298N motor driver tutorial for ESP32

Learn how to control a DC motor (speed and direction) with the ESP32 using the L298N motor driver. To get started, follow the next tutorial:

Arduino core:

Get a mini DC motor.

Get a L298N motor driver.

26. Stepper Motor

ESP32 with Stepper Motor (28BYJ-48 and ULN2003 Motor Driver)

A stepper motor is a brushless DC electric motor that divides a full rotation into a number of steps. It moves one step at a time, and each step is the same size. This allows us to rotate the motor at a precise angle to a precise position. The stepper motor can rotate clockwise or counterclockwise.

To get started, follow the next tutorial:

Arduino core:

Get a stepper motor (2BYJ-48).

Wrapping Up

This was our compilation of tutorials for the most popular sensors, modules, and peripherals compatible with the ESP32.

If you have a sensor/module that you would like to be covered on our website, just write a comment below.

We hope you find this article useful. Don’t forget to bookmark this page for the future and share it with a friend that also likes electronics.

If you want to learn more about the ESP32, check out the following resources:



Learn how to build a home automation system and we’ll cover the following main subjects: Node-RED, Node-RED Dashboard, Raspberry Pi, ESP32, ESP8266, MQTT, and InfluxDB database DOWNLOAD »
Learn how to build a home automation system and we’ll cover the following main subjects: Node-RED, Node-RED Dashboard, Raspberry Pi, ESP32, ESP8266, MQTT, and InfluxDB database DOWNLOAD »

Recommended Resources

Build a Home Automation System from Scratch » With Raspberry Pi, ESP8266, Arduino, and Node-RED.

Home Automation using ESP8266 eBook and video course » Build IoT and home automation projects.

Arduino Step-by-Step Projects » Build 25 Arduino projects with our course, even with no prior experience!

What to Read Next…


Enjoyed this project? Stay updated by subscribing our newsletter!

16 thoughts on “ESP32: 26 Free Guides for Sensors and Modules”

  1. This tutorial is THE one to have!
    It is really good for at least 2 kinds of people:
    — those who have an actual project in mind and need to valuate sensors, and those who don’t have any particular project in mind, BUT just want to learn about the many possibilities that exist to sensing the outside world with the ESP32.
    I have taken much of this course and have experienced the use of many of these sensors and I can testify to how excellent this tutorial is.
    This is what you should take to learn about sensors!!

    Reply
  2. This tutorial list is excellent. I have used some of these sensors before and will probably use others in future projects. Thanks for bringing it all together.

    Reply
  3. Very good, thanks!
    I need to measure the liquid (water) level of a tank. Do you have any ideas you can suggest me?
    I would need to measure 3 or 4 levels.

    Reply
    • Such a sensor may be a vertical wire mounted on an insulator connected to the GPIO input with a high value pull-up resistor (of the order of 100k or more). Ground GND of the ESP board. When the water level reaches the end of the wire, it closes the circuit and reduces the voltage at the GPIO input from logical one to logical zero.

      Reply
  4. Hi
    Is there any tutorial for measuring distance / water level using infra red sensor .
    Thanks and regards.

    Reply
  5. Do you have any experience of the Gravity: I2C Ozone Sensor (0-10ppm) from DF Robot?
    I have a micropython project that will use that soon. There is a library from the manufacturer but my experience with micropython libraries from manufacturers is that I normally have to completely re-write them. The arduino library is normally good.

    Reply

Leave a Comment

Download Our Free eBooks and Resources

Get instant access to our FREE eBooks, Resources, and Exclusive Electronics Projects by entering your email address below.