Generalized-Core-Counter 3.20
Particle-based generalized core counter firmware
Loading...
Searching...
No Matches
PIRSensor Class Reference

PIR (Passive Infrared) Motion Sensor Implementation. More...

#include <PIRSensor.h>

Inheritance diagram for PIRSensor:
ISensor

Public Member Functions

SensorData getData () const override
 Get latest sensor reading.
const char * getSensorType () const override
 Get sensor type identifier.
bool isReady () const override
 Check if sensor is ready.
bool loop () override
 Poll the PIR sensor for motion detection.
void onSleep () override
 Prepare sensor for deep sleep: detach ISR and power down.
bool onWake () override
 Wake sensor from deep sleep: power up and re-attach ISR.
void reset () override
 Reset sensor state.
bool setup () override
 Initialize the PIR sensor.
bool usesInterrupt () const override
 This sensor uses a hardware interrupt for motion events.
Public Member Functions inherited from ISensor
virtual bool initializeHardware ()
 Initialize underlying hardware after power-on.
virtual bool isHealthy () const
 Health check for the sensor.
virtual int lastErrorCode () const
 Last sensor-specific error code (if any).
virtual ~ISensor ()

Static Public Member Functions

static PIRSensorinstance ()
 Get singleton instance.

Detailed Description

PIR (Passive Infrared) Motion Sensor Implementation.

This is a placeholder/template for future PIR sensor implementation. PIR sensors detect motion by measuring infrared light radiating from objects.

Typical usage:

  • Motion detection for occupancy tracking
  • Presence detection for people counting
  • Security/intrusion detection

Hardware Requirements:

  • PIR sensor module (e.g., HC-SR501, AM312)
  • Digital input pin for sensor signal
  • Power supply (typically 3.3V or 5V)

Definition at line 26 of file PIRSensor.h.

Member Function Documentation

◆ getData()

SensorData PIRSensor::getData ( ) const
inlineoverridevirtual

Get latest sensor reading.

Returns
SensorData with motion detection info

Implements ISensor.

Definition at line 94 of file PIRSensor.h.

◆ getSensorType()

const char * PIRSensor::getSensorType ( ) const
inlineoverridevirtual

Get sensor type identifier.

Implements ISensor.

Definition at line 101 of file PIRSensor.h.

◆ instance()

PIRSensor & PIRSensor::instance ( )
inlinestatic

Get singleton instance.

Definition at line 31 of file PIRSensor.h.

Referenced by SensorFactory::createSensor().

◆ isReady()

bool PIRSensor::isReady ( ) const
inlineoverridevirtual

Check if sensor is ready.

Implements ISensor.

Definition at line 108 of file PIRSensor.h.

◆ loop()

bool PIRSensor::loop ( )
inlineoverridevirtual

Poll the PIR sensor for motion detection.

Returns
true if new motion detected
Note
Currently interrupt-driven only. Returns false in polling mode. Motion is detected via a hardware interrupt (pirISR) which sets an internal flag. This method returns true once per interrupt and clears the flag.

Implements ISensor.

Definition at line 67 of file PIRSensor.h.

◆ onSleep()

void PIRSensor::onSleep ( )
inlineoverridevirtual

Prepare sensor for deep sleep: detach ISR and power down.

Reimplemented from ISensor.

Definition at line 131 of file PIRSensor.h.

References disableModule, intPin, and ledPower.

◆ onWake()

bool PIRSensor::onWake ( )
inlineoverridevirtual

Wake sensor from deep sleep: power up and re-attach ISR.

Reimplemented from ISensor.

Definition at line 146 of file PIRSensor.h.

References disableModule, intPin, and ledPower.

◆ reset()

void PIRSensor::reset ( )
inlineoverridevirtual

Reset sensor state.

Implements ISensor.

Definition at line 115 of file PIRSensor.h.

Referenced by setup().

◆ setup()

bool PIRSensor::setup ( )
inlineoverridevirtual

Initialize the PIR sensor.

Returns
true if initialization successful

Implements ISensor.

Definition at line 40 of file PIRSensor.h.

References disableModule, intPin, ledPower, and reset().

◆ usesInterrupt()

bool PIRSensor::usesInterrupt ( ) const
inlineoverridevirtual

This sensor uses a hardware interrupt for motion events.

Reimplemented from ISensor.

Definition at line 126 of file PIRSensor.h.


The documentation for this class was generated from the following files: