Zbotic Logo Zbotic Logo
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

  • Shop
  • About Us
  • Contact Us
  • Reseller
  • Blogs
020 69134444
1800 209 0998
[email protected]
Help Desk
Facebook Twitter Instagram Linkedin YouTube
Zbotic Logo Zbotic Logo
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

All departments
  • 3D Print Service
  • 3D Printer
  • Batteries & Chargers
  • Development Boards
  • Drone Parts
  • EBike parts
  • Sensor Modules
  • Electronic Components
  • Electronic Modules
  • IoT and Wireless
  • Mechanical Parts and Workbench Tools
  • Motors & Drivers & Pumps & Actuators
  • DIY and Robot Kits
  • Show more
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
Return to previous page
Home IoT & Smart Home

Home Assistant Integration: ESP32 Sensor with ESPHome

Home Assistant Integration: ESP32 Sensor with ESPHome

March 11, 2026 /Posted byJayesh Jain / 0

Integrating a Home Assistant ESP32 sensor using ESPHome is the most beginner-friendly way to build a fully functional, professional-grade smart home sensor network in India. ESPHome is a firmware framework that lets you configure ESP32 and ESP8266 devices using simple YAML files — no C++ programming required. Combined with Home Assistant’s powerful automation engine, you can create sensor dashboards, automation rules, and alerts for everything from room temperature to water tank levels to motion detection, all running locally on your home network with zero cloud dependency. This tutorial covers the complete workflow: setting up ESPHome, flashing your first ESP32 sensor, and integrating it with Home Assistant.

Table of Contents

  1. What is ESPHome and Why Use It?
  2. Hardware You Need
  3. Installing ESPHome
  4. Writing Your First ESPHome Configuration
  5. Adding the Device to Home Assistant
  6. Advanced Sensors and Automations
  7. Frequently Asked Questions

What is ESPHome and Why Use It?

ESPHome is an open-source firmware generation system created by Nabu Casa (the company behind Home Assistant). You describe your device in a YAML file — specifying the board type, Wi-Fi credentials, and which sensors or outputs are connected — and ESPHome compiles a custom firmware binary for you. Flash it to your ESP32 or ESP8266, and the device automatically shows up in Home Assistant as a fully functional integration with no manual API coding required.

The advantages over writing custom firmware from scratch are enormous:

  • No C++ required: YAML configuration is readable and modifiable even by beginners.
  • Hundreds of built-in components: DHT11, DHT22, DHT20, BME280, DS18B20, BMP280, HC-SR04, PIR sensors, relays, buttons, displays — all supported out of the box.
  • OTA updates: After the first flash, all future firmware updates are pushed wirelessly over your home network.
  • Native Home Assistant API: ESPHome uses a custom encrypted protocol for Home Assistant communication — faster and more reliable than MQTT for local networks.
  • Active development: ESPHome is continuously updated with new components, bug fixes, and security patches.

For the Indian maker and smart home enthusiast, ESPHome is particularly valuable because it eliminates dependence on cloud services (no Tuya, no Alexa, no monthly subscription) and runs entirely on your local router network.

Hardware You Need

For this tutorial, we’ll build a room environment monitor with temperature, humidity, and motion detection. You’ll need:

  • ESP32 development board (30-pin or any standard variant)
  • DHT20 or BME280 sensor for temperature and humidity
  • PIR motion sensor module
  • Micro-USB or USB-C data cable (for first flash)
  • A computer running Home Assistant (Raspberry Pi, Intel NUC, or any x86/ARM system)
  • Jumper wires and breadboard (for prototyping)
30Pin ESP32 Expansion Board with Type-C USB

30Pin ESP32 Expansion Board with Type-C USB and Micro USB Dual Interface

This expansion board breaks out all 30 ESP32 pins with breadboard-friendly spacing and supports both Type-C and Micro USB — great for Home Assistant sensor prototyping.

View on Zbotic

DHT11 Digital Relative Humidity and Temperature Sensor Module

DHT11 Digital Relative Humidity and Temperature Sensor Module

The DHT11 is one of the most widely supported sensors in ESPHome, making it ideal for your first Home Assistant temperature and humidity sensor build.

View on Zbotic

Installing ESPHome

There are two ways to use ESPHome: as a Home Assistant add-on (the easiest method if you already have Home Assistant OS), or as a standalone Python package on any computer.

Method 1: Home Assistant Add-on (Recommended)

  1. Open Home Assistant and go to Settings → Add-ons → Add-on Store.
  2. Search for “ESPHome” and click Install.
  3. After installation, click Start and enable Show in sidebar.
  4. Navigate to the ESPHome dashboard from the sidebar — you should see a clean interface ready for your first device.

Method 2: Standalone Python Installation

If you prefer to run ESPHome on a separate machine:

pip install esphome
esphome wizard my-sensor.yaml

The wizard will ask you a series of questions about your board and Wi-Fi network, generating a starter YAML file for you.

Writing Your First ESPHome Configuration

Here is a complete ESPHome YAML configuration for our room environment monitor with a BME280 sensor and a PIR motion detector:

esphome:
  name: room-sensor-1
  friendly_name: "Living Room Sensor"

