Topic hub

Sensors and actuators

How to connect sensors and low-voltage actuators to a microcontroller, size I²C pull-ups from the specification, calibrate an ADC, and avoid self-heating and input-pin traps.

Updated 28 November 2026 · I2C, SPI, UART, pull-up resistor, bus capacitance, ADC calibration, self-heating, BME280, H-bridge, RP2350-E9

Overview

Sensors turn a physical quantity into a number the microcontroller can read. Actuators turn a number back into motion, light or heat. This hub is for makers wiring a first sensor and for product teams who need readings they can defend. It covers the three common buses, how to size I²C pull-up resistors from the specification rather than by habit, why an ADC (analogue-to-digital converter) needs calibration, how a sensor can heat itself, and how to drive motors and relays safely at low voltage.

This site covers low-voltage circuits only. Anything that switches mains power belongs in a certified product or module, not in a hand-wired build.

Key ideas

Choose the bus by distance, speed and pins

  • I²C (Inter-Integrated Circuit) uses two shared lines, SDA (data) and SCL (clock), and addresses each device on the bus. It suits several slow sensors on one board.
  • SPI (Serial Peripheral Interface) uses a clock, two data lines and one chip-select per device. It is faster and suits displays, flash and high-rate sensors, at the cost of more pins.
  • UART (universal asynchronous receiver-transmitter) is a point-to-point serial link with no shared clock. GNSS receivers, cellular modems and some particle sensors use it.

NXP’s UM10204 (Rev. 7.0, October 2021) is the I²C reference. It defines Standard-mode at up to 100 kbit/s, Fast-mode at 400 kbit/s and Fast-mode Plus at 1 Mbit/s. Rev. 7 also replaced “master/slave” with “controller/target”, so newer datasheets use those words.

I²C pull-ups come from two limits

I²C lines are open-drain: devices only pull them low, and a resistor to the supply pulls them high. The resistor value has a ceiling and a floor, and UM10204 section 7.1 gives both:

  • Maximum: the line must rise in time. Rp(max) = tr / (0.8473 × Cb), where tr is the maximum rise time (1000 ns in Standard-mode, 300 ns in Fast-mode, 120 ns in Fast-mode Plus) and Cb is the bus capacitance.
  • Minimum: a device must be able to pull the line low. The floor comes from the supply voltage, the allowed low-level voltage and the minimum sink current (3 mA for Standard and Fast-mode, 20 mA for Fast-mode Plus).

Bus capacitance is limited to 400 pF in Standard and Fast-mode and 550 pF in Fast-mode Plus. Every breakout board, cable and pin adds to it. Several breakouts on one bus can each carry their own pull-ups, which combine in parallel and can push the total below the minimum. Our I²C bring-up checklist walks through measuring and fixing this.

VDDRpRpSDASCLControllerTarget 0x76for example BME280Target 2Cb: total bus capacitance, max 400 pF(550 pF in Fast-mode Plus)Rp(max) = tr / (0.8473 x Cb)
An I²C bus: one controller, two targets, a single pair of pull-up resistors and the bus capacitance that limits their value. Our own drawing. Limits from NXP UM10204 Rev. 7.0, Table 11 and section 7.1.

An ADC reading is not a voltage until you calibrate it

An ADC compares the input against a reference voltage, and that reference varies from chip to chip. Espressif’s ESP-IDF v6.1.1 documentation for the ESP32-C5 says the nominal reference is 1100 mV but the true value can range from 1000 mV to 1200 mV between chips. The ESP32-C5 supports a curve-fitting calibration scheme that corrects for this. Use the calibration API and report millivolts, never raw counts.

Board design matters too. The RP2350 ADC has no on-chip reference and uses its own supply instead. On the Pico 2 W that supply comes from the 3.3 V regulator through a 201 Ω and 2.2 µF filter. The Pico 2 W datasheet notes that its switching regulator runs in a power-saving mode (PFM) by default, which adds ripple to the ADC supply at light load. Driving WL_GPIO1 high forces PWM mode for the duration of a conversion and reduces that ripple, at some cost in efficiency. The same datasheet says the ADC draws about 150 µA, which creates an offset of about 30 mV across that filter resistor. Read the board datasheet’s ADC section before trusting the last few bits.

