← Glossary
Scientific experiments and activities with an ESP32 microcontroller

ESP32

The ESP32 is a 32-bit microcontroller from Espressif Systems that integrates Wi-Fi and Bluetooth, as well as interfaces for sensors and external peripherals. In FizziQ, it serves as a remote sensor for recording measurements at a distance.

Discover FizziQ

How to measure it in class

FizziQ records in the experiment notebook the data transmitted by an ESP32, which acts as a remote sensor. Its Wi-Fi or Bluetooth link makes it possible to measure at a distance, with no wire between the board and the phone.

Steps:

  • Wire the sensor to an analog input of the ESP32, making sure the delivered voltage never exceeds 3.3 V: unlike the Arduino Uno, the board does not accept 5 V on its inputs.
  • Program the board from the Arduino IDE or in MicroPython to read the input and convert the raw value (0 to 4095) into a physical quantity.
  • Enable the wireless link and pair the board, then check that the values are coming through before starting the acquisition.
  • Place the board where the measurement is needed - inside an enclosure, on a moving object, outdoors - and record the series of measurements in FizziQ.
  • Plot the resulting curve and export it, then discuss the quantization step of the measurement in light of the amplitude of the observed signal.

Learn more

Characteristics and history

The ESP32 is based on a dual-core Tensilica Xtensa LX6 processor and 4 MB of flash memory. It embeds numerous interfaces (serial ports, I2C, SPI, PWM, ADC, DAC) and supports Wi-Fi 802.11 b/g/n and Bluetooth 4.2 (BR/EDR/BLE). Announced in 2016, it quickly established itself thanks to its advanced features, low power consumption and affordable cost, and is now used in robotics, home automation, the Internet of Things (IoT) and music creation.

A microcontroller that measures where the smartphone cannot go

The ESP32 is used to move the measurement away from the phone. A smartphone cannot be immersed, heated, left outside for an entire night, or attached to a launched projectile. A board costing a few euros can. The built-in Wi-Fi and Bluetooth also make it possible to receive the data remotely while the experiment is under way, without having to retrieve the board.

The 12-bit analog-to-digital converter

The ESP32 digitizes voltages over 12 bits, that is 4096 levels, on a range of 0 to 3.3 V. The quantization step is therefore about 0.81 mV, compared with 4.9 mV for an Arduino Uno over 0-5 V. That is a factor-of-six gain in resolution. Be careful, however: this converter is known for its non-linearity, particularly near 0 V and above 3 V. Fine resolution does not guarantee good accuracy; calibration is required.

Common mistake: confusing resolution and accuracy

A display with four decimal places does not make a measurement exact. Resolution only says what the smallest detectable variation is. Accuracy depends on the calibration of the sensor, the stability of the power supply and electrical noise. On an ESP32, power supply noise when the Wi-Fi is transmitting is often the main source of scatter in the measurements.

Orders of magnitude

Quantization step: 0.81 mV over 0-3.3 V. Clock frequency: up to 240 MHz. RAM: 520 KB. Sampling frequency usable in practice for continuous acquisition: from a few hertz to a few kilohertz depending on the processing. Deep-sleep consumption: on the order of 10 µA, which allows measurement campaigns lasting several days on battery power.

Formula

The ESP32 does not obey any physical law of its own. The useful relations are those of signal digitization.

Quantization step of the converter:

q = U_ref / 2^n

where:

  • q: smallest distinguishable voltage variation (V)
  • U_ref: full-scale voltage, 3.3 V on an ESP32 (V)
  • n: converter resolution, 12 bits on an ESP32

Numerical application: q = 3.3 / 4096 ≈ 8.1 × 10⁻⁴ V, or about 0.81 mV.

Conversion of the raw value into a voltage:

U = N × U_ref / (2^n − 1)

where:

  • U: voltage present on the analog input (V)
  • N: integer value read, between 0 and 4095

Condition on the sampling frequency, from the Shannon criterion:

f_s > 2 × f_max

where:

  • f_s: sampling frequency of the acquisition (Hz)
  • f_max: highest frequency present in the measured signal (Hz)

Application examples

  • Record the outdoor temperature every minute for an entire night and plot the cooling curve: impossible with a smartphone, whose battery life and fragility rule it out.

  • Measure the illuminance inside a greenhouse for a week thanks to deep sleep and battery power.

  • Monitor the pressure in a closed enclosure and transmit the values via Bluetooth to the smartphone left outside.

  • Digitize a capacitor discharge: with a step of 0.81 mV, the decay can be followed over nearly four time constants before noise dominates.

  • Mount the board on a rotating object and transmit the measurements over Wi-Fi, a connecting wire being impossible here.

  • Build a small network of several boards measuring the temperature at different points in a room, to map a thermal gradient.

FAQ

Q: What is the difference between an ESP32 and an Arduino Uno? A: The ESP32 integrates Wi-Fi and Bluetooth, runs at 240 MHz and digitizes over 12 bits; the Arduino Uno has no wireless link, runs at 16 MHz and digitizes over 10 bits. On the other hand, the Arduino accepts 5 V on its inputs and remains simpler to use and better documented.

Q: Can a sensor designed for 5 V be connected to an ESP32? A: Not directly. The ESP32’s inputs are limited to 3.3 V and a higher voltage damages the board. A voltage divider or a logic level adapter must be inserted.

Q: Does 12-bit resolution guarantee a more accurate measurement? A: No. It only guarantees the ability to distinguish finer variations. The ESP32’s converter is notoriously non-linear at the ends of its range, and without calibration the value obtained can deviate significantly from the actual voltage.

Q: Does the ESP32 have built-in sensors? A: No, no sensor usable in physics. Unlike the micro:bit, all the sensors you need must be wired to it. It is an acquisition interface, not a measuring instrument.

Q: Does Wi-Fi disturb the measurements? A: It can. Radio transmission causes current surges that make the power supply fluctuate and add noise to the analog inputs. For a fine measurement, it is better to acquire and then transmit, rather than transmit during the acquisition.

Arduino - Micro:bit - Resolution - Sampling - Sensor Calibration

Explore FizziQ

Discover all the science experiments you can do with your smartphone.