Code Monkey home page Code Monkey logo

esphome-bed-occupancy-fsr's Introduction

ESPHome-bed-occupancy-FSR in Homeasistant

Easy EDA files added.

Bed sensor based on Force Sensitive Resistor (FSR) for double bed works for each side, can just use one side if required. One FSR (60cm recommended) is fixed to a slat on each side underneath middle of sleeping position. Each sensor is soldered to bell wire and heat shrink used to reinforce the join, extreme care is needed to do this as you do not want to melt the plastic tape, you can purchase connectors instead if not confident but it really is very easy. I suggest pretinning the bell wire and tapeing the wire and FSR down to a flat surface the tinned wire on top of the copper contact area of FSR, a tiny dab with solder iron and solder wil make the join. The FSR tapes are stuck down to the slat but recomend each strip is also held down with wrap of masking tape all around the slat just for extra protection.

One ESP32 (36pin) is used and connects to both FSRs. Project inspired by the following link, some excellent information in here and code taken from here and modified for this particular project.

https://community.home-assistant.io/t/fsr-the-best-bed-occupancy-sensor/365795

FSR used obtained from Pihut in UK:

https://thepihut.com/products/extra-long-force-sensitive-resistor-fsr

One end of each FSR is connects to 3.3V and the other to an ADC pin, an additional resistor is needed to bring signal into a range where the resistance of the FSR when been is occupied and unoccupied can be detected. Following the original project the easiest way to measure this is to use a multimeter connected to the wire soldered to each resistor, use a crocodile clip or a wago connector clipped onto the probe and wire. Measure the resistance with bed occupied and unoccupied, it will drift so take an average value, a min max multimeter works very well for this but is not needed! With this PCB you can completely eliminate this stage if desired as it is not necessary but it does give a good starting point for adjustment I found that a little tweaking over the first few days of use gave the best performance long term. Change of bedding etc, sleeping postion can affect it but using this PCB with trim pots allow adjustments without needing to replace resistors.

The resistance needed is Sqrt (in bed*out of bed)

Set the trim pot for each side to the value determined, you will need a multimeter connected to the PCB, do not at this stage have the FSR or ESP32 connected. The resistance for each side can be measured between the pin and the 3.3V pin. When you connect this to the FSRs I have found you want to set it so that the out of bed reading from the ESPHome sensor is about 2.9V. Clockwise turns on the trim pot reduce the voltage, you can just do this instead of measuring resistance.

The FSRs can then be connected, one wire from each FSR goes into the 3.3V terminal and then the other wires go into their respective terminals. The ESP32 (previously Flashed with ESPHome code) can be connected along with an i2c device if desired, example code shows nothing and also option with BMP280 for temperature and pressure. In addition an example is given where the bluetooth on board is also used for iwatch tracking (to add).

I have had some issues with power on the ESP32 I used (suggested ESP32 to be added to BOM) I resolved this by flashing and then connecting it to a decent power supply which seems to sort it.

Example code is attached.

The occupancy sensor can be used for whatever you want, turning a lowlevel light on if up in night is one example. I also use node red with an and gate to estabish when both people up in the morning to open all the blinds, turn on the kettle etc.

PCB A PCB have been designed allowing for a dual bed sensor with trim pots on the board to allow for resistance adjustment on the device, you can add an i2c device for example a BME280 for room humidity, pressure and temperature but it's not needed. Schematic and gerbers are in repo.

image

Example yaml for both is included, BOM to be added.

esphome-bed-occupancy-fsr's People

Contributors

iainphay avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.