Input pins have their own errata

A floating or slowly changing input can misbehave in ways the datasheet’s main tables do not show. On the RP2350 A2 stepping, erratum E9 lets a GPIO input that sits between the logic thresholds source around 120 µA and hold itself near 2.2 V (at 3.3 V IOVDD). The internal pull-down cannot overcome it. An external pull-down of 8.2 kΩ or less can, and the internal pull-up works normally. Stepping A3 fixes it. Buttons and open-drain sensor outputs are the circuits most likely to hit this. Details and stepping checks are in /topics/microcontrollers-and-socs/.

Sensors can heat themselves

Any sensor that dissipates power warms up, and so does the board under it. Bosch’s BME280 datasheet (Rev. 1.24) says the temperature from its internal sensor depends on PCB temperature, self-heating and ambient temperature, and is typically above ambient. For weather monitoring the datasheet suggests forced mode with one sample per minute, oversampling of 1 and the filter off, and gives 0.16 µA for those settings. The datasheet does not quantify the temperature offset, so measure it against a reference thermometer, in your enclosure, next to your regulator and radio. /topics/enclosures-and-3d-printing/ covers venting and placement.

Drive actuators through a driver, never a GPIO

A GPIO pin can drive an LED. It cannot drive a motor or a relay coil. Use a driver IC or transistor, a separate supply sized for the load, and a shared ground. An integrated H-bridge such as TI’s DRV8833 runs from 2.7 V to 10.8 V and has two H-bridges for two small DC motors. TI rates it at 1.5 A RMS and 2 A peak per bridge in the PWP and RTY packages (at 5 V, 25 °C) and builds in overcurrent, short-circuit, undervoltage and overtemperature protection. For a relay coil, use a transistor driver with a flyback diode across the coil. Keep the relay’s switched side at low voltage too.

Where to start

/learn/beginner/05-sensors-over-i2c/ connects one I²C sensor, scans the bus and reads a datasheet register map. /learn/beginner/04-gpio-timers-and-interrupts/ covers inputs, pull resistors and debouncing. /learn/beginner/10-printing-an-enclosure/ deals with keeping the sensor away from heat sources.

Tools and platforms

Job Option Why Source
Temperature, humidity and pressure on I²C Bosch BME280 Address 0x76 or 0x77 set by the SDO pin BME280 datasheet Rev. 1.24, 6.2
Low-power environmental logging BME280 forced mode, 1 sample per minute 0.16 µA for the suggested settings BME280 datasheet, Table 7
Size I²C pull-ups UM10204 section 7.1 formulas Rise-time ceiling and sink-current floor UM10204 Rev. 7.0
Bring up a new I²C sensor Our I²C bring-up checklist Ordered steps with ESP-IDF return codes UM10204 Rev. 7.0
Calibrated ADC readings on ESP32-C5 ESP-IDF ADC calibration, curve fitting Corrects the 1000 to 1200 mV reference spread ESP-IDF v6.1.1
Quieter ADC on Pico 2 W Force PWM with WL_GPIO1 during conversion Less regulator ripple at light load Pico 2 W datasheet
Two small DC motors TI DRV8833 dual H-bridge 2.7 to 10.8 V, built-in protection TI DRV8833

For makers

Start with one sensor on a short I²C bus at 100 kbit/s. Count the pull-ups on every breakout you add. Log calibrated values with units, and compare the temperature against a separate thermometer before you believe it. Power motors from their own supply through a driver board.

For product teams

Specify bus capacitance and pull-up values in the design review, using the UM10204 formulas and your measured trace and connector capacitance. Characterise ADC accuracy across several units and temperatures, not one board. Measure self-heating in the final enclosure and correct for it in firmware. Check every input circuit against the errata for each chip stepping you may receive.

Common mistakes

  • Stacking breakouts that each carry pull-ups, so the combined resistance falls below the specification’s minimum.
  • Running long I²C cables at 400 kbit/s without checking the rise time.
  • Reporting raw ADC counts as a voltage.
  • Mounting a temperature sensor next to the regulator or radio and calling the reading “room temperature”.
  • Driving a motor or relay coil straight from a GPIO.
  • Relying on an internal pull-down on an RP2350 A2 input.

Going deeper