Detecting bed-presence using thin film pressure sensors with ESPHome

Disclosure: This post contains affiliate links. If you click through and make a purchase, I will earn a commission, at no additional cost to you. Read my full disclosure here.

Today, we're talking about an ESPHome project that's taken bed automation to a whole new level. The ingenious tech enthusiast behind this project has designed a DIY bed-presence detector, utilizing a few thin film pressure sensors and an ESP32. This nifty device can even tell the difference between the two sides of the bed! It's a bit more intricate than some of the other ESPHome projects we've seen, making use of the ADC sensor. But don't sweat it—the creator has left no stone unturned in explaining how everything fits together.

YouTube video

The joys of a good-night-automation

Are you familiar with the wonder of good-night-automation? It was one of my first projects using Home Assistant, and boy, did it revolutionize my nightly routine. Granted, it wasn't entirely automated, as I had to manually trigger it via my sleep tracker. Still, it was a game-changer, ensuring my cat didn't set off any motion sensors and helping me avoid being blinded by bathroom lights during my nocturnal bathroom trips. Plus, the soothing white-noise lullabies from my Google Nest Mini were a nice touch.

What you need for bed presence detection

Similar to projects involving PWM LED strips, this bed presence detector employs an ESP32—and for a good reason. These boards come with multiple Analog To Digital (ADC) pins, which is vital because each analog pressure sensor in this project requires an ADC pin. If you intend to monitor more than one person in a bed, you'll need multiple pressure sensors.

Powering the ESP32 is a breeze—you can simply use the onboard USB Micro-B connector and an idle phone charger. None of the components are power-hungry enough to require anything more. But keep in mind that if you intend to use the same ESP32 for under-bed lighting, you'd need a sturdier power supply for the LED strips.

The real star of this project is the thin film pressure sensors. These unassuming little devices measure the pressure between two surfaces—in this case, your mattress, and bed. You'll need a resistor between the ground pin and the pressure sensor. The creator used a 5k Ohm resistor, but you might need to do some testing—after all, not all mattresses and people weigh the same.

While the project has been meticulously documented, the wiring process, unfortunately, hasn't been detailed. But don't worry—I found this handy guide that will show you the ropes. You simply replace the ESP8266 with your ESP32, and you're good to go. Just remember, wiring a thin film pressure sensor is slightly different from digital sensors, so it's crucial to get it right.

How the bed presence detection works

Configuring each thin film pressure sensor requires only a few lines of YAML code. The creator has kindly shared the relevant parts of their code for us to replicate. The ESPHome code itself decides whether the bed is occupied. Using on_value_range, an input boolean in Home Assistant is triggered when the pressure exceeds a certain value. For their automations, the creator used Node-RED and has generously made the complete configuration used for the bed presence detection available. So why not give it a go and turn your bed into a smart bed? Now, that's what I call sleeping on cloud nine.

A portrait photo oif Liam Alexander Colman, the author, creator, and owner of Home Assistant Guide wearing a suit.

About Liam Alexander Colman

is an experienced Home Assistant user who has been utilizing the platform for a variety of projects over an extended period. His journey began with a Raspberry Pi, which quickly grew to three Raspberry Pis and eventually a full-fledged server. Liam's current operating system of choice is Unraid, with Home Assistant comfortably running in a Docker container.
With a deep understanding of the intricacies of Home Assistant, Liam has an impressive setup, consisting of various Zigbee devices, and seamless integrations with existing products such as his Android TV box. For those interested in learning more about Liam's experience with Home Assistant, he shares his insights on how he first started using the platform and his subsequent journey.

Leave a comment

Share to...