FSR - the best bed occupancy sensor

Success, 0.7-0.8V in bed, goes to 2.8v ish out.
Thank you!

What kind of terminals/pre made wires do I need so I can just plug and play wires instead of trying to solder them to the dev board pins

1 Like

Search for “DuPont jumpers”.

Soldering is always more reliable though.

who modified the code to have two films using only one Exp? I read that someone did it but too many comments don’t allow me to find it

I assume you meant Esp, not Exp? If so, my complete code for 2 strips is a little further up.

1 Like

Thank you. can i ask u the schema on esp8266 for two strips?
Thank you

It would seem that it is not possible on the ESP8266 as it only has one ADC.

Screenshot 2024-03-26 215336

This is funny to read, since I’ve been having the same problem for ages and therefore never actually use my bed sensor. For the last few days I’ve been testing everything (including many different power supplies) and nothing worked.

So I finally reduced everything to its bare minimum and was testing on my workbench and it still was doing this until I removed the magnetic clamps I was using to attach the cables to the underside of the bed. It appears the magnets were causing some sort of EMI interference (I’m guessing acting as a sort of inductor?) making it absolutely unusable.

Now I still have a pretty regular dip in voltage, but I’m able to filter it out in software. My assumption is that there’s still some source of interference and that I should somehow shield it. I’m planning to try and use some cat6 cable.

My cables are fairly long, so it can reach both sides of the bed (I have two sensors normally), testing the same circuit on my workbench without cables didn’t show any fluctuations at all, so I’m pretty confident this is the issue by this point.

My current readings (with a median filter of window size 5 on it, sorry I only realized later) look like this. The big dip is the moment I actual lie in the bed. Since it’s only a few ticks of drop and a positive signal is stable, I think I can filter it simply by using the max filter and the exponential filter.

I’m going to try it out in practice the coming few days.

You need to fix that interference issue. With that amount of noise the sensor will not work correctly or it will be slow if filtered to remove it.

Try connecting a fixed resistor in place of the FSR, do you still see the issue?

If you don’t, you have a faulty FSR.

You are right of course, but I wanted a semi-stable solution while I worked on a more permanent solution. I have enough applications that don’t require high speed, such as arming and disarming the night alarm.

I tried the same sensor on my workbench and I didn’t have these large spikes then. I didn’t test it for a very long time, but as you can see in the image, the frequency is roughly every 60 seconds, so a few minutes should have been enough to see the effect. I did see very minor dips (from 3.16 to say 2.9), but nothing like the effect I’m seeing once it is mounted.

I’m not quite sure what is causing it. An important difference of course is that the sensor is experiencing more weight from the bed-frame, even when noone is in bed, so it might just become unstable at that specific pressure. However, as you can see below, it operates fine once someone is in bed. I also had a second sensor - that I managed to break during the testing :frowning: - that showed the opposite effect. The 2 voltages were somehow coupled.

anyway, this was the result last night:

Another theory (since it does have a certain regularity) is that there’s some sort of resonance picked up.

I’ve ordered some extra sensors, so I should have my answer once those arrive. I plan to make these a bit more modular with a short cable that has some sort of connector, so I can try different combinations and more easily assemble and disassemble. In that case I can also properly test your suggestion, because I want to test it ceteris paribus (since everything is fine anyway on the workbench).

Have you soldered the connections to the FSR or are they crimped?

Do you have a PWM electric blanket on the bed?

I have them soldered on and no other electronics on the bed. There’s some surrounding it obviously (lamps, a zigbee dimmer, that sort of thing), but nothing close by. AT first I thought it was the CO-2 sensor I had running on the same esp32, but if I remove it it doesn’t change anything.

I was having trouble getting anything detected underneath a memory foam mattress. I put a strip of thin plywood underneath without any difference. I then put another strip over top and now the sensor works perfectly.

Thanks so much for this idea, I didn’t even know I needed this until finding this post.

I seem to have solved my issue in a (for me) unexpected way. I was experimenting creating a voltage follower with an op-amp, since I read somewhere that this was needed for voltage divider circuits, but it didn’t work as I expected.

So I simply tried filtering high frequency noise by adding a 10uF capacitor between the ADC pin and ground and to my surprise this has completely solved the issue. I didn’t expect it, since I figured the frequency filtered out would be much higher than the resonance I was seeing, but for some reason it has almost completely removed it. Look at this output (without any software filtering):

As you can see it is very stable and it is also fast acting (within 1 second), so I think I’ll just be happy with this solution. Hopefully this helps someone else as well.

Just in case anyone else is having a hard time getting their strip/sensor to work correctly (after following the pined tutorial).

You could just have a bad sensor and likely worth buying a replacement instead or trying to troubleshoot/calibrate for 3 weeks… :man_facepalming:

  • My wife’s Side:
    First sensor I bought to test it all out, worked perfect from the beginning.

  • My Side:
    Took me x3 sensors to finally get it working (first x2 were not ideal).

I was having issues with one of my sensors (my side of the bed) being extremely slow to reach min/max volt and the most voltage difference I could get was only at max ~1v when in/out of bed.
I tried measuring, recalculating and changing the R1 value so many times but, was never happily consistent.

I solder electronics every day at my job so I know it was not the connection, just a ribbon that was not 100% functional for what ever reason.

Where did you buy the sensors?

All were from the same seller on Ali Express.
Not sure if that was smart or silly, but the first one worked like a charm so didn’t think it was too silly reordering more… haha

They all came like others have mentioned, more or less scrunched up in a bag. I ran the bent parts over a heat gun on low to straighten them out.