ESPHome 2026.6.0-dev
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::qwiic_pir {
16
17// Qwiic PIR I2C Register Addresses
18enum {
21 QWIIC_PIR_DEBOUNCE_TIME = 0x05, // uint16_t debounce time in milliseconds
22};
23
29
30static const uint8_t QWIIC_PIR_DEVICE_ID = 0x72;
31
33 public:
34 void setup() override;
35 void loop() override;
36
37 void dump_config() override;
38
39 void set_debounce_time(uint16_t debounce_time) { this->debounce_time_ = debounce_time; }
41
42 protected:
43 uint16_t debounce_time_{};
44
46
52
53 union {
54 struct {
55 bool raw_reading : 1; // raw state of PIR sensor
56 bool event_available : 1; // a debounced object has been detected or removed
57 bool object_removed : 1; // a debounced object is no longer detected
58 bool object_detected : 1; // a debounced object has been detected
59 bool : 4;
60 };
61 uint8_t reg;
62 } event_register_ = {.reg = 0};
63
64 void clear_events_();
65};
66
67} // namespace esphome::qwiic_pir
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:132
void set_debounce_time(uint16_t debounce_time)
Definition qwiic_pir.h:39
void set_debounce_mode(DebounceMode mode)
Definition qwiic_pir.h:40
enum esphome::qwiic_pir::QwiicPIRComponent::ErrorCode NONE
union esphome::qwiic_pir::QwiicPIRComponent::@148 event_register_