FSR - the best bed occupancy sensor

Use a 100K Ohm resistor.

1 Like

One of my sensors has big voltage oscillation range of 0.4V another one I made was just around 0.1V. Despite following the formula and run the sensor with 5V I am getting 2.1 to 2.5V empty and 1.2 - 2V occupied. If I set the threshold at 2 it will work especially if added with a delay. However I am trying to add some automation with brisk detection for empty bed so the delay doesn’t really work well in this. What would you suggest? Should I try changing the resistor if so higher or lower or add a capacitor to stabilize the voltage oscillation?

How long are the cables from the FSR to the ESP?

What sort of cable?

What resistance (not voltage) do you get in and out of bed?

What resistor are you using?

Thanks for this! Quick question about measuring R1. I measured on the strip with it not connected to the ESP32, and I get 2.1M Ohms, but it will slowly get less and less resistance as I measure (no pressure on the strip). So do I use the 2.1 as the value or the end value after a set time? Or do I measure when 3.3v is applied?

You measure the FSR resistance with nothing attached, wait for it to settle.

3 Likes

I’ve just found a reason for using input_numbers in home assistant instead.

ESPHome number components do not restore their state on restart of the esphome device. :angry:

I’ll be changing back to using input numbers.

1 Like

I’ve wondered why I was having to reset the state. Are you going to update post 1? I’m good at copy/paste!
Thanks

Yeah, I just reverted the first post to the previous edit.

2 Likes
  • restore_value (Optional, boolean): Saves and loads the state to RTC/Flash. Cannot be used with lambda. Defaults to false.
3 Likes

Why isn’t that on the Number component page?

That’s where I looked for that exact setting. Either way I’m leaving it as an input number now.

1 Like

By the looks of it only the template number supports restore_value and all other number platforms don’t (at this point). Probably that’s the reason why the documentation is found directly in the Template Number docs and not in Number component docs (because it’s not “universal” for that component). :bulb:

1 Like

I want to build it today, but I didnt understand how to connect the wires to esp32, I have resistors
I just need pic or something to show me how to wire
thank you

Could anyone help me in setting up a second strip for my partners side of the bed?

We have a superking bed and the bed sensor is working fantastic but what it’s highlighted is that I sleep on the same place and she moves around lol. It’s perfect when she’s on the right spot but not so good when she moves.

My plan is to add a third FSR but ideally I would create 2 ADC sensors and name then XXX1 and XXX2 but I would only want them to change the binary sensor if one or the other is lower than the threshold.

So basically

  • platform: template
    name: “XXX Bed Occupied”
    id: “XXX_bed_occupied”
    lambda: |-
    if (id(XXX1_bed_sensor).state < id(XXX_trigger_level).state) {

OR XXX2 < Trigger State

return true;
} else {
return false;
}

I know how to setup the 2 sensors but I’m struggling with coding the OR. Ideally I’ll end up with a single binary sensor that can be switched by 2 FSR’s

Thank you all :slight_smile:

Does somebody has a link on Aliexpress for buying these resistors ?

Thanks !

I got these, £30 pair @ 60cm

No, I mean the resistors (R1)

Buy them locally.
You can probably find a box full of all values fairly cheap.

We don’t have such a store nearby…

Anyway, I already have to order stuff at Aliexpress so.

A box with different values would indeed be great, but I’m a novice so I really don’t know what I should order…and that’s why I asked.

For a start these assorted kits are always useful.

Like some resistors:

https://www.aliexpress.com/item/32505894332.html

Some capacitors:

https://www.aliexpress.com/item/32954751214.html

Some diodes:

https://www.aliexpress.com/item/4000986877208.html

2 Likes