FSR - the best bed occupancy sensor

It’s one resistor per FSR. Not sure why you need a custom PCB for it, but sure your design will work. The only recommendation I’d make would be to exclude the ground plane from the area under the ESP antenna as per the ESP hardware guidelines pdf, section 3.1.2

Untitled

Or you may find you have poor wifi signal strength.

1 Like

You are very generous with your time and I’m starting to feel encouraged to try this! If you don’t mind I have a few follow up questions:

  • When I purchase any tools I learned to not cheap out and get the good stuff right away. That being said do you have a suggestion for s soldering iron/setup that will make my life easier and last?

  • It seems people around here keep mentioning the Wemos D1 Mini. Would that be a good choice? (Also the one I linked is from a company called ACEIRMC. Is Wemos not a brand name?)

  • I own this multimeter. Would that work? Which of the settings would I need to set it to to measure the FSR resistance?

*What range of resistor pack should I be looking for so I’m all set for this project?

*Would you recommend the FSR linked in the first post or did you use some cheap one from Aliexpress?

  • Even if I solder it all together it will still be a mess of wires and rather fragile, right? Do you put it all in some sort of case? I have done a breadboard WLED project once but it all fell apart because it was all so fragile. What kind of case would you recommend for a setup like this? I just don’t want things to come apart.

I think I will actually document this build with step by step video instructions so that other N00bs can follow it and learn from it. Would be super cool to have a step by step video tutorial for this amazing project.

OMG this looks so clean!!! Where is the EPS, though?

The soldering iron I have probably costed about $10-15.
It was probably among the cheapest soldering irons at the time.
You probably get a better tool if you spend more money, but it works fine for me.

Sure WeMos is fine, I have a few of those.
I have not noticed much difference between different normal ESPs, when you get those with displays or other accessories added then they can be harder to use.

I haven’t used that multimeter myself but reading the header and looking at the picture, seems good.

Something like this?

It has all the values that you will ever need.
If you do need a larger value for any reason then you can add two in series.

I haven’t used a FSR as a bed sensor.
I use a pressure mat.
But I have used FSRs and they generally work fine. Not this particular though.

As I said, I don’t recommend a breadboard, possibly a perfboard as above.
But no I don’t have a case for mine. It’s not fragile when you solder it.
You can glue it to the bottom of the bed or tie it.
It will work fine, it’s not that much movements down there.

Looking forward to the video! :+1:

thx a lot. the sensor workinng really good!

Hi @tom_i,
It’s not a question of “need.” It’s just a question of “I want to have it”. And besides, I’ve always wanted to play around with KiCAD and see if I can get it to work. :slight_smile: . Although this area of clearance (as I can see) is needed for the ESP Baseboard only. Since my design is for a ESP32-Mini which will be installed on 10pin headers (just for beeing flexible if the esp-board will break) I think this is not needed.

Fair enough. It’s a nice simple project to get started with using KiCad.

I disagree. The headers do not lift the ESP antenna more than 15mm from the PCB ground plane. Follow the design guidelines.

I don’t know if its just me but I am ussing a pressure sensor that does have more than 2M ohms when not pressed. If I sit on it it has approx 10 ohms.

I have tried with R1=1M and it is always the same. When I sit the A0 goes to 3,3V and when i stand it goes to 0 V. Its completely reversed.

Any help?

You have the resistor and FSR swapped in this:

Screenshot 2021-12-11 at 15-53-11 Resistance Sensor

The resistor should go to 3.3v and the FSR to ground.

now it worked with a 100k resistor!

Thank you.

Any idea how to power it up with batteries?
Is it possible to use two AA batteries 1,5+1.5V= 3V

For a very short while it’s probably possible

Thx for your info. I’ve updated the design toe keep-out the copper area from the ESP32-mini antenna.
Also updated the github-project with new files (schematic, pcb and gerber files). Also post it here just for reference :slight_smile:

Cheers Flo



image

Could someone help me please. I have build this pressure sensor. But the values are all over the place. I have 2 sensors, but only 1 connected. But it picks up values on both sensors. But constantly fluctuating.
This is the left sensor that is connected:

And this is the right sensor that is not connected:

Maybe I did something wrong with the wiring? Could someone show a outline of the wiring with 2 sensors and an ESP32?

Hi, great projects. I want to ask, will this FSR works in this project? https://www.aliexpress.com/item/1005004918766636.html or https://www.aliexpress.com/item/1005001572817402.html
Thanks for help.

Is there a reason we couldn’t use the FSR flex/bend with the ESP32-touch sensors? Like this:

esp32_touch:
   setup_mode: true
   low_voltage_reference: 0.8V
   high_voltage_reference: 2.4V
   voltage_attenuation: 0V
   iir_filter: 10ms

binary_sensor:
   - platform: esp32_touch
     name: "Top Right"
     pin: GPIO33
     threshold: 1
     id: left_side_bed

Just wondering as I have a hard time wiring this up and making it work - while touch seems to work right away?

1 Like

I’m not an electronics expert but I assume - no - since this IS not touch sensor right? :slight_smile:

So I got it working in the end. Probably my Wemos D1 was broken, after experimenting it died on me (wifi gives constantly a brownout - even if there is nothing else in the esphome script/firmware).

When I calculated it as the reading was averaging 880 in bed and overload out of bed (meter goes till 20M), I had to assume a value for R2. I assumed just a little bit above 20M. When I did the formula - it came up with a value for R1 as 47000 (47K). I found a site explaining the Voltage Divider and it had a small tool where you could enter different values so calculate the voltage on the divider.

https://learn.sparkfun.com/tutorials/voltage-dividers/all

When I entered 3.3 volt, R1 = 47000, R2 = 880, it would generate a voltage of 0.3 volt. I thought his was a little too low. On the site you play around with the figures and with a R1 = 4.7K it would drop to 0.52 volt. This seemed a little bit safer (don’t know if there is a danger in dropping to 0, a short circuit?).

As the bed has two sides, two the same mattrasses, and the same FSR, I assumed I could take the same values. That didn’t turn out to be the case. I have installed now for the second FSR an R1 = 100K. Before with R1 = 4.7k the in bed voltage would fluctuate from 2.6 to 2.9, now with the R1 = 100K it drops to 0.3 volts. Perhaps still to low but the difference is now larger. Even though the out of bed voltage is now fluctuating between 3.14 (which seems to be the maximum) and 3.0.

Is it bad that the out of bed voltage is fluctuating? And is there a danger in reaching in bed values of 0 volt?

Still the tool works great to test possible voltage out comes and one can adjust accordingly. This is the script in ESPhome that I am using:

sensor:
  - platform: adc
    pin: GPIO36
    attenuation: 11db
    name: "Bed Sensor Right"
    id: "bed_sensor_right"
    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: GPIO34
    attenuation: 11db
    name: "Bed Sensor Left"
    id: "bed_sensor_left"
    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: mqtt_subscribe
    id: bed_trigger_level_left
    topic: homeassistant/input_number/master_bed_left_trigger_level/state

  - platform: mqtt_subscribe
    id: bed_trigger_level_right
    topic: homeassistant/input_number/master_bed_right_trigger_level/state

I am using MQTT to communicate with HA, it is just much faster and more reliable. I got constant disconnections with the API call to HA.

Touch sensors work on the same principal. I think with the voltage and the resistors you have more control over sensitivity. But I connected the FSR as a touch sensor, and it worked. However the in bed voltage that the touch sensor read (as the touch sensor registers voltage) would drop to 0 volt. Out of bed it was 3.3 volt. It was too extreme for me.

It looks like the touch sensors work kind of like what we are doing: it can measure the voltage going through the sensor and gnd.

2 Likes

It’s an input not a power pin. The lower the “off” voltage the better.

Getting 0 to 3.3V is an ideal response for the sensor.

So why would we use this whole voltage divider setup, if we can just use the esp32_touch settings?

2 Likes