geekcowboy.neta florea.xyz revival

Home automation

Live sensor graphs you own, with an ESP32, a BME280, ESPHome and Home Assistant

Hosted sensor-data services come and go, so keep the data at home. An ESP32 and a $15 BME280 sensor send temperature, humidity and pressure to Home Assistant, which keeps the history and draws the graphs. For people without Home Assistant, the same node can publish over MQTT or serve its own page.

By florea.xyz ·

Sending your sensor readings to someone else’s server is the easy way to get a graph you can see from anywhere. It is also how you lose them.

Pachube was the classic example. It was a hosted service, started by London architect Usman Haque, that collected sensor data from anyone’s projects. LogMeIn bought it in 2011 for $15 million. It became Cosm in May 2012 (that month the Arduino Ethernet library swapped its Pachube examples for Cosm ones “due to Pachube.com rebranding”), and Xively in May 2013, when developer and hobbyist accounts were still free. In February 2018 Google announced it was buying Xively to strengthen its Cloud IoT Core service. In August 2022 Google gave a year’s notice that Cloud IoT Core would close, and it was retired on 16 August 2023. Today xively.com redirects to a Google Cloud architecture page (checked 27 November 2026).

The lesson is not that those companies were bad. It is that a graph you care about should live on a machine you control. This build does that: a sensor node on your Wi-Fi, and Home Assistant at home keeping the history.

What you need

Prices from Adafruit, checked 27 November 2026, both in stock:

Part Example Price
ESP32 board Espressif ESP32-DevKitC (ESP32-WROOM-32E) $15.00
Sensor Adafruit BME280 breakout: temperature, humidity, pressure $14.95

Any DevKit-style ESP32 board works with the configuration as it is (for another ESP32 board, change board: and the I2C pins), and so does any BME280 breakout. Check that it says BME280 with an E, though: the BMP280 measures only temperature and pressure (ESPHome has a separate bmp280_i2c platform for it).

You also need a USB cable for the first flash, four jumper wires, and Home Assistant running somewhere at home.

Wiring

The BME280 talks I2C. On an ESP32 DevKitC, ESPHome’s usual I2C pins are GPIO21 for data and GPIO22 for clock:

BME280 board ESP32 DevKitC
VIN (or VCC) 3V3
GND GND
SCK (or SCL) GPIO22
SDI (or SDA) GPIO21

Adafruit’s board has a regulator and level shifting, so 3.3 V on VIN is fine. A bare module that also brings out CSB and SDO needs two more wires. Tie CSB to 3.3 V: Bosch’s datasheet requires a direct connection to select I2C. Do not leave SDO floating: to GND it gives address 0x76, to 3.3 V it gives 0x77. Adafruit’s board defaults to 0x77 and has a jumper for 0x76.

Pull-ups. I2C needs a pull-up resistor from SDA and from SCL to 3.3 V. ESPHome turns on the ESP32’s internal pull-ups by default, but its documentation still recommends external ones for longer wires or several devices on the bus. Check whether your breakout already has them (its schematic or product page will say). If it does not, fit two 4.7 kΩ resistors, which is Bosch’s “normal value”.

The configuration

ESPHome builds the firmware from one YAML file. Put your Wi-Fi details and an API key in secrets.yaml next to it. The key is 32 random bytes in base64, and openssl rand -base64 32 makes one.

sensor-node.yaml

# sensor-node.yaml: an ESP32 and a BME280 send temperature, humidity and pressure to Home Assistant.
# geekcowboy.net, 2026. MIT licence.
esphome:
  name: sensor-node
  friendly_name: Sensor node

esp32:
  board: esp32dev

logger:

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

api:
  encryption:
    key: !secret api_encryption_key

ota:
  - platform: esphome

i2c:
  sda: GPIO21
  scl: GPIO22

sensor:
  - platform: bme280_i2c
    address: 0x77            # 0x76 if SDO is tied to GND: the I2C scan in the boot log shows which
    update_interval: 60s     # one reading a minute, Bosch's suggestion for weather monitoring
    temperature:
      name: Temperature
      oversampling: 1x
      filters:
        - sliding_window_moving_average:
            window_size: 5   # the mean of the last five readings...
            send_every: 5    # ...sent once every five readings
    humidity:
      name: Humidity
      oversampling: 1x
      filters:
        - sliding_window_moving_average:
            window_size: 5
            send_every: 5
    pressure:
      name: Pressure
      oversampling: 1x
      filters:
        - sliding_window_moving_average:
            window_size: 5
            send_every: 5

Flash it over USB the first time with uvx esphome run sensor-node.yaml, or from the ESPHome Device Builder app in Home Assistant. The ota: block lets later changes go over Wi-Fi.

Update interval and filters

Bosch’s datasheet suggests these settings for weather monitoring: forced mode, one sample a minute, ×1 oversampling and the IIR filter off. ESPHome already uses forced mode, so the chip measures and then sleeps until the next reading. Its defaults are a 60 s interval with the filter off, but 16× oversampling, so the configuration sets oversampling: 1x on all three readings.

