FSR - the best bed occupancy sensor

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

Because as others have noted it is not a touch sensor, so that connection method was not initially considered.

Hi Guys,

I’ve updated the PCB a little bit (to be smaller dimensions - also the groundplate is now over the whole PCB)


Also - please I’ve created a GitHUB Repository on that - feel free to download (or contribute if you want)

GitHub Repository

Cheers Flo

1 Like

Thanks a lot! the spacing for the screw terminals solder pins is 5mm. I also added 3d models in a local copy of your GitHub repository to get a better idea how the finished project looks like. I didn’t add the female headers though.

Has anyone used a shorter FSR - this one is 11 cm long but much cheaper.

Thx for that Felix - anyhow I’ve updated the design again to make the pcb smaller (45x32mm) and designed it to get VCC from external PSU. Also I added more descriptions on the PCB. The QR Code is a link to the github-repository where the KiCAD Files are located.

Cheers Flo

1 Like

I suppose so :slight_smile:
But I think with 11cm you will not get a reliable result, unless you do not turn over in your sleep and always stay in the same place :wink: