A Survey of Hubitat's Bedroom Skills

I've been on a year-long quest to have reliable bed presence detection. Along the way, I think I've attempted all but one of the methods I've read about on the forums here, so I thought a write-up of my successes and failures might be useful to others looking to accomplish the same thing.

(The method I haven't yet attempted is placing an mmWave motion detector under / on the bottom of the bed pointing up, in hopes that it can see the people in the bed. I might test this at some point, but I worry about false positives from the cats sleeping on any bed they can get to.)

Scenario

I have three beds in the house I want to monitor -- the adults and our two kids.

I want to have detection for the kids to squelch the " is up" announcement when the kid is actually in bed and the adult who put them to bed is leaving the room. My son also has a bad habit of getting up and doing things in his room late into the night and then being tired and grumpy the next day, so I have a rule that sends my phone a notification when he's been out of bed for five minutes but not left his room.

For the adults, we have lighting that comes on if we get out of bed at night and should go off once we return to bed. (And mostly, it's because once I endeavor to solve something, I won't give up (darn it!) even if multiple attempts fail.) It would also be nice if some of the morning routines could be tied to getting out of bed, not when someone opened our door. (With small people around, those are distinct events.)

My initial criterion was that I didn't want anything on top of the mattress. Other criteria got added over time.

#1: Tuya Contact Sensors + Seat Mats

I got these cheap ZigBee contact sensors and these pressure pads. After melting a hole in the side of the contact sensor case, I soldered the pressure mat across the reed switch that the magnet trips.

This initially seemed to work, as squeezing the pressure mat would cause the contact sensor to close. However, I quickly found that the required activation pressure was a lot more than that in any one place on a bed. After some experimentation, I found that doubling the mat up on itself would reduce the required activation pressure, since the same force would be hitting more dots at once. However, then it became a tenuous game of how folded was sensitive enough, but not so sensitive it would be tripped by the weight of the mattress.

I eventually found positions that this would mostly work:

  • For the adults' bed, on top of the foundation slat closest to our hips
  • For my son's bed, between one of the slats holding the mattress and the bed frame, so it got pinched by the slat when he was laying in bed.

However, this solution had a number of drawbacks:

  • It never successfully tripped for my daughter's tiny frame
  • My son's bed slats can move, and the slat had to be in just the right spot to correctly trigger, so I was constantly readjusting his bed
  • Detection was inconsistent for my wife, mostly depending on position.
  • This approach appears to eat 2032 batteries every few months. Getting under mattresses to change batteries quickly became annoying.

#1.5: Tuya contact sensors + FSR Strips

I also got some of the SF15-600 force-sensitive resistor strips in hopes of detecting across a larger area. Unfortunately, I didn't realize how prone these were to damage from soldering and lost one pretty much immediately.

I cut one of the pressure sensor mats off the cord connected to the contact sensor and soldered female connectors onto the end, then plugged in the other strip. Putting one of these across the slat on my son's bed and connected to the contact sensor was generally pretty good, and no longer subject to the shifting. It also killed the contact sensor battery about a week later; that may have been conincidence, but made me get more interested in hardwired options.

#2: Strain gauges and ESP8266

After reading this article, I decided to give strain gauges a try. Tared for the weight of the bed, that should be able to differentiate me and my wife, and perhaps even separately indicate the cats, though that's not really a goal.

This solution was also appealing because of the ability to hardwire the power going to the ESP; no more batteries to change inside mattresses!

I got a kit from Amazon that included eight strain gauges and two HX711 modules to read their output back to an ESP8266. This was my first foray into the world of Arduino, and I followed the sample project to report back over MQTT. (I already have an MQTT server from Teslamate, so adding a new publishing source wasn't a big deal.)

Unfortunately, this required a lot of wire-running to get the sensors under all four legs appropriately cross-connected, and even more so to conceal the wires from my cat who likes to chew on wires. Something in that mess of wiring was preventing it from getting a good read, and I never did figure out what. It may be the HX711 board itself; I need to go back and test it. The strain gauge setup is still sitting on my workbench. :unamused:

#3: DIY capacitors and ESP32 touch

For the adult bed, I experimented with this approach using homemade capacitors and the ESP Touch platform. Since the ESP8266 doesn't have the touch capability, I had to acquire an ESP32 for this one. This article used the ESPHome platform, which can be connected to Hubitat using the ESPHome drivers available on HPM).

They were actually really impressive in testing, with the touch value numbers dropping very low under pressure. The drawback for me was getting a solid connection to the aluminum foil and keeping it that way. Things kept coming loose despite continuing attempts to make a better attachment, and part of the point is not needing to get back under the mattress on a regular basis.

Maybe figuring out how to solder onto aluminum foil would have helped here?

Never attempted this on the kids' beds.

#4: ESP8266 + FSR Strips

I tried connecting the FSR strip on my son's bed slat to an ESP8266 (originally bought for the strain gauge), again using ESPHome. My initial attempt tried using the internal pullup resistor as a binary input, which worked on my son's bed but failed completely on my daughter's bed.

Realizing the difference would be very small for her, I added a voltage divider and read the FSR using the ADC. That worked amazingly for my son's bed. The difference for my daughter's bed is still quite small, but with a larger resistor, I think we're in business.

#4.1: ESP32 + FSR Strips

I expected to do the same thing for the adult bed but using the ESP32 because of its ability to read more than one ADC input at a time.

To my consternation, the ADC kept reading the max value on the ESP32. I initially thought it was my omission of attenuation: auto, which increases the input range up to 3.3V and really ought to be the default. However, even after fixing that, they still produce no noticeable response between mattress and foundation -- apparently it's just that good at spreading out the pressure!

Eventually, I moved the FSRs between the foundation and the bed frame, where they're getting a very firm pinch. In that position, they give a clear difference between occupied and not. I do wonder whether a larger resistor would enable these to be under the mattress as well, but at this point I'm not planning to mess with what's working.

Conclusion

I've become a big fan of the ESPHome platform. Really simple to set up a sensor to your specifications, really simple to bring them into Hubitat. If someone is starting down this path, I'd say to start with a ESP dev board and an FSR.

That said, I think this is also a space ripe for someone to come in with a prepackaged produce. A sensitive pressure-sensing mat and a driver that can do some appropriate calibration in the settings would go a long way here. I would definitely rather have purchased something off the shelf.

5 Likes

I just tossed a 24GHz radar behind the headboard pointed through it. Doesn't give me who is in the bed, but when I played around with load cells a while back, they would just drift and drift endlessly so they weren't even useful for anything other than a binary 'adult human(s) in bed or not' anyway.

The one I saw required you to send a "tare" command daily at a time the bed would not be occupied. I was assuming that would compensate for drift, but I didn't get that far.

It was more that it varied the recorded weight.

So I could get on bed, it would read X, I get off, back on 5 seconds later and it would be like 3X, then off, back on, 0.2X. The measurements were just all over the place. But I don't have a bed with 4 bed posts, so I had to put the load cells under the ends of bed slats. Maybe having them under the bed posts would work better, but I'm not buying a new bed to find out.

From your attempts thus far, I gather you desire or require a local solution. Although cloud-based, I've found the off-the-shelf Withings Sleep sensor has provided very reliable bed presence for my family, including kids. Like you, I'd sure love it if there was an off-the-shelf option that was local. It's helpful to see the DIY solutions you've tried!

1 Like

Am I the only one who thought the thread was going in an entirely different direction? :joy:

11 Likes

Well, okay, an off-the-shelf solution for less than $130/person. I wouldn't particularly object to a cloud-based solution, but I definitely prefer local options and I couldn't justify over $500 after tax for this project.

While it's possible I approached that by exploring the solution space, I don't think so. My final design is under $20/person being monitored, I think.

1 Like

How about a thin cheap LED bathroom scale and feed the output into an ESP32? Put the scale under the mattress above the box spring

I have no idea what you could possibly mean! :wink:

Double entendre aside, privacy is a consideration in home automation my wife is very wary of. I'm deliberate about, for example, presence integrations that give me a binary home/away signal rather than giving a location history.

It's useful to be able to open logs for questions like "How early was he up this morning?" I don't think it would fly if I could check the logs for statistics on that topic.

Typically, bathroom scales are strain gauges (#2) under a platform. Under a mattress, they wouldn't be as precise, so I'd expect them to probably be similar to the FSRs, but a bit more lumpy.

Bought two matts that is used in car seats on ebay, they are very cheap.
Hooked up with a door sensor, and in between an optocoupler relay
All powered with a usb suply with a voltage regulator. Works like acharm, guess less than 200 dkr in all

1 Like

I’ve also been interested in something like this for a while, but I gave up as my DIY wiring and soldering skills are pretty minimal, and went with Withings bed sensors for me and my wife.

I haven’t yet gone down the mmWave sensor rabbit hole, but aren’t they capable of distinguishing between someone in the room moving around, or sitting/lying still?

I've gone down the Withings and node-red route. The upside to using node-red is that you've got some serious fine grain control of how you use the sensors. The only problem is that sometime the Withings serves have hiccups and that breaks a lot of my automation as a result.

I originally bought an Aqara FP2 for exactly this purpose although I've never gotten around to trying it. In preliminary testing, I determined that it can't reliably differentiate between a cat and a person. An update has supposedly improved the situation, but I haven't been able to test it yet...

And if the AI pet detection requires continuous cloud access, that is likely a no-go from the start. So, I'm relying on using the sleep number integration for my wife and I. Works well enough for my purposes, but is cloud based so there can be delays up to 1 minute before it changes state.

Genius

I had everything working perfect until my cat decided to sleep on the bed. That became a week long journey to create "cat mode" so I could keep everything on track.

I bought two of these for the wife and myself, cut the wires and connected them to my favorite contact sensors, the eco2.5 and have been very pleased. Takes a minute to get them oriented just right but have used them for years and they drive our awake/goodnight rules daily.

Pressure Mat Alarm with Chime, Floor Alarm Mat System for Home Security https://a.co/d/enlg2cQ

1 Like

I am still using @ogiewon’s Hubduino bed presence sensors. I have an ESP8266 under our adult bed with 2 FSRs attached. Has been working great for several years. Pictures of my setup are in this thread:

1 Like

Following.

Current jury rig has me trying different material to apply car seat pressure sensors to as well as experiment with multiple sensors with a connection splitter. Aqara water sensor makes it easy to connect to Hubitat. Not mains powered for sure/can't speak to battery drain rate. I saw this and this on Amazon & wonder how they would perform. Certainly would prefer to not to have to roll my own. Tried FSR strips ... should say fried FSR strips since they don't come with pigtails so when attempting to make a solder connection - FAIL/destroys the strip :face_with_symbols_over_mouth:

Are you paying attention all ye sensor manufacturer product mgrs. out there? :mega: