SensorMonitor interrupt switch example

Overview

In this tutorial we will make use of  a library called SensorMonitor available on Github. This example builds on a previous example by adding an interrupt handler  to force an immediate update of the switch state. This is useful when for example you are building an alarm system and you need to update a remote system that there was entry or movement. Without having the interrupt in place and your poll time was too long, you might have missed the switching event. For example an intruder could have quickly opened and closed the door, and you might have missed that event if the next polling would have only happened in – let’s say – 1 minute.

 

Prerequisites

Nothing special required besides the required components.

Source Code

The source code for this project is available on my GitHub Repository.

Required Components

  • Arduino
  • Push button
  • 1K Resistor
  • A breadboard might be useful if you don’t want to solder
Arduino UNO with push button
Arduino UNO with push button

Running the code

git pull https://github.com/trojanc/learn-arduino
cd learn-arduino/sensor-monitor-switch-interrupt
platformio init
platformio run --target run
platformio device monitor

For more information about the library used in this example see the SensorMonitor Github Repository

Leave a Reply

Your email address will not be published. Required fields are marked *