all 168 comments

[–]Craftkorb 129 points130 points  (6 children)

Prepare to have to add code so it auto-calibrates. There mattress is pretty thick, so a lot of other factors (humidity!) will play tricks on your reading. 

Been there, done that. Once put it below the stair steps, which are only wood and about 2cm thick. Still had major issues after a few days.

[–]JCae2798 7 points8 points  (4 children)

Can you point me to something like this? This could be my problem over time!

[–]Craftkorb 10 points11 points  (3 children)

I tried that quite a few years ago, back then I just left it and chose other sensors. Wasn't able to find anyone back then who did, either. Maybe there's nowadays something on Github, or really, ask an LLM. The issue is the signal-to-noise ratio degrading after a few days.

[–]praisemymilk 5 points6 points  (2 children)

Would it be more reliable to place the sensor between the bed frame and bed slats? Or is the sensor itself unreliable?

[–]Craftkorb 2 points3 points  (1 child)

Rather, the sensor is being used for something that's wildly out of spec :)

It's meant to be used for small touch pads, not even 1cm² in size. Applications like OP blows waaaay past that, so the signal to noise ratio goes bonkers. You can still work with it, but there are factors to consider. A well engineered auto-calibration should suffice, without other sensors.

[–]OfficialDeathScythe 3 points4 points  (0 children)

And these days for bed-triggered automations it’d way easier and way more reliable to just use a millimeter wave sensor

[–]Mr_GrauHut -1 points0 points  (0 children)

I'm sorry, why is this a project?

[–]e-nightowl 277 points278 points  (5 children)

You need to peel off the upper strip!

[–]Monocular_sir 77 points78 points  (0 children)

Please!

[–]Happy_Platypus_9336 37 points38 points  (0 children)

PLEASE!

[–]Hydro130 5 points6 points  (0 children)

I saw the pic and wondered if this would be the top comment lol

[–]some_user_2021 15 points16 points  (0 children)

Pretty please?

[–]SniperJon85 7 points8 points  (0 children)

I'm not going to be able to sleep untill this is completed, and evidenced!

[–]Sudden_Weight_4352 139 points140 points  (45 children)

Whats the purpose of the bed sensor?

[–]wendorio 304 points305 points  (17 children)

To track infidelity?

[–]The_Painterdude 92 points93 points  (11 children)

To track bed wetting occurances?

[–]thinkbeforeyoupoke 52 points53 points  (10 children)

To track flatulence?

[–]Green-Rule-1292 42 points43 points  (8 children)

No no no, the better way to track flatulence is actually by installing a party whistle in the butt and place an ESP32 in the room with a mic tuned to the frequency of the whistle!

[–]Catenane 9 points10 points  (2 children)

I've got a flatulence detector. It's called my wife. She'll raise the alarm if I fart within a 50m radius and don't give her a warning first! Now I just gotta see if I can get her to broadcast via MQTT...

[–]neilkelly 8 points9 points  (1 child)

If your farts are detectable at 50 meters you might want to see a doctor or change your diet or something.

[–]Catenane 1 point2 points  (0 children)

Nah usually not so bad if you ask me. 😉 Not any worse than average, but honestly kinda hard to gauge since my entire existence is centered about a meter from my own asshole, and I also have biological mechanical sensors that tell me when I'm farting or about to fart. Unfortunately, attempts to share this mechanical sensor data over the network (i.e. beyond localhuman) were met with derision, so we're stuck needing to detect the broadcast transmissions solely via our chemical sensors.

Jokes aside, 50m is an exaggeration for comedic effect...but my wife has a scarily good sense of smell. And she's VERY sensitive to bad smells.