esp32:
  board: esp32dev
  framework:
    type: arduino

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  ap:
    ssid: "Room-Sensor Fallback"
    password: "fallback1234"

captive_portal:

api:
  encryption:
    key: !secret api_encryption_key

ota:
  - platform: esphome
    password: !secret ota_password

logger:

i2c:
  sda: GPIO21
  scl: GPIO22
  scan: true

sensor:
  - platform: bme280_i2c
    address: 0x76
    temperature:
      name: "Room Temperature"
      unit_of_measurement: "°C"
      accuracy_decimals: 1
    humidity:
      name: "Room Humidity"
      unit_of_measurement: "%"
    pressure:
      name: "Room Pressure"
      unit_of_measurement: "hPa"
    update_interval: 60s

binary_sensor:
  - platform: gpio
    pin: GPIO14
    name: "Motion Sensor"
    device_class: motion
    filters:
      - delayed_off: 30s

A few important notes on this configuration:

  • Secrets file: ESPHome uses a secrets.yaml file to store sensitive values like Wi-Fi passwords and API keys. Never hardcode these in the main config. The !secret tag references a key from this file.
  • Captive portal: If Wi-Fi connection fails, the ESP32 creates its own access point so you can reconfigure it — essential for devices installed in walls or ceilings.
  • API encryption: All communication between ESPHome devices and Home Assistant is encrypted with a 32-byte key you generate. This prevents unauthorised access on your local network.
  • Motion sensor delayed_off: The PIR sensor output stays HIGH for some time after motion stops. The delayed_off: 30s filter ensures the Home Assistant binary sensor stays in the ON state for at least 30 seconds after the last detected motion, preventing rapid toggling.

Flashing the Firmware

From the ESPHome dashboard, click your device and press Install. Choose Plug into this computer for the first flash (requires USB connection). Select the correct serial port (usually /dev/ttyUSB0 on Linux or COM3 on Windows). ESPHome will compile the firmware and flash it automatically — this takes 2–4 minutes. All subsequent updates will be sent wirelessly via OTA.

Adding the Device to Home Assistant

Once the ESP32 is flashed and connects to your Wi-Fi network, Home Assistant will automatically discover it. You’ll see a notification in Settings → Devices & Services saying a new ESPHome device was found. Click Configure and enter the API encryption key from your config. That’s it — within seconds, the room temperature, humidity, pressure, and motion sensor entities will appear in Home Assistant, ready to use in dashboards and automations.

Creating a Dashboard Card

  1. Go to Overview → Edit Dashboard → Add Card.
  2. Choose Entities card and add your sensor entities.
  3. Alternatively, use the Gauge card for temperature or a History Graph card to show trends over the past 24 hours.

Automations

Once your sensor is in Home Assistant, you can create powerful automations. Example: when the room temperature exceeds 32°C and it’s daytime, send a notification to your phone and turn on the AC (via a smart plug). Here’s a simple automation YAML:

alias: High Temperature Alert
trigger:
  platform: numeric_state
  entity_id: sensor.room_temperature
  above: 32
action:
  - service: notify.mobile_app
    data:
      title: "Room Too Hot!"
      message: "Living room is {{ states('sensor.room_temperature') }}°C"

Advanced Sensors and Automations

Adding a DS18B20 Temperature Sensor

The DS18B20 is a waterproof one-wire temperature sensor that’s perfect for measuring outdoor temperatures, water tank temperatures, or refrigerator monitoring. In ESPHome:

one_wire:
  - platform: gpio
    pin: GPIO4

sensor:
  - platform: dallas_temp
    name: "Water Tank Temperature"
    update_interval: 30s
DS18B20 Module for D1 Mini Temperature Measurement Sensor Module

DS18B20 Module for D1 Mini – Temperature Measurement Sensor Module

A plug-and-play DS18B20 temperature sensor module with onboard pull-up resistor, compatible with ESP32 and D1 Mini — perfect for ESPHome water or outdoor temperature sensing.

View on Zbotic

Motion-Triggered Lighting with PIR

ESPHome PIR sensors work seamlessly with Home Assistant automations for motion-triggered lighting. Connect any standard HC-SR501 or similar PIR module’s output to a GPIO pin and configure it as a binary_sensor with device_class: motion. In Home Assistant, create an automation that turns a Philips Hue lamp or a smart plug on when motion is detected at night.

AC 220V Security PIR Human Body Motion Sensor

AC 220V Security PIR Human Body Motion Sensor Detector LED Light Switch

A mains-voltage PIR sensor that directly controls LED lights — combine with a relay-controlled ESP32 node for a complete Home Assistant-integrated motion-lighting system.

View on Zbotic

Multi-Room Sensor Network

The real power of ESPHome and Home Assistant becomes apparent when you deploy multiple nodes across your home. Each room can have its own ESP32 with temperature, humidity, and motion sensors. Home Assistant aggregates all the data and lets you create cross-room automations: “If the kids’ room temperature is above 30°C and motion is detected, turn on the fan in that room only.” With ESPHome OTA updates, you can push firmware changes to all 10 nodes simultaneously from the Home Assistant dashboard.

