Building a Bed Occupancy sensor for Home Assistant (yet more load cell guides!)

Hey guys!

Thought I’d share my bed occupancy sensor (yes I know, more bed occupancy sensors based on load cells!) and hopefully make it easy for anyone else that wants to replicate.

Using those cheap 50kg load cells under each corner of the bed, a HX711 board, Wemos D1 Mini and of course Home Assistant!

One thing I found hard to find information on was how to mount the sensors. I tried a few things but ended up 3D printing casters/holders for my bed legs and allowing the load cells to slot into them, this stops the bed sliding around on the cells and interfering with the reading. This method keeps everything secure and ensures each cell is in the exact same position.

Couple of pictures:

So what do I use this for?

This has greatly improved my automations:

  • Ensuring that when we are both in bed, every light and media player is turned off, door locks are set and the house alarm is set to “armed home”.
  • I have lights that are automated through Home Assistant when motion is detected, I add a condition to these automations not to trigger these lights when we are both in bed, this is so that our dogs do not trigger lights all night.
  • During night hours, the bathroom light comes on at a very dim brightness if one of us exits the bed during the night. This is great for not being blinded when getting up to the bathroom during the night!

I’ve created a full guide here

Github code:

Any issues, let me know!

11 Likes

I have ordered the hardware from Aliexpress yesterday. Pretty excited to implement your setup once the stuff arrives in a few weeks.
Thanks.

Please let me know how you get on, I’m interested to know! Let me know how the guide is too and if anything needs updating!

This project is awesome. I am trying to do the same with minor modification. In my case I don’t need accurate measurement and all I want to check if there is any additional weight on the bed or not. I am having trouble mounting the load cell because of my special bed legs. However I would only need one cell. My bed has a middle leg in the centre. Do you know how to make the wiring to HX711 if I only need one or maximum two load cells?

Sorry for the late reply, I replied to your comment on the website. Let me know if you need any more help!

The tutorial helps me a lot, especially the troubleshooting section, thank you so much! The sensors are working fine now, but I have never worked with MQTT before. When it comes to setting this up, do I just need to use this integration? https://www.home-assistant.io/docs/mqtt/broker/ And do you know a way to run the ESP8266 on battery without having to re-charge it every couple of days?

Hey,

I wrote a guide for you here: https://everythingsmarthome.co.uk/howto/how-to-install-an-mqtt-broker-mosquitto-install-config-on-debian-ubuntu-mint-fedora-raspbian/

Hope that helps.

Running an ESP8266 can be a difficult task that depends on many factors, what sensors do you plan to use, how often do you need the ESP8266 to report, how big a battery, etc etc?

1 Like

This is great, thank you so much! The installation seems pretty straight forward, I will definitely try it out.

I’m using the same sensors as in your tutorial, with a different amplifier and a board from aliexpress that’s called something like “Micro ATmega32U4 Leonardo replacement”. It’s working fine with your calibration code, but I’ll have to switch to a wireless solution w/ battery, because there’s no outlet next to the bed.

I’m sorry I do not know the answer to that, you would need to measure the power draw of the setup and do some calculations to see what kind of runtime you would get. You can also implement deep sleep on Arduino boards which saves a lot of power. Choosing a board without USB headers can save a lot of power along with removing any onboard LEDS.

I’ve made a battery door sensor before on battery power, it lasted a long time after doing the above, but that is a totally different sensor, I don’t think you will get a long time out of a battery but you will know more after doing the calculations. I used this link here which had a lot of good information:

Sorry I do not have more information!

Question for you, how can 4x50KG sensors be enough?
Surely the bed, you and your partner weight over that.

We are often 4 in my bed, and the bed weight quite a lot, should I use more sensors?

If you need the exact weight measurement then yes.

I have made mine so that there is support under the load cell part that bends. So that it can’t bend too much to break. I use it only to detect on/off the bed. Not so interested of the actual weight.

1 Like

Just received my 40 ( forty ) sensors in order to build this.
Anyone knows how to wire them in order to sum their values?

Thanks!

Hi all

This is probably a stupid question, however I’ve seen Lewis’ YouTube guide on this, read the article and now ended up here when googling for inspiration!

I’ve printed the same sensor holders as shown in the 1st and 2nd images above. But if the bed leg is larger than the printed top (as is the case by seeing the larger “leg holder” printed cases), then how does the bed leg apply pressure to the flappy part of the case, when it will also be touching the 4 edges of the top case too?

Sorry if that’s not a very clear question… I’d be interested to see how people have attached the sensor cases to the bed legs is I guess what I’m asking…!

Thank you

Hi

I was about to go ahead with this project, but I noticed our bed has 12 (!) legs !
Is it possible to have 12 load cells connected to the HX711 ?
If so, how do I join the wiring … in groups of 3 ? Does it matter if you join the outer legs / corners etc ?

You should look into this instead…

Yes, I saw that too.
But there was a youtube video from a smart home builder, and he prefered the load cells.

The FSR … it would be less fuss to be honest

The load cells are more reliable (at least in my experience) but obviously a bit more work.

To answer the question, you don’t need to cover all legs necessarily, you could make “blanks” for the other 8 legs so the weight is distributed evenly - haven’t tried it but should work

I’ve found the complete opposite.

:sweat_smile:

Well, anyway, I found this guy who has diagrams for 4 / 2 and even 1 leg(s)/load cells.
If you don’t need an exact weight measurement and just a simple presence detection, this more then enough I think. I think I’m just going to take the 2 center legs of each side of the bed and see how this goes.

Btw, I also read that some HX711 amplifiers don’t have ground on pin E- , maybe that’s the cause of inaccurate readings:

https://community.home-assistant.io/t/bed-scale-occupancy-sensor/114205/21