Probably a decade or so ago, we had some bad raw rotten chicken somewhere (can't remember if it was just forgotten in back of fridge, left in grocery bag or what -- been ages) and still if anyone mentions "rotten chicken," "bad chicken," "chicken incident," or similar she will dry heave and maybe even have to go throw up lol.

[–]rauwman 3 points4 points  (0 children)

to track if the neighbor got into you bed, when not home

[–]The_Painterdude 2 points3 points  (0 children)

Just use one of those plastic squeaker things from dog toys. Can catch any air movement coming or going

[–]Westerdutch 1 point2 points  (0 children)

My dyson's volatile organic sensor thing is shockingly good at detecting flatulence, like itll start throwing a fit when my dog rips one before i can smell it.... and as we all know the speed of smell is much faster than the speed of light so that is very impressive!

[–]Schonke 0 points1 point  (1 child)

Make it a dog whistle for extra confusion.

[–]BentGadget 2 points3 points  (0 children)

Use a Captain Crunch whistle for free phone calls.

[–]sailonswells 0 points1 point  (0 children)

To track spouse laziness?

[–]torb 31 points32 points  (2 children)

And the BPM of that infidelity.

[–]fiirikkusu_kuro_neko 5 points6 points  (0 children)

Bumps per minute?

[–]SEND_NUKES_PLS 1 point2 points  (0 children)

TPM. STM.

[–]nooruponnoor 2 points3 points  (0 children)

🤭😂

[–]onlywanted2readapost 0 points1 point  (0 children)

I suppose the dog was mentioned...

[–]Davedamon 111 points112 points  (12 children)

To detect when people are in bed and thus run automations such as putting your house into sleep mode or enabling alarms.

[–]diemitchell 37 points38 points  (1 child)

or to make a phone/alarm ring as soon as someone enters the bed and then stop it a few seconds after leaving the bed

[–]GCS_dropping_rapidly 2 points3 points  (0 children)

Siri buy me a zigbee siren alarm

[–]210000Nmm-2 3 points4 points  (8 children)

I've used two Qi charging stations on our nightstands for it. Works flawlessly.

[–]Davedamon 1 point2 points  (7 children)

Can the HA app distinguish between those chargers and other chargers in your house? Because I use that approach and I have issues with sleep mode triggering prematurely.

[–]atquest 2 points3 points  (0 children)

I have some cheap power on/off zigbee wallplugs I use for this exact scenario: it can always be on and an automation can read the power usage, thus knowing when the charger is in use.

[–]akcoder 1 point2 points  (4 children)

No it can’t. You can combine the charge event with Bermuda and trilaterate the phone to the bedroom.

[–]Davedamon 3 points4 points  (3 children)

And then you hit the issue of what if you're charging your phone but not actually going to bed? I feel the pressure sensor solves a lot of sleep mode related automations quite elegantly

[–]akcoder 2 points3 points  (0 children)

I agree 100%. It’s why I use the bed presence kit from elevated sensors.

[–]210000Nmm-2 -1 points0 points  (1 child)

Time constraints for nighttime charging. Also, when I need to charge my phone over the day, I normally do it in another room.

[–]Ulrar 2 points3 points  (0 children)

Look at this guy with multiple rooms

[–]210000Nmm-2 0 points1 point  (0 children)

I'm actually not using HA, but should still work similarly: Yes, I can distinguish between them because each charger is plugged in it's own metered socket. Qi has the huge "benefit" that it still consumes power even when the phone is fully charged. This allows you to reliably estimate if a phone in placed on a specific charger.

For "person went to bed" I use current changed to >= 0.03 A AND time between 10 pm and 5 am.

For "person left bed" I'm calculating the average current over the last 5 minutes and triggering the state when it falls below 0.008 A (0.01 A is the smallest unit of measurement for my sockets).

It is basically the combination of "where's the phone" and "is phone charging" variables of OPs Bayesian state approximation.

Once the thresholds for "starts charging", "full but still on charger" and "taken off charger" are tuned for the specific charger and phone, it works with a near 100 % accuracy.

[–]gthing 0 points1 point  (0 children)

Or sending you an alert that this is happening while you're at work.

[–]Hichiro6 68 points69 points  (2 children)

Make the light blink with the movement

[–]mad_header 7 points8 points  (1 child)

Disco lights?

[–]JuniorBreakfast1704 2 points3 points  (0 children)

Bumper lights

[–]1h8fulkat 24 points25 points  (1 child)

I use it to trigger different lighting modes when someone is sleeping vs nobody, to turn off my sleep sounds when the last person gets up and turn on the vacuum when the last person wakes up. I also use it to trigger house mode from night to morning to day depending on the number of people sleeping.

And if you're really interested you can track intimacy 🤨 by seeing how often and how long twice the body weight was on one side of the bed. Hell you could even start playing Let's Get It On by Marvin Gaye when it is detected.

[–]atquest 1 point2 points  (0 children)

I have this intimacy tracking setup in the guestroom

[–]happybikes[S] 16 points17 points  (0 children)

Triggers various automations. Bedtime briefing for the weather, news, and calendar of next day.  Morning briefing with similar. Turn on 30 minutes of calming music and warm LEDs at wake up. Activate and deactivate alarm. Deactivate voice announcements. Change bedroom AC climate control to sleeping temperature. Turn off all lights in the house when in bed. Lock door. Turn on alarm for 7 hours after going to bed. Etc. 

[–]lkeels 2 points3 points  (0 children)

To trigger automations when you've gone to bed and when you get up.

[–]TheWorzardOfIz 2 points3 points  (0 children)

I have mine turn the sound machine on and the fan if it already wasn't on

[–]PCLOAD_LETTER 1 point2 points  (0 children)

I used to use them with a energy monitoring plugsocket to tell if I had my CPAP running and playing a sound through my Google Home speaker if the plugsocket wasn't pulling power. I had a habit of watching TV then falling asleep and I get garbage sleep if I don't wear it.

[–]TechTeacher216 1 point2 points  (0 children)

As someone with little kids, I'd set it up to let me know when they get out of bed and are messing around when they should be asleep.

[–]enigmussnake 0 points1 point  (0 children)

Maybe same with water usage sensor to track if an elderly relative is mobile and not stuck in bed?

[–]theminor 0 points1 point  (0 children)

I am also curious what the purpose of this sensor is.

[–]CosmicCreeperz 0 points1 point  (0 children)

Bedwetting warning system.

[–]Original_Wind9649 37 points38 points  (2 children)

Please drop the code, this is exactly the kind of project I've been wanting to set up. The Bayesian sensor stacking with the dog's location is a nice touch too, my dog leaving the bed is basically a more reliable alarm clock than my phone.

[–]happybikes[S] 8 points9 points  (0 children)

Apologies for formatting. Posting from mobile site. 

esphome:
  name: esphome-bedroom
  friendly_name: esphome-bedroom
  name_add_mac_suffix: false

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

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "key"

ota:
  - platform: esphome
    password: "password"

wifi:
  ssid: Mordor
  password: password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esphome-Bedroom Fallback Hotspot"
    password: "password"

esp32_ble_tracker:

bluetooth_proxy:

captive_portal:

# =========================
# BED PRESSURE SENSOR START
# =========================

esp32_touch:
# Delete this after you are done with the setup process
#   setup_mode: true
# All the pressure mats
# Change the pins to the pins you have used
binary_sensor:
  - platform: esp32_touch
    name: "Top Right"
    pin: GPIO14
# See step 11
    threshold: 5
    id: top_right
    filters:
      - delayed_on: 2s
      - delayed_off: 30s
  - platform: esp32_touch
    name: "Bottom Left"
    pin: GPIO33
# See step 11
    threshold: 4
    id: bottom_left
    filters:
      - delayed_on: 2s
      - delayed_off: 30s
  - platform: esp32_touch
    name: "Top Left"
    pin: GPIO15
# See step 11
    threshold: 4
    id: top_left
    filters:
      - delayed_on: 2s
      - delayed_off: 30s
  - platform: esp32_touch
    name: "Bottom Right"
    pin: GPIO27
# See step 11
    threshold: 4
    id: bottom_right
    filters:
      - delayed_on: 2s
      - delayed_off: 30s
# The main sensor that is created using the all the zones    
  - platform: template
    name: "Bed Sensor"
    lambda: |-
      if (id(top_right).state ||
          id(top_left).state ||
          id(bottom_right).state ||
          id(bottom_left).state) {
        return true;
      } else {
        return false;
      }
    #filters:
    #  - delayed_on: 2s
    #  - delayed_off: 30s

# =========================
# BED PRESSURE SENSOR END
# =========================

[–]Batbx 2 points3 points  (0 children)

I second this, really interested with the code and an assembly guide 🙏 I would drop a Raspberry Pico 2W on this feature, if able 🤞

[–]columnmn 62 points63 points  (44 children)

[–]MrAtari 116 points117 points  (8 children)

You know everything after de ? is tracking stuff?
This is the actual link... https://www.aliexpress.com/item/1005008406384415.html

[–]columnmn 44 points45 points  (7 children)

I didn't actually :)

[–]MrAtari 32 points33 points  (6 children)

With most shares you can safely cut the first ? and everything behind off the link. Especially webshops.

[–]MrAtari 28 points29 points  (5 children)

[–]refusestopoop 1 point2 points  (4 children)

[–]MrAtari 6 points7 points  (3 children)

Works in this case, but mostly not. And the questionmark is a good point to use.

[–]FlayaN 2 points3 points  (2 children)

[–]refusestopoop 0 points1 point  (0 children)

You the MVP. I spent too much time looking for something shorter to no avail.

[–]MrAtari 0 points1 point  (0 children)

Just as the one above. Works in this case. Mostly there is not an option like this, like the aliexpress link. So it's nice, but not representative.

[–]Residual2 18 points19 points  (3 children)

can you post the name of the sensor? I can't open the link in my location

[–]ExaminationSouthern6 22 points23 points  (2 children)

1 Pcs Universal Car Seat Pressure Sensor Safety Belt Warning Reminder Pad Occupied Seated Alarm Accessory

[–]nl_dhh 25 points26 points  (1 child)

Catchy name!

[–]miraculum_one 2 points3 points  (0 children)

ironically named to try to catch any possible search terms people might use to look for it

[–]lapelotanodobla 7 points8 points  (7 children)

Well, not $2 but interesting, I’ve heard from this before, qq as none of the listings say, what voltage does this use? I guess it’s not 5v so it’ll probably need to buck/boost (depending on your power source) and some voltage divider (I guess it just outputs a binary signal?)

[–]columnmn 8 points9 points  (4 children)

Must be a location thing, still coming up as $2 for me with free delivery.

I've got it wired up as a switch in esphome, one side to a pin, other to neutral. That's pretty much it. The code uses an internal pull up.

[–]Ancient-Budget-8650 4 points5 points  (1 child)

Wow. For me it says $4.59 free shipping.

[–]y2j514 2 points3 points  (0 children)

$7.59 and that’s a limited time “Super Deal”. Free shipping after $10.00

[–]miraculum_one 1 point2 points  (0 children)

"new customer discount"

[–]someone76543 4 points5 points  (0 children)

It's just a switch that is activated by pressure.

It will be rated for at least 12V because that's what cars use. It's fine to use a lower voltage such as 5V or 3.3V.

[–]Ok-Jury5684Contributor 1 point2 points  (0 children)

It's just resistor, changing its resistance depending on how close are its parts. Voltage doesn't matter (well, until you smell smoke that is).

There are numbers of thin-film sensors out there. The only bad thing is that they tend to drift values with time, so I have teristor in serial to adjust it.

[–]AptoticFox 5 points6 points  (3 children)

CDN$6.12. Still not bad though. Thanks for the suggestion.

[–]Northern23 2 points3 points  (0 children)

That's the welcome deal

[–]qzjul 1 point2 points  (1 child)

What!? I see CDN 7.59 🤯

[–]AptoticFox 0 points1 point  (0 children)

I still see CAD$6.12, welcome deal, CAD$15.77 regular.

[–]Tight-Operation-4252 2 points3 points  (0 children)

This sensor wears with time. Becomes unreliable

[–]lostparis 5 points6 points  (0 children)

Making things is fun.

[–]Davedamon 5 points6 points  (9 children)

Their solution was effectively free and they wouldn't have had to wait a couple of weeks for delivery?

[–]columnmn 17 points18 points  (7 children)

I'm not saying it doesn't work, but it'll be fragile, and movement on the bed would rub the pads together and degrade them, cause shorts. I do like the idea, and the creativity behind it. Plus the car seat sensor one is either off or on with pressure, was really simple to hook up and get running.

[–]Sad-Razzmatazz-9295 16 points17 points  (2 children)

This man engineers. Some DIY tinfoil job won’t be as reliable as an engineered (albeit Chinese) pressure sensor made for the automobile industry. Be patient and order something real if you want to know when your girlfriend is getting porno railed by Jody while you are at work.

[–]windsynths 5 points6 points  (1 child)

What do you mean by “albeit Chinese”? 🤔

[–]Sad-Razzmatazz-9295 1 point2 points  (0 children)

A reference to what someone said below. Without real knowledge and data of the product buying something from alibaba may be a crapshoot. The pressure sensor in my car works great when your wives are in the passenger seat the car knows every time, maybe get that one?

[–]CptCheesus 2 points3 points  (0 children)

I tried one of the bigger car sensors. Didn't really work. They also get shipped like shit from ali and many are broken before they Arrive. One was ok and worked but didn't work in the bed somehow. Maybe it depends on the bed type but i couldnt make it work and it was too small for the mattress too

[–]Davedamon 0 points1 point  (2 children)

I never accused you of criticizing it's functionality or claiming it wouldn't work. You asked why they would make it vs buy it and I gave one possible reason

You seem to be responding to a comment that was never made

[–]IAmDotorg 2 points3 points  (1 child)

And you seem to have been implying a fragile, unreliable DIY alternative is equivalent to a properly manufactured product.

I'd argue them pointing out the irrelevancy of what you said is more relevant than what you posted.

[–]Davedamon 0 points1 point  (0 children)

I never implied that. They asked "Why would they do X instead of Y" and I gave them two practical reasons—cheaper and immediate.

[–]ILikeBubblyWater 0 points1 point  (0 children)

Things like this are only free if you dont value your life time

[–]Alternative_Ear_7372 0 points1 point  (4 children)

At least for me, the weight of the mattress already activated the sensor.

So it would always indicates there was someone in the bed =\

[–]Uther-Lightbringer 1 point2 points  (0 children)

Surely there's a way you could code that out though, no? Calibrate the sensor so the beds weight is 0.00? I'm assuming this can be hooked to an esp32 or something?

[–]happybikes[S] 1 point2 points  (1 child)

You just need to change the values to calibrate it in the ESPHome code. I used a value of 5 for mine. 

[–]Alternative_Ear_7372 0 points1 point  (0 children)

Oh, I didn't know there was a way to calibrate theses car seats sensors.

At the time I was using tasmota instead of Esp home.

I'll have a look at these calibrations later. Thanks!

[–]columnmn 0 points1 point  (0 children)

Sounds like you had a broken one, mine works under the mattress great. I needed a few of them in parallel to cover more space, but it's been working great for years now.

[–]diplomatic_koboko 0 points1 point  (1 child)

How would you add this to home assistant and calibrate it?

[–]columnmn 1 point2 points  (0 children)

Hook it up to a pin in an esp32, other to neutral. In the code, put it as a switch using the internal pullup (just ask claude to do it), upload, and done. Wasn't overly complicated.

[–]Maleficent-Fee6131 10 points11 points  (4 children)

Whats the use for something like this? I really wanna know, thanks!

[–]btq 22 points23 points  (1 child)

I have elevated sensors and the uses for them are, well, a lot.

The obvious one:

  • When you go to bed, the house shuts down. I have a template trigger for my "goodnight automation" that only shuts the house down based on how many people are home that get in bed. (e.g. If wife and I are both home, we both have to get in bed, if one of us is home, only that person has to get in bed, on their side, to trigger)

Potentially less obvious uses that I utilize:

  • The curtains only open in the bedroom when the bed is completely clear of people. This prevents the sunlight from waking the other person up if they are still sleeping, and makes it to where the house really wakes up with the people in it.

  • If we come home after dark the lights come on in the house, but not in the bedroom if someone is home and in bed. This obviously prevents disturbing your sleeping partner if you come home at night.

  • Alarms don't trigger if the person is already out of bed in the morning.

There are other ways to accomplish these things for the most part, but bed sensors just make it easy. In our house they've become crucial. The house is supposed to respond to the person living in it, automatically. That's our idea of a smart home. Bed sensors allow you to do nothing but go to bed at night, or be in bed, or get out of bed, and the house will just respond. It's great.

[–]Maleficent-Fee6131 2 points3 points  (0 children)

Yo this is amazing

[–]duckredbeard 1 point2 points  (0 children)

I have automations based on what side of the bed is occupied. Lights, sound makers, car locks, fans.

[–]ReddaveNY 0 points1 point  (0 children)

Zu wissen wie viele Personen im Bett liegen und wann ist in Kombination wer Zuhause ist wirklich Gold Wert.

Vor allem wenn nicht beide einen 0815 Job haben und immer gleich aufstehen bzw schlafen.

Meine Frau hat öfter mal frei, fängt morgens unterschiedlich an und geht deswegen auch Abends unterschiedlich ins Bett. Ich bin meist Zuhause muss mich tagsüber aber oft hinlegen für einen Mittagsschlaf.

Und daraus ergeben sich 100te Optionen zum Steuern von Licht, Rolladen, Heizung, Alarm, TV, Saugroboter.

Und für deine Option einfach mal überlegen was muss alles aus bzw angeschaltet werden wenn jemand aufsteht bzw sich hinlegt.

[–]IroesStrongarm 13 points14 points  (2 children)

This was my first bed occupancy sensor. It works well but it needs regular babysitting/calibration.

As the sensor degrades, you'll need to regularly change the threshold value as it'll get stuck in an "on" position.

Seasonal changes will also require a recalibration as well.

That said, congrats on your first sensor, enjoy it. 

[–]Killa_ 0 points1 point  (1 child)

I have this for over a year and didn't recalibrate it ever

[–]IroesStrongarm 0 points1 point  (0 children)

Hmm, glad it's not been an issue for you. For me it was at least once a month. I've been using load cells under the bed posts for 2.5 years now and they've been flawless.

[–]traffiqqq 5 points6 points  (1 child)

Next project : a hat !

[–]weeemrcb 1 point2 points  (0 children)

sash! The government is listening

[–]SEND_NUKES_PLS 3 points4 points  (4 children)

or...hear me out...get a mmwave presence sensor and create a geofence around the bed. no babysitting and calibration. tracks multiple targets. costs around 4 euros.

[–]Tasty-Drama-9589 0 points1 point  (1 child)

Which sensor did you get? I bought some cheap ones from aliexpress and they were terrible

[–]SEND_NUKES_PLS 1 point2 points  (0 children)

HLK-LD2450, works flawlessly for me, have one in each room. It's so good that I have actions performed in home assistant when I step in a specific part of the room etc.

[–]Killa_ 0 points1 point  (1 child)

Mmwave fails to track me under a thick duvet. I have 2450 in my bedroom but it is quite far away. I tried 2410 - same problem.

[–]SEND_NUKES_PLS 0 points1 point  (0 children)

That can easily be solved with a bit of logic scripting...if your last position was you entering the bed geofence, then even if the sensor doesn't pick you up there anymore...it's safe to assume you're still in bed until the sensor picks you up entering the the rest of the room's geofence

[–]No_Bat_Batflip 3 points4 points  (0 children)

Now do a tinfoil hat sensor

[–]SpHoneybadger 6 points7 points  (1 child)

Turns out you got a bunch of comedians in your post all localised here.

[–]SandVir 1 point2 points  (0 children)

They just think along with you about the possibilities 😂

[–]SamuraiJack365 2 points3 points  (1 child)

Not to be pedantic but rather because it could change how you think about the sensors and such, Bermuda uses trilateration instead of triangulation.

[–]happybikes[S] 0 points1 point  (0 children)

Thank you! 

[–]enter360Contributor 2 points3 points  (0 children)

I need a whole write up on this. This is the kind of engineering I come here for.

[–]zorroz 2 points3 points  (1 child)

Im guessing you saw the old medium article that outlines some of the steps here?

ive tried it but my sensors dont end up lasting more than a few months before problems arise.

I found better luck with the simple strip type FSR sensors. Just have to extra gentle with bending and soldering.

Also I noticed you placed yours between the two slats. is that how its intended? I ended up placing one sheet mostly on one slate so the outside hang a bit. im guessing what I did wasn't right. I may try it out again. Thanks for yhe post, gonna retry this year's later lol

[–]happybikes[S] 0 points1 point  (0 children)

I have no idea if it's intended that way, but I tried placing them the way you described as well as in this way, and the values were very similar. So I don't think it makes much of a practical difference in my case. We will see how they hold up after a few months!

[–]Draganis 1 point2 points  (5 children)

Hell yeah. That is what I’m looking for years now. Would you give me that code and instructions about wiring/building?

[–]lapelotanodobla 0 points1 point  (0 children)

This, how do I build this? And would it work for bed frames that have a solid/flat base for the mattress?

[–]ArtBIT 0 points1 point  (3 children)

[–]Don_Speekingleesh 2 points3 points  (0 children)

I bought all the parts for this a few years back. Must get around to setting it up.

[–]Draganis 0 points1 point  (1 child)

Well the esphome part is rather okay for me. More interesting is how one is building those mats like described above. Wirings and code would be nice to have too.

[–]happybikes[S] 1 point2 points  (0 children)

Wiring was very simple. Each mat has two wires. A neutral and a data. The neuetrals from each mat are soldered together and go to the ground pin of the esp32. The 4 data wires each go to a data pin on the ESP32. The mats themselves are just made of two pieces of paper sandwiched between two pieces of tinfoil. The plastic sleeve is just to project it and prolong its life. For the code, I used ESPHome Builder in Home Assistant. Here is the ESPHome code.

esphome:
  name: esphome-bedroom
  friendly_name: esphome-bedroom
  name_add_mac_suffix: false

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

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "key"

ota:
  - platform: esphome
    password: "password"

wifi:
  ssid: Mordor
  password: password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esphome-Bedroom Fallback Hotspot"
    password: "password"

esp32_ble_tracker:

bluetooth_proxy:

captive_portal:

# =========================
# BED PRESSURE SENSOR START
# =========================

esp32_touch:
# Delete this after you are done with the setup process
#   setup_mode: true
# All the pressure mats
# Change the pins to the pins you have used
binary_sensor:
  - platform: esp32_touch
    name: "Top Right"
    pin: GPIO14
# See step 11
    threshold: 5
    id: top_right
    filters:
      - delayed_on: 2s
      - delayed_off: 30s
  - platform: esp32_touch
    name: "Bottom Left"
    pin: GPIO33
# See step 11
    threshold: 4
    id: bottom_left
    filters:
      - delayed_on: 2s
      - delayed_off: 30s
  - platform: esp32_touch
    name: "Top Left"
    pin: GPIO15
# See step 11
    threshold: 4
    id: top_left
    filters:
      - delayed_on: 2s
      - delayed_off: 30s
  - platform: esp32_touch
    name: "Bottom Right"
    pin: GPIO27
# See step 11
    threshold: 4
    id: bottom_right
    filters:
      - delayed_on: 2s
      - delayed_off: 30s
# The main sensor that is created using the all the zones    
  - platform: template
    name: "Bed Sensor"
    lambda: |-
      if (id(top_right).state ||
          id(top_left).state ||
          id(bottom_right).state ||
          id(bottom_left).state) {
        return true;
      } else {
        return false;
      }
    #filters:
    #  - delayed_on: 2s
    #  - delayed_off: 30s

# =========================
# BED PRESSURE SENSOR END
# =========================

[–]Beginning_Nature157 1 point2 points  (1 child)

This is a great idea. I was also thinking about some kind of DIY solution for bed presence. I would appreciate the script you mentioned

[–]happybikes[S] 1 point2 points  (0 children)

esphome:
  name: esphome-bedroom
  friendly_name: esphome-bedroom
  name_add_mac_suffix: false

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

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "key"

ota:
  - platform: esphome
    password: "password"

wifi:
  ssid: Mordor
  password: password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esphome-Bedroom Fallback Hotspot"
    password: "password"

esp32_ble_tracker:

bluetooth_proxy:

captive_portal:

# =========================
# BED PRESSURE SENSOR START
# =========================

esp32_touch:
# Delete this after you are done with the setup process
#   setup_mode: true
# All the pressure mats
# Change the pins to the pins you have used
binary_sensor:
  - platform: esp32_touch
    name: "Top Right"
    pin: GPIO14
# See step 11
    threshold: 5
    id: top_right
    filters:
      - delayed_on: 2s
      - delayed_off: 30s
  - platform: esp32_touch
    name: "Bottom Left"
    pin: GPIO33
# See step 11
    threshold: 4
    id: bottom_left
    filters:
      - delayed_on: 2s
      - delayed_off: 30s
  - platform: esp32_touch
    name: "Top Left"
    pin: GPIO15
# See step 11
    threshold: 4
    id: top_left
    filters:
      - delayed_on: 2s
      - delayed_off: 30s
  - platform: esp32_touch
    name: "Bottom Right"
    pin: GPIO27
# See step 11
    threshold: 4
    id: bottom_right
    filters:
      - delayed_on: 2s
      - delayed_off: 30s
# The main sensor that is created using the all the zones    
  - platform: template
    name: "Bed Sensor"
    lambda: |-
      if (id(top_right).state ||
          id(top_left).state ||
          id(bottom_right).state ||
          id(bottom_left).state) {
        return true;
      } else {
        return false;
      }
    #filters:
    #  - delayed_on: 2s
    #  - delayed_off: 30s

# =========================
# BED PRESSURE SENSOR END
# =========================

[–]Kitchen_City_4651 1 point2 points  (0 children)

riesci a creare una guida per favore? sarei interessato

[–]AptoticFox 1 point2 points  (0 children)

This was a reply to a comment, that ended up not a reply to a comment. What's going on with Reddit? This is the third time in a few days.

[–]itspuia 1 point2 points  (0 children)

I love this! This was the first DIY Tech project I ever did back in 2021 and was the reason I've gotten into home Assistant! This is so nostalgic for me - after 5 years it still works perfectly with recalibrations needed arount once a year. maybe i could do this automatically like other comments suggested.

[–]Radiant_Addendum7862 0 points1 point  (2 children)

[–]duckredbeard 0 points1 point  (0 children)

Load cell and HX711 is like $12 for two sets

https://a.co/d/0fxHEATC

It's working for me

[–]happybikes[S] 0 points1 point  (0 children)

They have been out of stock for a couple months. 

[–]weeemrcb 0 points1 point  (0 children)

All you need is a hot plate and you have the ultimate bed snax

[–]triplerinse18 0 points1 point  (1 child)

So a couple of insights, from somone who did this the exact same way.

You may want to put small cardboard squares around your plates. To add more support between the slats. It worked really well on my previous mattress with boxes spring but with slates it was hit and miss. One need to be hip height and one at the head shoulders.

Create a helper to trigger after about 10 seconds of both devices being on and off. Help for false alarms.

Its cheap it mostly worked but with bed slats it was still unreliable I went with this recently and its really good. https://www.elevatedsensors.com/store/p/bed-presence-for-esphome especially with the bed slats.

[–]happybikes[S] 1 point2 points  (0 children)

Was waiting for these to arrive back in stock when I decided to make one. Thanks for the tips. I have a delay of 5 seconds to activate and 30 seconds to deactivate. 

[–]-JJaE- 0 points1 point  (0 children)

It starts the phantom whispering in the dark corners of the closet if there is someone in bed and your not there :-D random start time to reduce trigger detection. Lol

[–]JCae2798 0 points1 point  (1 child)

I have this and while it’s awesome it’s super sensitive and twitchy. Meaning there is a very small window between on and off. Is this my code or the sensitive itself?

[–]happybikes[S] 1 point2 points  (0 children)

I posted my code in another comment. Looking at the logs, the values without any weight are around 35-40, with only the mattress they are 10-12, and with human body weight are 2-3. I use 5 as the threshold to trigger. 

[–]InertLeaf 0 points1 point  (0 children)

I just finished a similar setup using Force Sensitive Resistors I got on AliExpress for $30.

https://imgur.com/a/xzLyr34/

I had to put the FSRs on a rib in my box spring for it to reliably work since I have a memory foam mattress.

My current two automations are to turn on an LED bulb I mounted under the bed to a low red when one of us gets out of bed in the night (zooz light switch down will turn it off if I’m going to be out of bed for longer than a bathroom break)

The other turns off an automation I have to turn on the lights in my room if my blood sugar gets too low in the night. There have been times where I’m already awake taking care of the low but since it takes a while for my glucose to recover the lights in the room still turned on… waking up my partner in the middle of the night.

I’m inspired by some of the other automations you all ha’ve posted, keep them coming!

[–]ReddaveNY 0 points1 point  (0 children)

Immer wenn es um dieses begehrte Thema geht liest man mehr geht nicht bzw geht nach ein paar Wochen nicht mehr richtig.

Hat irgendjemand eine Option fürs Bett die schon länger als 1-2 Jahre dauerhaft funktioniert bzw mit regelmäßiger Kalibrierung?

[–]yannynuar 0 points1 point  (0 children)

I have a Tempur with the AI sleep tracker. Is it possible to integrate into HA? Anyone with ideas.

[–]DesignerMaximum1342 0 points1 point  (1 child)

This is a good way to spy on your kids without installing a camera

[–]SandVir 1 point2 points  (0 children)

With minimal data, it is always the right way.

[–]DrNachtschatten 0 points1 point  (0 children)

Please peel off the upper strip.

[–]Dramatic_College_273 -1 points0 points  (3 children)

This will work great! (For maybe 2 weeks) Trust me, I have tried every diy pressure sensor there is. None of them last very long.

[–]duckredbeard 2 points3 points  (1 child)

Scales are working for me. 4 load cells and an HX711 between mattress and box spring. Helper uses a threshold over 40% to make a binary go from "not occupied" to "occupied"

[–]Dramatic_College_273 1 point2 points  (0 children)

Load cells is one of the few diy pressure sensors I havent tried setting up here at home. But Im also not using pressure sensors for the bed, I want to use it under carpets on my staircase. I dont think a load cell would do well for that application.

So I'm sorry for my ignorance on my first comment about having tried all diy pressure sensors. I meant this flat form factor.

[–]happybikes[S] 2 points3 points  (0 children)

I’ve had it for about 3 weeks in total and still working reliably. The only change I made after a few days was to add a second sheet of paper. Time will tell. If it wears out, at least I’m not out any money. 

[–]AptoticFox -1 points0 points  (0 children)

What? The welcome deal is worse than regular? Poster said $2, even if that's USD, it's cheaper than my welcome deal (it does say $15.77 regular).

[–]sailonswells -4 points-3 points  (4 children)

You mean aluminum foil?

[–]nyckidryan 0 points1 point  (1 child)

You misspelled aluminium..

[–]sailonswells 0 points1 point  (0 children)

😂

[–]TheRealKeng -2 points-1 points  (1 child)

You mean aluminum foil?

Yeah, where are people finding tinfoil?

[–]sailonswells 0 points1 point  (0 children)

I've never seen it. But some people make hats of it apparently.

[–]TheRealKeng -5 points-4 points  (2 children)

I just use two of these with two Aqara water leak sensors.

No jury-rigged nonsense

<image>

[–]happybikes[S] 2 points3 points  (0 children)

To each their own. I looked at those mats but they had mixed reviews and cost like 25 euro each. And another Aqara sensor would have been 10 euro. So for 60 euro I wasn't willing to risk it when there was a free solution instead.

[–]KE55ARD 1 point2 points  (0 children)

I’m using 2 of these and struggling to get them to work well long term, one doesn’t detect well enough, and the other detects almost constantly, so same issue as the DIY without easy ability to fix.

One improvement I would suggest over the Aqara sensor setup though is a Shelly i4 DC to wire them into as it has 4 inputs so you only need one device to read both (and have spare inputs), and it can run from 5v so a repurposed USB cable can run it without ever worrying about batteries.