Site Tools


en:tech:bedsensor

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:tech:bedsensor [2021/01/19 08:33] – [Links] bullaren:tech:bedsensor [2022/09/26 09:59] (current) – external edit 127.0.0.1
Line 4: Line 4:
  
 Everyone who has become infected with the topic of smart home considers almost continuously how he/she can still automate manual, recurring tasks further. Provided that the appropriate sensors and actuators are already available. A sensor area that seems somewhat underrepresented is the occupancy sensor, e.g. to trigger or refrain from actions by going to bed. \\ Everyone who has become infected with the topic of smart home considers almost continuously how he/she can still automate manual, recurring tasks further. Provided that the appropriate sensors and actuators are already available. A sensor area that seems somewhat underrepresented is the occupancy sensor, e.g. to trigger or refrain from actions by going to bed. \\
-There are alarm mats as bed rugs or professional bed sensors from the care sector. The seat sensors from the automotive industry also perform a similar task. What they all have in common, however, is the lack of connection to an open protocol such as MQTT and of course the usually very high purchase costs.+There are alarm mats as bed rugs or professional bed sensors from the care sector. The seat sensors from the automotive industry also perform a similar task. What they all have in common, however, is the lack of connection to an open protocol such as MQTT or Home Assistant and of course the usually very high purchase costs.
  
 {{:tech:bettsensor_prof.png?direct&300|Professional bedsensor}} {{:tech:bettsensor_prof.png?direct&300|Professional bedsensor}}
Line 26: Line 26:
   * Two sensor inputs for a double bed   * Two sensor inputs for a double bed
   * WiFi integration   * WiFi integration
-  * MQTT protocol+  * MQTT protocol or ESPHome
  
 ====Hardware==== ====Hardware====
Line 65: Line 65:
 {{ :tech:bedsensor_module.jpeg?direct&400 | Bed Sensor open}} {{ :tech:bedsensor_module.jpeg?direct&400 | Bed Sensor open}}
  
-====Programing====+====Programming (ESPEasy)====
  
 After the hardware has been created we still have to program the ESP module. As already mentioned, the bed sensor is based on [[https://www.letscontrolit.com/wiki/index.php/ESPEasy|ESPEasy]]. In the link you can also find instructions on how the ESPEasy firmware is installed on the module. In order to get into the programming mode, the jumper SJ1 must be closed during the reset release. The programming is done serially via JP1 (USB-serial converter). After the hardware has been created we still have to program the ESP module. As already mentioned, the bed sensor is based on [[https://www.letscontrolit.com/wiki/index.php/ESPEasy|ESPEasy]]. In the link you can also find instructions on how the ESPEasy firmware is installed on the module. In order to get into the programming mode, the jumper SJ1 must be closed during the reset release. The programming is done serially via JP1 (USB-serial converter).
Line 134: Line 134:
 During the system boot we set the multiplexer to input 1, the start values ​​to 100 and a timer that calls the following routine every second. During the system boot we set the multiplexer to input 1, the start values ​​to 100 and a timer that calls the following routine every second.
 Both values ​​are read out every second and if there has been a change to the threshold value, the result is sent to the MQTT server. These are the states IN and OUT. You can of course also transmit the current values ​​and leave the decision as to whether IN or OUT to the home automation. In the following example I recorded a night like this. Both values ​​are read out every second and if there has been a change to the threshold value, the result is sent to the MQTT server. These are the states IN and OUT. You can of course also transmit the current values ​​and leave the decision as to whether IN or OUT to the home automation. In the following example I recorded a night like this.
 +
 +====Programming (ESPHome)====
 +The integration into [[https://www.home-assistant.io|Home Assistant]] lcan be easily done with [[https://esphome.io|ESPHome]]. All mandatory infos about the programming can also be found there online.
 +Here the final code for Bedsensor:
 +
 +<code yaml>
 +esphome:
 +  name: bedsensor
 +  on_boot:
 +    then:
 +      - delay: 20s
 +      - output.turn_off: led_blue
 +
 +esp8266:
 +  board: esp01_1m
 +
 +# Enable logging
 +logger:
 +
 +# Enable Home Assistant API
 +api:
 +  encryption:
 +    key: "--key--"
 +
 +ota:
 +  password: "---password---"
 +
 +wifi:
 +  ssid: !secret wifi_ssid
 +  password: !secret wifi_password
 +
 +  # Enable fallback hotspot (captive portal) in case wifi connection fails
 +  ap:
 +    ssid: "Bedsensor Fallback Hotspot"
 +    password: "--password--"
 +
 +captive_portal:
 +
 +switch:
 +  - platform: gpio
 +    pin: GPIO12
 +    id: sensor_select
 +    internal: true
 +
 +output:
 +  - platform: gpio
 +    pin: GPIO2
 +    inverted: true
 +    id: led_blue
 +
 +sensor:
 +  - platform: adc
 +    pin: A0
 +    id: bed_raw_adc
 +    update_interval: 1s
 +    raw: true
 +    accuracy_decimals: 0
 +    internal: true
 +    on_raw_value:
 +      then:
 +        - lambda: |-
 +            if (id(sensor_select).state) {   
 +              if (x < 50) {
 +                id(bed_sensor_2).publish_state(false);  
 +              } else {
 +                id(bed_sensor_2).publish_state(true);  
 +              }                
 +              id(sensor_select).turn_off();
 +            } else {
 +              if (x < 50) {
 +                id(bed_sensor_1).publish_state(false);  
 +              } else {
 +                id(bed_sensor_1).publish_state(true);  
 +              }    
 +              id(sensor_select).turn_on();
 +            }    
 +
 +binary_sensor:
 +  - platform: template
 +    name: "Bed Sensor 1"
 +    id: bed_sensor_1
 +
 +  - platform: template
 +    name: "Bed Sensor 2"
 +    id: bed_sensor_2
 +</code>
 +
  
 ====Example==== ====Example====
Line 154: Line 241:
 ==== Donate ==== ==== Donate ====
  
-If you my job feel to donate a cappuccino or so...+If you like my articles feel to donate a cappuccino or so...
  
 <html> <html>
  
 <form action="https://www.paypal.com/donate" method="post" target="_top"> <form action="https://www.paypal.com/donate" method="post" target="_top">
-<input type="hidden" name="hosted_button_id" value="N397JC5HP82AQ" /> +<input type="hidden" name="hosted_button_id" value="49N24HL36GF9U" /> 
-<input type="image" src="https://www.paypalobjects.com/de_DE/DE/i/btn/btn_donateCC_LG.gif" border="0" name="submit" title="PayPal - The safer, easier way to pay online!" alt="Donate with PayPal button" /> +<input type="image" src="https://www.paypalobjects.com/en_US/DK/i/btn/btn_donateCC_LG.gif" border="0" name="submit" title="PayPal - The safer, easier way to pay online!" alt="Donate with PayPal button" /> 
-<img alt="" border="0" src="https://www.paypal.com/de_DE/i/scr/pixel.gif" width="1" height="1" />+<img alt="" border="0" src="https://www.paypal.com/en_DE/i/scr/pixel.gif" width="1" height="1" />
 </form> </form>
  
 </html> </html>
- 
- 
  
en/tech/bedsensor.1611045239.txt.gz · Last modified: 2021/01/19 08:34 (external edit)