The sliding_window_moving_average filter then sends one value every five minutes: the mean of the last five readings. That smooths the noise, and it matches the five-minute statistics Home Assistant keeps (see below). send_first_at defaults to 1, so a value still arrives right after boot rather than five minutes later. If you would rather have a rolling average every minute, set send_every: 1. If a sensor throws the odd wild reading, a median filter (window of 5 by default) drops single spikes before they reach the graph.

Reading every second gains you nothing for a room. The air does not change that fast, and the chip measures, and warms itself, more often than it needs to.

Keep the sensor away from the ESP32

This is what bites most temperature nodes. Bosch’s datasheet says the BME280’s temperature “depends on the PCB temperature, sensor element self-heating and ambient temperature and is typically above ambient temperature.” Put the breakout on top of the ESP32 board, or shut both in a small box, and you are partly measuring the ESP32.

So put the sensor on a short cable, outside the enclosure and below it rather than above, since warm air rises. Then leave a trusted thermometer next to it for a day. If the node still reads consistently high, correct it with an offset filter, for example - offset: -0.8 above the averaging filter. Fix the placement first, though. An offset cannot follow an error that changes with the board’s load or the weather.

Into Home Assistant

Once the node is on your Wi-Fi, Home Assistant normally finds it on its own: it shows up as Discovered under Settings → Devices & services. Add it, and when it asks for the encryption key, enter the one from secrets.yaml. If it is not discovered, add the ESPHome integration by hand from the same page. The three readings appear as sensors of the Sensor node device.

History and long-term statistics

The History panel graphs the sensors straight away. For a dashboard, two cards matter. Both can be added from the dashboard editor without writing YAML. These are the equivalents, and your entity IDs may differ, so pick yours from the list:

type: history-graph
title: Sensor node, last 48 hours
hours_to_show: 48
entities:
  - sensor.sensor_node_temperature
  - sensor.sensor_node_humidity
type: statistics-graph
title: Temperature, daily
entities:
  - sensor.sensor_node_temperature
period: day
days_to_show: 30
stat_types:
  - min
  - mean
  - max
chart_type: line

How much is kept is the part worth knowing:

What Resolution Kept
Every state as sent 10 days by default (the recorder’s purge_keep_days)
Short-term statistics 5 minutes as long as the recorder keeps states
Long-term statistics 1 hour indefinitely

Both kinds of statistics hold the minimum, maximum and mean of each period, and they are only kept for sensors with a state_class. ESPHome gives the BME280’s readings state_class: measurement by default, so you get them without doing anything. The history graph card uses them too: set hours_to_show beyond the recorder’s ten days and long-term statistics fill in the older part of the graph. The statistics graph card is the one for “what was the coldest night in January”, at a period of hour, day, week or month.

From anywhere

Home Assistant’s documentation gives two sensible ways to look at the graphs away from home. One is Home Assistant Cloud, which needs no open ports on your router. The other is a VPN such as Tailscale or ZeroTier. It warns that just forwarding a port “is not secure”. Either way the history itself stays on your own machine.

Without Home Assistant

The same node can run without Home Assistant. Replace the api: block with this, and add mqtt_password to secrets.yaml:

mqtt:
  broker: 192.168.1.10       # your broker's address
  username: sensor-node
  password: !secret mqtt_password
  discovery: false           # nothing is listening for Home Assistant discovery

web_server:
  port: 80
  version: 3

Remove api:, do not just add to it. ESPHome’s documentation warns that otherwise the node reboots every 15 minutes, because no client ever connected to the native API. Setting reboot_timeout: 0s under api: is the alternative.

The web server gives you a page at http://sensor-node.local/, on your own network only. In version 3, clicking a sensor expands a graph. That graph lives in your browser and holds the last 50 values it received while the page was open, so it is a quick look, not an archive. By default the page’s script loads from oi.esphome.io, so the browser needs internet access. local: true builds it into the firmware instead.

MQTT is the route to a graph that keeps history. With topic_prefix left at its default (the node’s name), each reading goes to a topic of the form sensor-node/sensor/temperature/state as a plain number. Run mosquitto_sub -v -t 'sensor-node/#' to see the exact topics. From there, the usual self-hosted chain is:

  • Telegraf, with its mqtt_consumer input subscribed to sensor-node/sensor/+/state, data_format = "value" and data_type = "float". Each message becomes one number, tagged with its topic.
  • InfluxDB to store them. Telegraf has outputs for InfluxDB 1, 2 and 3.
  • Grafana to draw them. It ships with an InfluxDB data source that supports all three versions.

That chain was not built for this article, so no Telegraf or Grafana configuration is given here. It is four programs to keep running instead of one, so unless you already run them, Home Assistant is the shorter way to the same graphs.

Sources