Hi all,
I followed the instructions from this thread.
https://www.reddit.com/r/Esphome/comments/11p24vk/bed_occupancy_detection_using_pressure_strips/
It seems to work fine when the sensor is outside the bed, but when I put it under the mattress only one side works. I thought that possibly a wire that came loose when I put the mattress on top, but if I lift up the mattress and push it down with my finger it works fine. Does anyone have any ideas why this might work perfectly on one side, but not work at all on the other side.
Here is the esphome code
substitutions:
name: master-bedroom-bed-sensor
friendly_name: Master Bedroom Bed Pressure Sensor
esphome:
name: ${name}
friendly_name: ${friendly_name}
min_version: 2024.6.0
name_add_mac_suffix: false
project:
name: esphome.web
version: dev
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
# Allow Over-The-Air updates
ota:
- platform: esphome
# Allow provisioning Wi-Fi via serial
improv_serial:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "${name}"
password: "KK5Mom3*sgi$SchDVL"
# In combination with the `ap` this allows the user
# to provision wifi credentials to the device via WiFi AP.
captive_portal:
dashboard_import:
package_import_url: github://esphome/example-configs/esphome-web/esp32.yaml@main
import_full_config: true
# Sets up Bluetooth LE (Only on ESP32) to allow the user
# to provision wifi credentials to the device.
esp32_improv:
authorizer: none
# To have a "next url" for improv serial
web_server:
switch:
- platform: restart
name: Restart ${friendly_name}
sensor:
- platform: adc
id: "pressure_brian"
pin: GPIO36
name: "Bed Pressure Brian"
update_interval: 1s
entity_category: "diagnostic"
attenuation: auto
- platform: adc
id: "pressure_britni"
pin: GPIO39
name: "Bed Pressure Britni"
update_interval: 1s
entity_category: "diagnostic"
attenuation: auto
number:
- platform: template
name: "Brian Voltage Threshold"
id: "brian_threshold"
optimistic: true
min_value: .2
max_value: 3.3
step: .02
restore_value: True
entity_category: "config"
on_value:
- lambda: |-
id(bin_brian).set_upper_threshold(x);
id(bin_brian).set_lower_threshold(x);
- platform: template
name: "Britni Voltage Threshold"
id: "britni_threshold"
optimistic: true
min_value: .2
max_value: 3.3
step: .02
restore_value: True
entity_category: "config"
on_value:
- lambda: |-
id(bin_britni).set_upper_threshold(x);
id(bin_britni).set_lower_threshold(x);
binary_sensor:
- platform: analog_threshold
id: "bin_brian"
device_class: "occupancy"
name: "Bed Brian Occupancy"
sensor_id: pressure_brian
threshold: 0.2
filters:
- invert:
- platform: analog_threshold
id: "bin_britni"
device_class: "occupancy"
name: "Bed Britni Occupancy"
sensor_id: pressure_britni
threshold: 0.2
filters:
- invert: