HC-SR50 Motion sensor at 3.3v & whisper node low power

I recently found this tutorial to convert the HC-SR501 PIR Motion sensor, to allow it to run on 3.3V, so I thought I would give it a try, to use it with my whisper node, and make it count the amount of people passing the sensor, trying to make it run on a coincell battery.

Test Setup

IMG_2513 IMG_2511

I madeĀ a test sketch, blinking one of the leds on the whisper node

 

int ledPin = 6; 
int motionPin = 16; 

void setup() {
  
  pinMode(ledPin, OUTPUT);
  pinMode(motionPin, INPUT);
 
  digitalWrite(ledPin, LOW);
  
}

void loop() {
  if(digitalRead(motionPin) == HIGH)
  {
    digitalWrite(ledPin, pirValue);
  }
}

Trigger Modes

The lowest delay between motion detection is 5 seconds.
The first thing I noticed is that it uses the repeatable trigger mode.
This means if it detects motion, the output pin will go high for 5 seconds, whenever motion is detected within these 5 seconds the 5 second delay will restart.

I would prefer using single trigger mode, in single trigger mode it would stop sensing motion untill the 5 second delay is done, this way I wouldn’t miss too many people passing my sensor.

I tried soldering the wire to the L pad, since this is normally the single trigger mode on the HC-SR501 version with a jumper, but with no luck, tried everything, untill I broke one of my HC-SR501 sensors, and then gave up on single trigger mode, I guess I should be happy I got the sensor working on 3.3v šŸ™‚ but if anyone managed to get single trigger mode working let me know!

Soldered Protoboard Version

Since I want to place one of these versions somewhere I made a small pcb to connect the whisper node and HC-SR501 (I would normally prefer female header pins, but I ran out :(, so I soldered the node and sensor directly to the pcb with male header pins.

I noticed the Motion detector has a pretty wide detection angle, since I want to count people walking past the sensor, I decided to tape off the dome, so it will only go off when people really pass the sensor.

IMG_2516Ā IMG_2516

Low Power Using Interrupt

To use the lowest amount of energy I will put the whisper node in sleep mode, Ā listening for an interrupt on pin D3, when the pir sensor detects motion the output pin will go HIGH waking up the whisper node, which will continue the sketch from where it went to sleep.

In this test sketch I will wake the whisper node up on interrupt and blink the led, to visually see that the motion has been detected:

#include <LowPower.h>

void blinkLed(){
  digitalWrite(6, HIGH);
  delay(10);
  digitalWrite(6, LOW);
}

void setup(){
 pinMode(pirPin, INPUT); 
  pinMode(6, OUTPUT);
  attachInterrupt(digitalPinToInterrupt(pirPin), blinkLed, RISING);
}

void loop(){
  delay(2);
  LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
}

With my final sketch where I also send the data to a base stationĀ I got it down to 93uA in sleepmode

IMG_2524

Leave a Reply

Your email address will not be published.