Close

Motion Sensor

A project log for Desk Buddy

A small device that lets work colleagues know if you'll be at your desk today so they know if they can sit there.

tony-kambourakisTony Kambourakis 05/14/2017 at 01:400 Comments

The motion sensor detects the presence of a visitor on a day that I am not in the office. This will trigger a welcome message and appropriate informational feeds to the display throughout the day with a reminder to clean up the desk at the end of the day.

The HCSR501 PIR Passive Infra Red Motion Sensor is powered by 5V but includes a 3.3V output level.

The motion sensor output is connected to the NodeMCU D7 pin. The pin is set as an input and attached to an interrupt that detects a rising edge.

#define MOTIONSENSORPIN D7 // D7 = GPIO13

void setup() {
  pinMode(MOTIONSENSORPIN, INPUT);
  attachInterrupt(MOTIONSENSORPIN, motionSensorActivated, RISING);
}

void motionSensorActivated() {
  motionSensorDetected = true;
  motionSensorDetectedCount += 1;
}

Discussions