Do you really have a water bed? Is that something you can still purchase new? I used to have one and honestly had no idea they were still around.
No, I was replying to someone with one. I haven’t slept on one of those for 20 years.
Been awhile since I looked at this thread seems lots of people have moved on with pcbs etc. I use a custom pcb on mine (which works great) couple of things that spring to mind reading through.
BME280 definitely needs to be off board, I connect mine with DuPont wires to header as it was several degrees off mounted on board.
The use of single set resistors, I don’t do this with mine I used trim pots, makes setting a breeze and allows easy tweaking over period of time to account for different weights of bedding and to dial out effects of cats sleeping on the bed in day time, Didn’t even bother measuring resistance on the last one I installed, 100k trim point turned down until voltage dropped below 3 out of bed. Not a clue what the resistance is, no need to know,
It’s a brilliant project, the amount of automations I have built based on this, genius idea by op.
Just wanted to send a warm thank you to @tom_l for an outstanding project! Built one this afternoon for the master bedroom and it works beautifully. My wife thought it was pure magic when she tested getting in and out of bed and watched everything turn on and off.
Used an ESP32 pico M5Atom Lite and Proto kit I had leftover from another project which turned out to be a perfect fit for this simple circuit. Thought I’d share!
Good Morning @demig !
Sound like a legit attempt. I‘ll try this as well since it‘s quite frustrating to always unsolder those metal-film resistor when want to „tune“.
From what I read / understand means that a 100k TrimPot has a Range from 0-100kOhm, please correct me if I‘m wrong.
Cheers Mate
Looks very cool! But only for one side hugh?
Hah I know I know; the M5 Atom lite only has one ADC pin header unfortunately, so my first pass was just the one side of the bed. But! I realized that the Grove port has a second ADC pin, and you gave me the motivation to redo it! Finished this morning with a spare board and now have both sides of the bed covered and working perfectly.
Looks very sleak - Cool thing!
I’m currently very satisfied with my little PCB - don’t looks that clean but I’ve put the whole thing into a surface mounted box and mounted it with reusable cable ties to the slats of my bed. And what should I say - it’s working wonderfully
Only when the roof leaks!
Thanks for this great writeup! I tried this years ago and for some reason failed, I guess I didn’t know enough about electronics yet. Now I have a sensor for each side of the bed and it’s working perfectly!
Note, I had to use a much higher R1, probably because my mattress weighs much less. With such a light load it was harder to get a reading for the base value of the FSR, so I used 5 Mohm for my calculation and that seems to have worked out great. My resulting resistor that I chose was 680 Kohm.
My FSR strips from Aliexpress arrived yesterday!
I’ve determined that breadboard jumper wires fit the pins perfectly…
Got it semi installed…under the mattress is complete but external circuitry still very temporary! Two FSRs secured and wired but only 1 connected to a D1 mini; an ESP32 is on order. I started with a 470K resistor but voltages in/out of bed very low (sub 1.0v). Worked my way down to a 50K resistor and have in bed voltages of 0.3-0.4 and out of bed 2.0-2.4. Judging by everything posted above, I would seem to be in the ballpark but will try smaller value resistors to get the out-of-bed voltage closer to 3.0 volts.
I don’t think I would use those Dupont wires for this use especially under the mattress that’s going to be moving around a lot. I think reliability would be a major issue.
Thanks to everyone for all the contributions. You guys convinced me to switch from a weight sensor to the FSR Bed sensor, which is a much more reliable and easier solution, I love it.
I want to give something back to the community, so I am sharing my ESP-Home code which I modified for 2 bed sides, faster sensor response by using the exponential_moving_average and added some nicer Icons and defined the correct device classes. (with sensor names in German)
binary_sensor:
- platform: template
name: "Bett besetzt links"
id: bed_state_left
device_class: occupancy
icon: mdi:bed-outline
lambda: |-
if (id(bed_sensor_left).state < id(trigger_level_left).state) {
return true;
} else {
return false;
}
- platform: template
name: "Bett besetzt rechts"
id: bed_state_right
device_class: occupancy
icon: mdi:bed-outline
lambda: |-
if (id(bed_sensor_right).state < id(trigger_level_right).state) {
return true;
} else {
return false;
}
- platform: template
name: "Bett besetzt"
icon: mdi:bed
id: bed_state
device_class: occupancy
lambda: |-
if (id(bed_state_left).state == true || id(bed_state_right).state == true ) {
return true;
} else {
return false;
}
- platform: template
name: "Bett besetzt auf beiden Seiten"
icon: mdi:bunk-bed
device_class: occupancy
id: bed_state_both
lambda: |-
if (id(bed_state_left).state == true && id(bed_state_right).state == true ) {
return true;
} else {
return false;
}
sensor:
- platform: adc
pin: GPIO34
attenuation: 11db
accuracy_decimals: 3
device_class: voltage
name: "Bett Sensor links"
id: "bed_sensor_left"
icon: mdi:arrow-collapse-vertical
update_interval: 0.2s
filters:
- exponential_moving_average:
alpha: 0.1
send_every: 1
- or:
- throttle: 180s
- delta: 0.02
- platform: adc
pin: GPIO35
attenuation: 11db
accuracy_decimals: 3
device_class: voltage
name: "Bett Sensor rechts"
id: "bed_sensor_right"
icon: mdi:arrow-collapse-vertical
update_interval: 0.2s
filters:
- exponential_moving_average:
alpha: 0.1
send_every: 1
- or:
- throttle: 180s
- delta: 0.02
number:
- platform: template
name: "Bett Links Trigger Level"
id: "trigger_level_left"
mode: box
optimistic: true
min_value: 0
restore_value: true
unit_of_measurement: "V"
device_class: voltage
max_value: 3.3
step: 0.01
icon: mdi:chart-sankey
- platform: template
name: "Bett Rechts Trigger Level"
id: "trigger_level_right"
device_class: voltage
unit_of_measurement: "V"
mode: box
optimistic: true
min_value: 0
restore_value: true
max_value: 3.3
step: 0.01
icon: mdi:chart-sankey
Do you mean the friction fit connector or the wires in general? There’s only about an inch or two of wiring taped down. Two fsr’s join a 3 conductor RGB ribbon cable that then goes below the slats and is secured alongside the center beam.
The mattress itself is quite heavy and only has +/- 1 in of play inside the frame…
Mostly the friction fit connectors. But the wires themselves inside the insulation are kind of flimsy too. Leaving them as a ribbon will help tho.
But the connectors are definitely the weakest link. I wouldn’t use them but maybe you’ll get lucky and they’ll work fine.
I tried DuPont connectors on my FSR, they were not a good fit so I went with careful soldering.
restore_value: True
works fine if you add restore_from_flash: True
to esp8266
section…
esphome:
name: bed-sensor
esp8266:
board: d1_mini
restore_from_flash: True
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
password: ""
wifi:
ssid: "<redacted>"
password: "<redacted>"
manual_ip:
static_ip: 192.168.1.86
gateway: 192.168.1.254
subnet: 255.255.255.0
fast_connect: true
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Bed Sensor Fallback Hotspot"
password: "<redacted>"
captive_portal:
binary_sensor:
- platform: template
name: "Master Bed Right Occupied"
id: mb_r
lambda: |-
if (id(master_bed_right_sensor).state < id(master_bed_right_trigger_level).state) {
return true;
} else {
return false;
}
number:
- platform: template
name: Master Bed Right Trigger Level
optimistic: True
min_value: 0
max_value: 3.5
step: 0.05
restore_value: True
initial_value: 2.0
id: master_bed_right_trigger_level
icon: mdi:arrow-collapse-down
unit_of_measurement: V
sensor:
- platform: adc
pin: A0
name: "Master Bed Right Sensor"
id: "master_bed_right_sensor"
icon: mdi:bed
update_interval: 0.5s
filters:
- multiply: 3.3
- sliding_window_moving_average:
window_size: 10
send_every: 1
- or:
- throttle: 180s
- delta: 0.02
I’m excited to work on this soon.
For those who have built this using two FSR strips, how did you wire and configure them? Did they both go into the same ESP32?
Additionally, has anyone who typically shares a bed with a partner had success setting the resistors so they can detect occupancy both a) when sleepers are in a specific side of the bed, and b) when just one sleeper is sleeping in the middle? How did you determine the resistor value (for the calculations in the OP) for that?