FSR - the best bed occupancy sensor

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.

1 Like

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.

Hey guys, is anyone selling the daughter boards with the adjustable resistors? I don’t need 5 and there is no reason for all of us to keep paying setup fees.

I’m working on a dual sensor setup with a digital potentiometer that attaches cleanly to the bed slat. The goal is that it can auto calibrate to a new bed, weight, etc. without having to calculate a new resistor value manually. This is definitely a little more universally applicable for those struggling with the hardware setup side of things. If there’s enough interest I’d be interested in selling them once I finish packaging it up.



16 Likes

Jason,

Looks good, would you have a schismatic or better yet a picture of both sides of the PCB?

For those using trimpots / potentiometers to provide more dynamic control over resistance (@RoadkillUK), wondering about:

  1. since trimpots have different ohm ratings, how do you pick the right one? I’ve been using the math in the OP, finding a low end and high end, and then selecting a potentiometer in that range. Is there a better way?

  2. noticed some trimpots market themselves as “precise adjustment”. Is that real or just marketing? It did make me wonder how fine-grained the knobs on a trimpot are.

Appreciate any advice from folks more schooled in electronics than I am.

For the folks who observe the noisy, only slightly reacting on pressure measurements (below) - high chances the sensor is broken and needs replacement:

Same line after replacement:

Used 60 cm FRS sensor from Ali (here widely discussed). Sensor came highly bent.

The broken sensor visually looks fine, even better then the working one, but don’t deliver sensible values (±50% noise around the pressure level, not possible to compensate/average in reasonable time).

To exclude other sources of problems I’ve switched the ADC lines, so it was for sure the sensor.
I also tried to add 65nF capacitor on sensor line - no difference.