Racks & WattsLOCAL HARDWARE / CLEAR PICKS

Electronics bench & ESP32

Your first ESPHome sensor: ESP32 + temperature, motion and light sensors in Home Assistant

Wire a XIAO ESP32C3 to SHT31 temperature/humidity, BH1750 light and PIR motion sensors. Follow the pin map, ESPHome YAML and Home Assistant setup.

A breadboard with a microcontroller, three sensor boards and coloured jumper wires on a lab bench.

OUR PICKS / YOUR SETUP

Find your fit.

Build around one XIAO ESP32C3: use DFRobot SHT31 SEN0331 for temperature and humidity, ShillehTek BH1750 for lux, and HC-SR501 for motion. Reuse the ELEGOO breadboard and jumpers; flash ESPHome, then add the native integration in Home Assistant.

  • BoardXIAO ESP32C3
  • I²CGPIO6 SDA · GPIO7 SCL
  • MotionGPIO3 · PIR input

How we evaluate hardware.

YOUR NEXT PROJECT / THE GEAR

Parts list

  • Seeed Studio XIAO ESP32C3, three-pack

    Build small Wi-Fi and BLE projects with three documented ESP32-C3 boards and solder-on headers.

    Check price on Amazon
  • ELEGOO EL-CK-002 Electronic Fun Kit

    Prototype with the breadboard, jumper wires and small components before making permanent joints.

    Check price on Amazon
  • DFRobot Fermion SHT31 (SEN0331)

    Read temperature and humidity over the same two signal wires as the light sensor.

    Check price on Amazon
  • ShillehTek BH1750 pre-soldered breakout

    Get lux readings with a pre-soldered header and a simple I²C connection.

    Check price on Amazon
  • ShillehTek HC-SR501 PIR motion sensor

    Add a motion signal you can read on one GPIO, with adjustable hold time.

    Check price on Amazon

Make a room sensor that you can actually change. Start with temperature and humidity, add a light reading, then give it a motion input. One little ESP32 sends all four entities straight to Home Assistant—and the next feature is a YAML edit away.

Use one Seeed XIAO ESP32C3, the DFRobot SHT31 SEN0331, a ShillehTek BH1750 light breakout and its HC-SR501 PIR. The ELEGOO breadboard kit from our first electronics bench guide supplies the breadboard and jumper leads. Already have those? Reuse them.

Specs and wiring from the makers; configuration from ESPHome and Home Assistant docs, checked October 31, 2026.

For adjustable power while debugging, the DC bench supply guide explains current limits and the XIAO’s external-power diode requirement; keep the USB-powered build here for your first run.

The parts, by job

Job Pick Why it belongs here
Wi-Fi brain Seeed XIAO ESP32C3 three-pack Use one USB-C board for this project; save the other two for your next ideas.
Prototyping and wires ELEGOO EL-CK-002 component kit Breadboard and jumper/Dupont leads; leave its separate power module aside.
Temperature + humidity DFRobot Fermion SHT31, SEN0331 I²C breakout; power it from 3.3 V.
Light ShillehTek pre-soldered BH1750 Lux readings on the same I²C bus, with the header already fitted.
Motion ShillehTek HC-SR501 Adjustable hold time and a digital output; give it 5 V power.

You also need an existing Home Assistant server, a USB-C data cable and a 2.4 GHz Wi-Fi network. This board talks over Wi-Fi, so you don’t need a Zigbee coordinator. Explore the Home Assistant hub if you’re still choosing a host.

The XIAO pack’s headers and the SHT31’s supplied header need soldering before you plug them into the breadboard or jumper sockets. The Seeed pack contents and DFRobot shipping list show the separate headers. Our bench guide covers the iron, holder and first joints.

The PIR detects movement. For lights that stay on while you sit still, explore a mmWave presence sensor as your next project.

Wire the XIAO C3 by its labels

Unplug USB while wiring; keep 5 V off the XIAO’s GPIO pins. Mount the XIAO across the breadboard’s centre gap so its two header rows stay separate. Use male-to-male leads between breadboard contacts and female-to-male leads from exposed sensor headers to the breadboard.

