FSR - the best bed occupancy sensor

Changing my ESP devices to use numbers instead of Home Assistant input numbers and buttons instead of switches that turn themselves off after a delay is on my 3 page list of things to do.

EDIT: ok that’s one thing off my list. First post updated to use ESP template number.

1 Like

I know the feeling…

Thanks — and happy cake day!

1 Like

That was an easy one to change. The switches to buttons change… not so much. So many services to change.

I had the same problem with my mattress which is a memory foam type. I believe the problem is that the weigh distribution of the mattress is fairly even across the entire bed frame so it doesn’t particularly distribute weight to the sensor.

I solve it by raising the force sensor off the slats. I use a piece of wood, about 0.5 inch high, 1 inch in width and 60 cm or more to have the entire strip on. This basically allows more pressure to be exerted on the strip and thereby dropping the resistance of the sensor to measurable range. Even with this trick, the resistance is still fairly high so the voltage chagne between occupy and empty is about 1V but accurate enough for me.

1 Like

Can the ESP32 be powered by USB power? I have hooked everything up and voltage never drops when sensor is pressed. I have confirmed my sensor is working and not damaged.

Yes, assuming you don’t have this board: Something is very wrong with the WiFi on the ESP32 boards I ordered from AliExpress. Is there any way to salvage these and fix the WiFi? - #5 by LoreNG

1 Like

I don’t think I have the board you mention. This is what I got off amazon. https://www.amazon.com/dp/B0CNYK7WT2?psc=1&ref=ppx_yo2ov_dt_b_product_details. If I wire the power straight to the FSR sensor and plug the other end into the GPIO pin to read the voltage I can get voltage to increase.

Don’t do that. You want it powered from 3.3V.

What do the device serial logs tell you in ESPHome?

I got it to work. Looks like I hooked it up wrong.

1 Like

The 0.L signal indicates the resistance is greater than your meter can read (overload), likely greater than >20 megaohms. I installed a 1 megaohm resistor in parallel with my fsr so that I always have a reading that is manageable for me.

Thanks @tom_l for this awesome project! I’m currently running an ESP32 (2 FSR) and a D1 Mini (3 FSR) very smoothly!
I followed your tutorial but I just noticed one thing: during my initial test, I had a regular voltage when I did not touch the FSR, like 3.15V constantly (which is also seems to be the case for other in this thread).
However, after investing why I had some weird binary sensor presence (I use an input_number in helper instead inside the ESP code), I found that voltage fluctuates from 2.8V to 3.16V.
I use a single 100k for the 3 FSR on D1 Mini (for my son) and 2 x 300k for the 2 FSR on the ESP (master bedroom). I tried without the mattress, keeping only 1 FSR or changing the resistance but the voltage still fluctuates.
In attachment the graph over a 2h windows.
Is voltage supposed to fluctuate that much, or should it be stable? Any ideas?
Thanks!

P.S: the blue line is a test with an ESP using the esp-idf framwork because I thought it might be the cause

No it should not be that noisy.

Thanks for the feedback @tom_l . Any idea why? Or any leads?

Not really. I haven’t seen that before. Are you using the ESPHome filters I wrote in the first post?

You may be picking up electrical noise from somewhere. How long are the cables from your FSR to the ESP?

Which FSR are you using?

Or a bad power supply? How are you powering it and are you using the 5V or 3.3V rail?

If Rin = Rout, fair to say that I’m in trouble with the FSR as is?

We have a king size mattress on top of two box springs, and then the wood slats are under both, so I’m (somewhat unsurprisingly) not getting a resistance differential between in and out. They’re both about 110 K-ohms. Thinking about grabbing a spare strip of 1x2 or 1x3 and slipping it under the mattress and above the box spring.

Any other suggestions?

Not really. If you cant apply pressure through the mattresses it wont work.

@tom_l, when measuring Rin and Rout, obviously the circuit should not be powered, but…is it important to have all the connections in place (other than power) in order to accurately gauge resistance? My leads are quite long, which would theoretically increase ohm value.

You measure the FSR resistance without it connected to anything except your meter.

Now that I’ve built a couple of these, I’m thinking about putting them in the guest room which would massively help a handful of automations. But of course, I can’t statically measure for an individual, so I was thinking about the trim pot route, so that it’s easily adjustable.

Curious if anybody has done this and what your experience has been?