FSR - the best bed occupancy sensor

Nice thanks for sharing, will give it a try parts are ordered🤗

1 Like

he sorry for bothering you, but could you please elaborate on your wiring, do you have a picture so its easier to rebuild =)

you dont leave bed at night i assume? :slight_smile:

whats the power supply you use here? if battery, possiblilty to report battery level would almost be a ‘must’ (i hate things dying from battery outage)

Yes occasionally why?

USB 5V 1A supplied from a wall outlet. Battery power is no good for this project.

morning announcements for 2am peeing is not what i would like :slight_smile:

I have conditions for that. Only after 6am.

15 Likes

So unlike the other techniques, where several sensors are connected in a Wheatstone bridge configuration, this works equally well with with just one FSR? Or did I misunderstand and there’s more than one used to detect separate occupants?

BTW, great guide!

Correct. Just the one sensor. I sleep on one side of the bed. If you want to detect two sides of a double or larger bed you will need two sensors.

1 Like

If I wanted to detect the presence of left/right occupants would two FSRs be required for accurate detection or would one centrally located FSR be sufficient?

It’s a king-size mattress (width: 76"/1.9m) so I figure two FSRs might be preferable?

Duh, you already answered while I was typing (and measuring the mattress) …

1 Like

Yeah definitely two for that.

Also position the FSR(s) on the slat that is under the heaviest part of your body. In my case that’s my posterior.

2 Likes

Results from a lighter person on a heavier and thicker mattress:

Not as wide a range as my other sensor and there is a little variability when unoccupied, but still very clear states.

1 Like

Here is my configuration for a single ESP32 with two FSR sensors for detecting both sides of the bed.


binary_sensor:
  - platform: template
    name: "Guest Bed Left Occupancy"
    device_class: occupancy
    id: gb_l
    lambda: |-
      if (id(guest_bed_left_sensor).state < id(guest_bed_left_trigger_level).state) {
        return true;
      } else {
        return false;
      }

  - platform: template
    name: "Guest Bed Right Occupancy"
    device_class: occupancy
    id: gb_r
    lambda: |-
      if (id(guest_bed_right_sensor).state < id(guest_bed_right_trigger_level).state) {
        return true;
      } else {
        return false;
      }

sensor:

  - platform: adc
    pin: GPIO34
    attenuation: 11db
    name: "Guest Bed Left Sensor"
    id: "guest_bed_left_sensor"
    icon: mdi:bed
    update_interval: 0.5s
    filters:
      - sliding_window_moving_average:
          window_size: 10
          send_every: 1
      - or:
          - throttle: 180s
          - delta: 0.02

  - platform: adc
    pin: GPIO35
    attenuation: 11db
    name: "Guest Bed Right Sensor"
    id: "guest_bed_right_sensor"
    icon: mdi:bed
    update_interval: 0.5s
    filters:
      - sliding_window_moving_average:
          window_size: 10
          send_every: 1
      - or:
          - throttle: 180s
          - delta: 0.02

  - platform: homeassistant
    name: "Guest Bed Left Trigger Level"
    id: "guest_bed_left_trigger_level"
    entity_id: input_number.guest_bed_left_trigger_level
  - platform: homeassistant
    name: "Guest Bed Right Trigger Level"
    id: "guest_bed_right_trigger_level"
    entity_id: input_number.guest_bed_right_trigger_level
10 Likes

This is such a cool project that I’m definitely wanting to build! Question, though, if the strips are under each side of the bed, what happens if you roll off of the strip? Let’s say on a queen or king mattress, you roll over and end up in the center of the bed, does the strip think you are no longer occupying it? The obvious thing would be to add a third strip to the center, but just curious - especially when my wife travels for a week or two for work and I have free reign to monopolize the entire bed :slight_smile: .

I also wonder if a foam mattress would be less effective.

The strips are 600mm long, if you think you will need three then use three.

Hi Tom,
So this is hooked up to the ESP8266 ? Do you place it in a housing? And how is that powered ? I see 3.3V so do you use a usb cable or ?

Would love to see it in full with pictures.

Very interested in this.

ESP32. Powered from a 240V wall plate that also has 5V USB outlets. I used to just use a 5V 1A plug pack.

Pictures wont be much use to you. The ESP is mounted in a vented enclosure that also houses a temperature and humidity sensor and an RGB push button. Also it is a dog breakfast inside as I have been through a number of iterations of this circuit. I’ll clean it up… one day.

Light goes dim red when the bed sensor is active. The button controls my bedside lamp smart bulb.

6 Likes

Nice thanks!

Hey mate, hope you’re well :slight_smile:

How are you stopping the alarm? Alexa Media Player?

With an automation triggered by the bed sensor state.