January 2019
Intermediate to advanced
458 pages
10h 35m
English
The motion module is intended to work with passive infrared (PIR) sensors. These have onboard logic that determine when a trigger point has been reached, at which point they change an interrupt pin into a high signal. We can use this to determine whether a person is in a room, or is walking through a hallway.
Its code looks as follows:
#include "base_module.h" #define GPIO_PIN 0 class MotionModule { static int pin; static Timer timer; static Timer warmup; static bool motion; static bool firstLow; public: static bool initialize(); static bool start(); static bool shutdown(); static void config(String cmd); static void warmupSensor(); static void readSensor(); static void IRAM_ATTR interruptHandler(); };
Of note here is that we explicitly ...