FSR - the best bed occupancy sensor

Any way to get the icon to change depending on the state?

Sure, add a device class: Binary Sensor - Home Assistant

thanks for the quick reply. This is what I had and it always stays the same.

binary_sensor:
# Bed Sensor - Occupancy
  - platform: template
    name: Bed Occupied Side 1
    id: bed_sensor_o
    icon: mdi:bed
    device_class: occupancy
    lambda: |-
      if (id(bed_sensor1).state > 1.19) {
        return true;
      } else {
        return false;
      }

Remove this:

icon: mdi:bed

That’s a step in the right direction. Now I get a house that fills in and outlines as the state changes. I tried to set the icon in the UI to bed but then it wouldn’t change.

What you want to do is not possible using HA core functionality. You can vote here for the feature to be added:

You can probably work around this (in the dashboard only) with this:

Thanks for the info. I would have kept beating my head over it.

1 Like

I’m running two FSR strips and two RGB led strings on one esp32. Does it no problem.

Thanks @tom_l for the detailed explanation on this! I just setup an esp32 with two sensors for each side of the bed. It was my first esphome project and it was done in only a few hours. I got lucky with the sensors, about 4k resistance when in bed and more than 20M (max for my multimeter) when out of bed, so I got away with a 100k resistor for each side of the bed and it has been working perfectly.

Was using the Withings Sleep Analyzer before, but this was going through a webhook and it had to calibrate every time the power went off. This solution is way faster, no Internet needed and way more reliable.

1 Like

@tom_l

I’ve tried to build this sensor, without much success on the outcome. I have a foam mattress so I even used the plywood trick under the sensor. In doing so I managed to calculate resistor values of 4.4K for me and 3.2K for my wife. Trouble is, I am never seeing things trigger. Even worse is that the range and values seem to be all over the map. Here’s images of mine (left) and my wifes (right). There’s no discernable difference on mine and my wifes looks a bit off. Should I attempt a different resistor value? Perhaps the 100K that was suggested above?Edit only allowed to post a single media item, so I’ll go with my wifes.

Any suggestions?

this is a great thread but i sometimes i wonder if you really need to reinvent the wheel …
all your really looking for is an OFF & ON yes someone’s in bed or not

what i used was a Universal Car Seat Pressure Sensor which will give you just an on and off … works like a dream and has done for almost two years
to play it safe and make for a larger read area on each side of the bed i brought four sensors and link two as one and placed each pair on its own side of the bed

captive_portal:
binary_sensor:
  - platform: gpio
    id: person_one_bed
    name: "Person One"
    pin:
      number: GPIO5
      mode: INPUT_PULLUP
    filters:
      - invert:
      - delayed_on: 2s
  - platform: gpio
    id: person_two_bed
    name: "Person Two"
    pin:
      number: GPIO4
      mode: INPUT_PULLUP
    filters:
      - invert:
      - delayed_on: 2s
1 Like

Here’s my sensor output

Your sensors are 17cm wide compared to the 60cm sensors used in this project, but if it works for you go for it.

What was the measured in and out of bed resistance?

Are your FSRs resting on a hard surface?

They do need to.

not really sure that works for me ?

your using a long length ‘yes’ but which is NOT very wind at all so your area of coverage isn’t a lot

where I’ve chained two sensor pad as one covering a lot larger area

at the end of the day it works and that’s all that matters

It works for everyone here. You don’t need to measure down the bed, just across it. And this covers a lot more.

Hi, I was playing around and did manage to get it working without using any resistors!
I am reading the value of A0, when not in bed, it reads around 7-10, when in bed, 1024.
I am curious, what is the use of R1?
Using ESP8266 (nodemcu v2)

image

The nodemcu has an on board voltage divider. The ESP ADC has a 0-1v input range. This voltage divider allows 0-3.3v input to the board.

You are placing the FSR variable resistor in series with one of these resistors.

Sounds like you have quite a wide resistance range from in to out of bed compared to the values of the on-board resistors, so this will work but if that were not the case you would see a poor voltage response. Additionally some boards do not have this voltage divider. In which case you would just be pulling the ADC input high and you would see no input variation.

Untitled

Brief question regarding the calculation of R1: Unoccupied, my FSR has a very high resistance - too high for my multimeter to measure it. Occupied it’s more like 3 kΩ to 10 kΩ.

Assuming 100 MΩ (for infinity), the equation yields around 500 kΩ for R1:

R1 = sqrt(3000*100000000) = 547722

Does that make sense?

What is the maximum your meter can read?

In bed it’s probably MegOhms.