Two sensors share I²C: SDA carries data and SCL carries the clock. On this board, D4 is GPIO6/SDA and D5 is GPIO7/SCL. D1 is GPIO3, our motion input. Follow Seeed’s C3 pin map, not a pin diagram for a different ESP32.

XIAO connection Connect to
3V3 SHT31 VCC and BH1750 VCC
GND SHT31 GND, BH1750 GND and PIR GND
D4 / GPIO6 SHT31 SDA and BH1750 SDA
D5 / GPIO7 SHT31 SCL and BH1750 SCL
5V, supplied by USB HC-SR501 VCC only
D1 / GPIO3 HC-SR501 OUT
GND BH1750 ADDR, selecting 0x23

Use the printed pin names on each breakout rather than assuming every three-pin connector has the same order. Leave the SHT31’s INT and RST pins unconnected for this build. You can distribute each supply through its own breadboard rail; keep the 3.3 V and 5 V rails separate and join all grounds.

The SEN0331 accepts 2.15–5.5 V; we use 3.3 V for both I²C boards. The BH1750 module has onboard pull-ups. The PIR needs a 5–20 V supply but outputs 3.3 V HIGH, so its OUT can go directly to GPIO3. Power the assembled build through the XIAO’s USB-C port.

Give it an ESPHome configuration

On Home Assistant OS, install ESPHome Device Builder through Settings → Apps → Install App, then select Start → Open Web UI. For Home Assistant Container, use the separate Device Builder install described in the official installation guide.

Choose Create device → New Device Setup, name it bench-sensor and select the ESP32-C3 board. Open Edit and use the configuration below. Keep your Wi-Fi credentials in secrets.yaml; put the wizard’s generated API encryption key there as bench_sensor_api_key, too. That key is a base64-encoded 32-byte key, not a password you invent. The native API documentation provides a key generator.

esphome:
  name: bench-sensor
  friendly_name: Bench Sensor

esp32:
  board: seeed_xiao_esp32c3
  framework:
    type: esp-idf

logger:

api:
  encryption:
    key: !secret bench_sensor_api_key

ota:
  - platform: esphome
    encryption:

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

i2c:
  sda: GPIO6
  scl: GPIO7
  frequency: 50kHz
  scan: true

sensor:
  - platform: sht3xd
    address: 0x45
    temperature:
      name: Temperature
    humidity:
      name: Humidity
    update_interval: 60s
  - platform: bh1750
    name: Illuminance
    address: 0x23
    update_interval: 10s

binary_sensor:
  - platform: gpio
    pin: GPIO3
    name: Motion
    device_class: motion

Your secrets.yaml needs the three entries referenced above: wifi_ssid, wifi_password and bench_sensor_api_key. Keep that file private. The encrypted OTA configuration reuses the API key for future wireless firmware updates.

This DFRobot board uses 0x45, as shown in its SEN0331 example. ESPHome’s generic SHT3x example defaults to 0x44; the explicit address above matters. The BH1750 component uses 0x23. The two addresses let both sensors share the same wires.

Flash once, then add it to Home Assistant

  1. Attach the XIAO’s supplied antenna and connect its USB-C data cable to your computer. Use Chrome or Edge for browser flashing; follow ESPHome’s USB connection guide for the secure browser connection.
  2. Validate. In Device Builder, open the device’s overflow menu and select Validate. Fix any YAML errors before moving on.
  3. Install over USB. Select Install and the option for the device attached to your computer. Select its serial port and complete the first flash. On later edits, select Install again to send the new firmware wirelessly—Save alone doesn’t change the board.
  4. Watch Logs. Let it join Wi-Fi, then look for the I²C scan and the sensor readings. The scan should find 0x45 and 0x23 with this wiring.
  5. Add the integration. In Home Assistant, open Settings → Devices & services and add the discovered ESPHome device. Enter its API encryption key when prompted. If discovery doesn’t appear, choose Add integration → ESPHome and enter the device’s address and key.
  6. Name its area. Put Bench Sensor in the room where you’ll use it. Temperature, Humidity, Illuminance and Motion now belong to one device.

The ESPHome getting-started guide covers the Builder flow; the Home Assistant ESPHome integration connects directly through the native API.

Make the readings do something

First, prove each input is alive. Give the PIR about a minute to settle, set its jumper to H for repeat triggering and start with a short hold time. Walk across its view, then stand clear and let Motion return to clear. Shade the BH1750 and uncover it; allow its 10-second polling interval for each change. Temperature and humidity refresh every 60 seconds.

Now make a lamp welcome you into a dim room. This recipe uses an existing Home Assistant light:

  1. Open Settings → Automations & scenes → Create automation → Create new automation.
  2. Under When, add State changed for Bench Sensor Motion. Set From to off and To to on.
  3. Under And if, add Numeric state for Bench Sensor Illuminance. Set Below to a threshold chosen from your own bright-room and dim-room readings.
  4. Under Then do, add Light: Turn on, choose the lamp and Save.

Use Run actions to check the lamp action. Then dim the room, wait for Illuminance to update and for Motion to clear, and walk past the sensor. The state trigger starts the automation on movement; the numeric-state condition checks the light level at that moment. Add an off routine later, once the first half works.

Troubleshooting: fix one layer at a time

Symptom Next move
No USB serial port Try a known data cable. Hold the XIAO’s BOOT button while connecting USB to enter download mode, then retry the installer.
Board stays offline Check the Wi-Fi secrets and 2.4 GHz access; read the USB logs before changing sensor wiring.
Neither I²C sensor appears Check common ground, 3V3 power and SDA/SCL against GPIO6/GPIO7. Recheck any split breadboard rails.
Scan finds SHT31 at 0x44 Use the scanned address in YAML; its address jumper may be configured differently. Save and install again.
PIR is stuck or chatters Check its 5 V supply, allow warm-up, shorten the hold time and move it away from changing heat sources.
HA finds it but cannot connect Copy the API encryption key from this device’s secrets entry; use manual ESPHome setup if discovery is blocked.

Keep the USB cable accessible while learning. It gives you a route back to logs and a fresh flash even when Wi-Fi isn’t cooperating.

Give the finished sensor some breathing room

Keep the temperature breakout away from the ESP32’s heat, leave the light sensor exposed to the room and give the PIR lens an unobstructed view. Prototype the placement before designing the box.

Use our printed homelab parts guide for mounts and inserts, or the printed radio-case guide for board-clearance and cable-exit ideas. Size the enclosure for this circuit. For the next project, head back to the electronics bench—you still have two XIAOs waiting.

Want to ask for the reading instead of opening a dashboard? Our local Assist hardware and setup guide adds a voice endpoint to your Home Assistant project.

If the wiring looks right but the sensor stays silent, capture and decode its I2C bus with a USB logic analyzer to see addresses and acknowledgements.

For a closer look at a supply rail or control signal, the first oscilloscope guide walks you through probe compensation and a low-voltage first session.

Sources & methodology

Where these facts come from.

Source dates are listed above.

As an Amazon Associate I earn from qualifying purchases.

YOUR NEXT PROJECT / THE GEAR

Parts list

  • Seeed Studio XIAO ESP32C3, three-pack

    Build small Wi-Fi and BLE projects with three documented ESP32-C3 boards and solder-on headers.

    Check price on Amazon
  • ELEGOO EL-CK-002 Electronic Fun Kit

    Prototype with the breadboard, jumper wires and small components before making permanent joints.

    Check price on Amazon
  • DFRobot Fermion SHT31 (SEN0331)

    Read temperature and humidity over the same two signal wires as the light sensor.

    Check price on Amazon
  • ShillehTek BH1750 pre-soldered breakout

    Get lux readings with a pre-soldered header and a simple I²C connection.

    Check price on Amazon
  • ShillehTek HC-SR501 PIR motion sensor

    Add a motion signal you can read on one GPIO, with adjustable hold time.

    Check price on Amazon

Prepared by Racks & Watts.