Frequently Asked Questions

Do I need a Raspberry Pi to run Home Assistant?

No. Home Assistant runs on a Raspberry Pi 4, but also on any x86-based mini PC (like an Intel NUC or a spare laptop), a VM on your existing desktop, or Synology NAS (via Docker). For a small home with under 20 ESPHome devices, a Raspberry Pi 4 with 4 GB RAM is perfectly adequate. Home Assistant OS is the recommended installation method as it handles backups, add-ons, and updates automatically.

Can ESPHome work without Home Assistant?

Yes, partially. ESPHome devices can expose data via MQTT, a REST API, or even simple HTTP endpoints. However, the native ESPHome API is designed specifically for Home Assistant and provides the best experience (automatic discovery, encrypted communication, entity auto-naming). For non-HA setups, configuring MQTT output in ESPHome and pointing it at a standalone Mosquitto broker is a common alternative.

How many ESPHome devices can Home Assistant handle?

Home Assistant can comfortably handle hundreds of ESPHome devices on a home network. The limiting factor is usually your router’s ability to handle many Wi-Fi clients, not Home Assistant’s processing power. For networks with more than 20–30 ESP devices, consider using a dedicated IoT VLAN or a separate access point on the 2.4 GHz band exclusively for IoT devices.

Is ESPHome secure?

ESPHome uses API-level encryption (a 256-bit key exchange) for all communication between devices and Home Assistant. All OTA updates are password-protected. The devices do not communicate with the internet — all traffic stays on your local network. This makes ESPHome one of the most privacy-friendly smart home solutions available, especially compared to cloud-dependent platforms like Tuya Smart.

Can I use ESPHome with ESP8266 D1 Mini?

Yes. ESPHome has full support for ESP8266 boards. The configuration is nearly identical — just change the platform declaration from esp32 to esp8266 and specify the board (e.g., d1_mini). You lose BLE and have fewer GPIO pins, but for simple temperature/humidity/motion sensors the D1 Mini is excellent and very affordable.

Build Your Home Assistant Sensor Network

Get ESP32 boards, sensors, and accessories for your ESPHome + Home Assistant project from Zbotic — fast delivery across India with genuine components.

Shop IoT Components at Zbotic

Tags: DIY smart home India, ESP32 sensor Home Assistant, ESPHome configuration, ESPHome tutorial, Home Assistant ESP32
Share Post
  • Facebook
  • Linkedin
  • Whatsapp
Telegram Bot with ESP32: Remot...
blog telegram bot with esp32 remote control via messaging app 595520
blog time series iot database influxdb with esp32 and grafana 595529
Time Series IoT Database: Infl...

Related posts

Svg%3E
Read more

IoT Home Insurance Sensor Kit: Leak, Smoke, and Motion

April 1, 2026 0
Table of Contents IoT and Home Insurance Water Leak Detection Smoke and Fire Detection Motion and Intrusion Sensing Building the... Continue reading
Svg%3E
Read more

IoT Pet Tracker: GPS Collar with Geofencing Alerts

April 1, 2026 0
Table of Contents Introduction and Overview Hardware Components Required GPS Module Integration with ESP32 Cloud Platform Setup Real-Time Tracking Dashboard... Continue reading
Svg%3E
Read more

IoT Aquaponics Controller: Fish and Plant Automation

April 1, 2026 0
Table of Contents The Water Monitoring Challenge in India Sensor Technologies for Water Building the Sensor Node Data Transmission and... Continue reading
Svg%3E
Read more

IoT Composting Monitor: Temperature and Moisture Tracking

April 1, 2026 0
Table of Contents Why Temperature Monitoring Matters Sensor Selection Guide Hardware Assembly and Wiring Firmware Development Cloud Data Logging Alert... Continue reading
Svg%3E
Read more

IoT Beehive Monitor: Weight, Temperature, and Humidity

April 1, 2026 0
Table of Contents Why Monitor Beehives Weight Measurement System Temperature and Humidity Sensing Building the Monitor Data Analysis for Bee... Continue reading

Add comment Cancel reply

Your email address will not be published. Required fields are marked

Facebook Twitter Instagram Pinterest Linkedin Youtube

Get the latest deals and more.

Download on Google Play Download on the App Store

Call us: 020 69134444 / 1800 209 0998

Monday - Saturday 09:30 AM - 06:00 PM
For Technical Supports Email: [email protected]
For Sales / Enquiries Email: [email protected]

  • My Account

    • Cart

    • Wishlist

    • Checkout

    • My Orders

    • Track Order

    • My Account

  • Information

    • FAQs

    • Blogs

    • Career

    • About Us

    • Contact Us

    • Payment Options

  • Policies

    • Privacy Policy

    • Terms & Conditions

    • GST Input Tax Credit

    • Shipping Return Policy

    • E-Waste Collection Points

    • Our Sitemap

© Zbotic.in is registered trademark of Moxie Supply Pvt Ltd – All Rights Reserved
Login
Use Phone Number
Use Email Address
Not a member yet? Register Now
Reset Password
Use Phone Number
Use Email Address
Register
Already a member? Login Now