ESPHome  2024.4.0
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 
11 #include "esphome/core/component.h"
14 
15 namespace esphome {
16 namespace qwiic_pir {
17 
18 // Qwiic PIR I2C Register Addresses
19 enum {
22  QWIIC_PIR_DEBOUNCE_TIME = 0x05, // uint16_t debounce time in milliseconds
23 };
24 
29 };
30 
31 static 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 
49  enum ErrorCode {
50  NONE = 0,
53  } error_code_{NONE};
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
const float DATA
For components that import data from directly connected sensors like DHT.
Definition: component.cpp:19
float get_setup_priority() const override
Definition: qwiic_pir.h:39
enum esphome::qwiic_pir::QwiicPIRComponent::ErrorCode NONE
void set_debounce_mode(DebounceMode mode)
Definition: qwiic_pir.h:42
BedjetMode mode
BedJet operating mode.
Definition: bedjet_codec.h:151
union esphome::qwiic_pir::QwiicPIRComponent::@102 event_register_
void set_debounce_time(uint16_t debounce_time)
Definition: qwiic_pir.h:41
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7
Base class for all binary_sensor-type classes.
Definition: binary_sensor.h:37
This Class provides the methods to read/write bytes from/to an i2c device.
Definition: i2c.h:133