[Release] HubDuino Bed Occupancy/Presence Sensors

@ogiewon I just received my components today and agree with this statement. How does this connect? Do I put pins into the crimp into the sleeve looking thing, under it? It almost looks like the FSR plastic slides in but not sure how.

I had to clip off the FSR’s “pins” a bit, so the connector can clamp on to the FSR plastic with the flat contacts of the FSR making contact with the connector’s contacts.

It isn’t a perfect solution. :wink:

1 Like

Better than me trying to figure out how to jam those pins through the holes. Thanks for the tip, fingers crossed mine work :grin:

@ogiewon I have this project setup and I am having mixed results. It detects me getting out of bed marking me as not present but then immediately changes to present. I changed the resistor from 10k to 15k yesterday hoping this would fix it. We do have a heavy and tall TemperPedic mattress. Should I keep increasing the resistance? I bought this 1280piece / 64 value resistor kit so have plenty of other options.

Great question. I think this is a situation where you’re going to have to experiment to see what works for your specific case.

Things to try

  • adjust resistor value, higher values will require more force on the FSR. There is a limit, though.
  • adjust sensor placement
  • consider augmenting the sensor with some sort of mattress supports along the length of the strips. I am just thinking off the top of my head... perhaps a thin cardboard strip along each side to ensure when the bed is unoccupied, the weight of the mattress is minimized on the FSR. Just an idea...:thinking:
2 Likes

I considered diving in to do this but after reading through all the posts I decided a better option for me was to write a rule based on typical patterns of movement we always do before getting into bed. Here is the logic I am considering...

First if there is any motion in the house other than bedroom, closet, and bathroom then someone is not ready for bed - set a flag to false.

Once that all stops for some period of time after sunset then set the flag that bed is possible to true.

In parallel if bed possible flag is set, check for patterns we do before bed which is bathroom sink motion, bedroom motion, then lights off.

I ignore motion in bedroom after that since it could be tossing and turning, but bathroom motion or lights trigger someone out of bed so it resets everything.

Do you folks think this would work reasonably well?

@ogiewon could you please explain your library’s numReqCounts parameter? I see it used with many types of sensors with varying values and see the bed sensor is 5000. Does the Arduino “sleep” for this duration? I had implemented delays in older versions of my alarm project and they are bad as the loop stops. This value cannot be milliseconds looking at my event history so curious what this parameter is.

I am asking because I am still getting false (flapping as they say in the IT event monitoring space) events where I am not present and immediately present again. Curious if changing this value will help.

If not I can program something on the HE side to deal with it.

That numCounts parameter is how many times, through the Arduino loop() function, has to occur before the sensor will change states. It is essentially used to debounce the circuit/prevent false status changes. So, increasing this value will help prevent false events. However, the larger the value used, the longer the time before a true new value will be sent to the hub.

Feel free to adjust the numCounts value and experiment. Try 10,000, 20,000, etc... to see the impact on both preventing false events and the delay on sending a truly valid change. Try to find a balance that suits your needs.

Got it thank you! I had started this project many weeks back but put it on hold given other priorities and holiday preparations. Now that things have settled and I am off work, time to dial this back in. I will post back with pictures of my setup and settings in case others may benefit.

@ogiewon thank you for all you do for the community. Happy New Year!

2 Likes

Finally got a stable setup and enjoying this. The numReqCounts parameter didn’t ever work well for me as I increased it to a very high number and I still had several not present/present events some evenings. What I ended up doing was modifying the child presence driver to prevent these flapping events. I added a delay preference that is utilized by a short runIn() delay. Currently mine is set to 5 seconds and it works very well as I don’t need automations to fire immediately since reliability is more important. Happy to share those driver tweaks if anyone is interested.

Here are a few pictures of my setup. As mentioned above I have a tall and heavy Temperpedic mattress so the cardboard strips help with FSR sensitivity. I also found the FSR works better upside down.

Here is what my ESP8266:

@ogiewon thank you again for posting this solution!

2 Likes

This is definitely some good information! Thank you for sharing it. Hopefully I'll find some free time soon to get back to dialing this in the way you have. I really like the simplicity of the two cardboard strips to help alleviate the pressure on the strip when the bed is unoccupied. Are your strips running from head to foot under the mattress, or side to side?

Side to side at a slight angle. I put them at center of body since that is where most weight is and that is also where you pivot to get in bed.

1 Like

For those interested, this is my rule. My wife and I have bedside Picos that allow us to change modes, turn on lights, etc so you will see my rule even virtually press one of my Pico buttons

@ogiewon I will PM you my customized Child Presence Sensor driver in case you are interested in my changes.

1 Like

My wife just told me that the bed sensor is one of her favorite automations I have done in recent months. She likes that the house shuts down and wakes up with her. Huge WAF.

Now if HE could just read her mind :thinking:

3 Likes

I'd be interested in seeing the tweaks you made to the code. I'm just getting mine setup and ready for testing. Thanks.

@ogiewon actually included my updates in his latest Child Presence Sensor driver. What you need to do is set the "Number of seconds to wait to verify presence" preference. Mine has been set to 5 seconds for a long time and works well. Obviously this will delay your rules from firing but better that than false situations.

2 Likes

Thanks for posting this project! I just completed my sensors and automations. Luckily I went with 20k potentiometers instead of 10k resistors, when I soldered it all together I preset each potentiometer to 10k but when I put it all in place (with a strip of 1/4" melamine under each strip since the frame under the mattress has ridges) I had to turn up the resistors just to get it to read not present with no one in bed, our mattress is really thick and heavy. I ended up turning them fully to 20k in order to keep my wife's sensor from showing present when I was in bed alone. I also put 10 in the "Number of seconds to wait to verify presence" field to stop it from flapping between present and not, although I may drop that to 5 seconds tomorrow to see if that's enough.

1 Like

I ended up having to put a few strips of .5" plywood (like the cardboard above) about 16" on either side of my wife's sensor otherwise it wouldn't change to not present when she got up in the morning, unless I lifted the mattress but then within 20 minutes it went back to present, mine works fine without though. So far it is working well since I did that.

I can see why they don't make a bed presence sensor like this for sale as the sensor strips are so thin and fragile feeling and getting them setup appropriately will be different for each mattress, but I think this is going to be my favorite sensor yet. I've been able to automate a lot of things that had been time based previously to occur only when we go to bed or wake up now like our bedroom shades opening 5 minutes after we get up (so they don't open in the middle of the night if we both get up at the same time to go to the bathroom) rather than at a certain time on weekdays and another on weekends. Since we don't always get up at the same time it's nice to not have the sun suddenly hitting our faces at a certain time in the morning. I still have them opening on time when the mode is away though so it still looks like we're home.

It also arms to night mode, turns off all the lights, verifies the doors are locked and the garage door is closed, and others when we go to bed and it triggers Alexa to tell the forecast in the morning using a virtual motion device and Alexa routine. I also had to take into consideration that we are sleeping when we're both in bed and both home or when one of us is bed if the other is not present (traveling, not that that's happening with Covid but maybe next year).

1 Like

Glad to hear you're finding this a useful sensor device for your home automation. Perhaps I should look back into getting this working in my own home again? :thinking: I stopped using it soon after I created it as we got a new split-king bed with individually adjustable platforms. But, you've rekindled my interest with your explanation of various use-cases. Thank you for sharing these ideas!

1 Like