ESPHome 2025.5.0
Loading...
Searching...
No Matches
qwiic_pir.h
Go to the documentation of this file.
1/*
2 * Adds support for Qwiic PIR motion sensors that communicate over an I2C bus.
3 * These sensors use Sharp PIR motion sensors to detect motion. A firmware running on an ATTiny84 translates the digital
4 * output to I2C communications.
5 * ATTiny84 firmware: https://github.com/sparkfun/Qwiic_PIR (acccessed July 2023)
6 * SparkFun's Arduino library: https://github.com/sparkfun/SparkFun_Qwiic_PIR_Arduino_Library (accessed July 2023)
7 */
8
9#pragma once
10
14
15namespace esphome {
16namespace qwiic_pir {
17
18// Qwiic PIR I2C Register Addresses
19enum {
22 QWIIC_PIR_DEBOUNCE_TIME = 0x05, // uint16_t debounce time in milliseconds
23};
24
30
31static const uint8_t QWIIC_PIR_DEVICE_ID = 0x72;
32
34 public:
35 void setup() override;
36 void loop() override;
37
38 void dump_config() override;
39 float get_setup_priority() const override { return setup_priority::DATA; }
40
41 void set_debounce_time(uint16_t debounce_time) { this->debounce_time_ = debounce_time; }
43
44 protected:
45 uint16_t debounce_time_{};
46
48
54
55 union {
56 struct {
57 bool raw_reading : 1; // raw state of PIR sensor
58 bool event_available : 1; // a debounced object has been detected or removed
59 bool object_removed : 1; // a debounced object is no longer detected
60 bool object_detected : 1; // a debounced object has been detected
61 bool : 4;
62 };
63 uint8_t reg;
64 } event_register_ = {.reg = 0};
65
66 void clear_events_();
67};
68
69} // namespace qwiic_pir
70} // namespace esphome
BedjetMode mode
BedJet operating mode.
Base class for all binary_sensor-type classes.
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:133
union esphome::qwiic_pir::QwiicPIRComponent::@140 event_register_
float get_setup_priority() const override
Definition qwiic_pir.h:39
void set_debounce_time(uint16_t debounce_time)
Definition qwiic_pir.h:41
void set_debounce_mode(DebounceMode mode)
Definition qwiic_pir.h:42
enum esphome::qwiic_pir::QwiicPIRComponent::ErrorCode NONE
const float DATA
For components that import data from directly connected sensors like DHT.
Definition component.cpp:19
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7