Bed Occupancy Sensor

Found some great inspiration here. Thank you all for sharing this awsome project.
Just made a couple of those sensors last weekend, and it works absolutely fantastic. I’ve used the information from @diplix “messlatte” for the hardware configuration, as I use a two loadcell setup with EasyESP combined with the information I’ve found here: https://selfhostedhome.com/diy-bed-presence-detection-home-assistant/. I’ve put the load cells between the slatted frame and the bed using a 3d printed load cell holder for an easy installation.
The HX711 seems not to work reliably when connected to 3.3V on my NodeMCU V3. Connecting it to 5V fixed all issues in combination with “ESPEasy_mega-20180914 and ESP_Easy_mega-20180914_test_ESP8266_4096.bin”
Right now I use this in my bed for presence detection and in the chaiselongues in my living room to turn on the reading light. Going to integrate it into my tv couch as well to automatically pause the movie and control the light when I get up to grab some snacks or drinks. :wink:
@diplix Have you managed to write a rule that only transmits significant changes?

UPDATE: Using static IPs for my ESP8266 Sensors (ESPeasy) helped to get rid of some occasional freezes.

1 Like

no rule on the esp, it just fires values every 2 seconds. to not spam my home assistant history, i divide the value down and round it, so that it doesn’t change the sensor when idle.

  - platform: mqtt
    state_topic: "kinderzimmer/weight/Weight"
    name: "bett gewicht"
    value_template: "{{ (value | float /1000) | round(0) }}"
    qos: 0
    unit_of_measurement: "kg"
    #force_update: true
    availability_topic: "kinderzimmer/status/LWT"
    payload_available: "Connected"
    payload_not_available: "Connection Lost"

so even if the esp constantly fires values between 1500 and 2500 the sensor remains idle/stale and stays at 2 kg.

Ok, thanks. That’s what I am doing right now. I guess I should stop worring about the poor ESP8266 sending unused messages most of the time :grin:

As the weigth difference between my wife and myself seems not big enough to have a reliable sensor to messure who’s sleeping, I just tried to connect a second HX711 + 2 load cells to my NodeMCU to measure both sides of the bed independent of each other. But it seems that unfortunatly two instances of the HX711 sensor are not support (at the moment) by ESPEasy. Should have tested it before soldering another one, but I guess the dog bed will get a sensor now :smirk:

Hi @jordan.schulze did u have any errors with the code? I have uploaded it but cannot connect to Wi-Fi throws some random error.

Hi @diplix how did you configure your mqtt in espeasy? There is no option of homeassistant mqtt? So how can I set it up?

I am getting negative values I have followed your method and configuration.

My mqtt topics do not give any result either. Please help.

Above all that my espeasy setup is from letscontrolit.com. is that fine? I followed your guide.

Many thanks

see

do you mind sharing your mqtt settings please? a screenshot maybe?

I looked into that topic but didnt find much help.

thanks.

thank you @diplix

now what are your mqtt topics in home assistant that you subscribe to for getting the weight values?

scroll up a little or/and see

is that what you mean? bett/weight/Weight?

but what is the following?

/%sysname%/%tskname%/%valname%

where can i find mine?

UPDATE: ok found it !

@diplix can you please help me on calibration?

how can I achieve it? using your formula? thanks

i don’t know what you mean. if you get values compare them and automate accordingly; compare the value you get for an empty bed with the value you get if the bed is occupied.

Can you explain the logic behind your formula?

The values keep changing so there isn’t a constant value

in case your refering to this formula in esp-easy: ((%value%+135750)*-1)/20

this formula is supposed to set the value sent by espeasy to approx. zero. before i mounted the sensor into the bed, i measured a 1 kg pack of flour, noted the change and came up with this formula. if i remember correctly espeasy reported a value of around -135750 without any weight applied and a value around −155749 with a kilo flour on the sensor. with the formula i get (around) 0 for no weight and (around) 1000 with a kilo applied.

(((−135750)+135750)×−1)/20 → ~ 0
(((−155749)+135750)×−1)/20 → ~ 1000

the values reported by espeasy change a lot, so i round the value in homeassistant to full kilograms, so that only changes greater than 1000 change the homeassistant sensor value.

value_template: "{{ (value | float /1000) | round(0) }}"
1 Like

Was your value of -135750 fixed or did it go up and down? Because mine is going up and down like anything

like i said, it changes all the time but not more than ±1000 in a state of rest. without looking it up, i guess it’s more or less around a range of 300. what’s your range of change?

@diplix Well the first 3 digits don’t change just the last 3 digits do. So they vary from -294380 to -294424

ok I have sorted it many thanks for your help.