GithubHelp home page GithubHelp logo

zigbee-bed-occupancy's Introduction

Bed occupancy sensor with ESP32-C6

Handles bed occupancy on two sides of the bed using two SF15-600 pressure sensors.

Uses ADC channels 2 and 3 to read the voltage and decide whether that side of the bed is occupied.

Schematic

Zigbee2MQTT configuration

const exposes = require('zigbee-herdsman-converters/lib/exposes');
const e = exposes.presets;
const utils = require('zigbee-herdsman-converters/lib/utils');

const definition = {
    zigbeeModel: ['Bed Occupancy'],
    model: 'Bed Occupancy',
    vendor: 'Espressif',
    description: 'Bed occupancy sensors',
    fromZigbee: [{
        cluster: 'genBinaryInput',
        type: 'attributeReport',
        convert: (model, msg, publish, options, meta) => {
            return {[utils.postfixWithEndpointName('occupancy', msg, model, meta)]: msg.data.presentValue === 1 ? true : false};
        },
    }
    ],
    toZigbee: [],
    meta: {multiEndpoint: true},
    endpoint: (device) => {
        return {bed1: 10, bed2: 11};
    },
    exposes: [
        e.occupancy().withEndpoint('bed1').withDescription('Occupancy of bed 1'),
        e.occupancy().withEndpoint('bed2').withDescription('Occupancy of bed 2')
    ],
};

module.exports = definition;

Which shows up as this:

Zigbee2MQTT

Configure the project

Before project configuration and build, make sure to set the correct chip target using idf.py --preview set-target TARGET command.

Erase the NVRAM

Before flash it to the board, it is recommended to erase NVRAM if user doesn't want to keep the previous examples or other projects stored info using idf.py -p PORT erase-flash

Build and Flash

Build the project, flash it to the board, and start the monitor tool to view the serial output by running idf.py -p PORT flash monitor.

(To exit the serial monitor, type Ctrl-].)

zigbee-bed-occupancy's People

Contributors

chadiem avatar

Watchers

 avatar  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.