ms-iot / pir-sensor

Code to help showcase using a PIR motion sensor on IoT Core
MIT License
11 stars 9 forks source link

PirSensor Event Handler not invoked #4

Closed baqwas closed 5 years ago

baqwas commented 7 years ago

I'm unable to get the motionDetected event handler invoked when there is motion in front of the HC-SR501 (PIR) sensor. I have used ms-iot examples for the PirSensor class and in a separate test cloned the GpioInterrupt example without any success. The same breadboard layout works fine with the equivalent (i.e. interrupt handling) in C++ and Python by swapping out the SD card. I have tried GPIO pins 26 and 6 (BCM numbers) without success for the sensor but Blinky (with the Timer event) works fine on these two pins.

I have tried the sensor with ActiveHigh and ActiveLow settings. For this particular model, ActiveHigh is the correct setting because that is the interpretation that I have in my test cases under Raspbian Jessie.

Any guidance available on debugging the GpioPinValueChangedEvent for a newbie user?

My W10 IoT Core tests have failed with five different HC-SR501 sensors and yet all of these work fine. Arduino Wiring will be my next test (since regular Arduino with interrupt handling is working fine) but some feedback on board level interrupt handling would be good education for me.

Thanks.

IoTGirl commented 7 years ago

Hi BaqWas, Have you looked at other IoT Core projects in the community that use a motion sensor? I did a quick search and found http://www.slideshare.net/andri_yadi/raspberry-pi-2-windows-10-iot-core-nodejs and they show a wiring diagram on slide 36 that might help. If you scroll through the slides further they also have a GitHub that you might leverage. Sincerely, IoTGirl

baqwas commented 7 years ago

Thanks for the quick heads-up. I did come across Andri’s article previously but there was no accompanying code for motion detection to emulate. Some of the other motion sensor articles specific for the Windows 10 IoT Core environment require other hooks and soak up more cycles than practical for this Hello Motion Sensor exercise. The Node.js app that is provided in the slide deck (to blink an LED) worked similarly me without any hiccups. The board layout for the motion sensor is similar to what I have – nothing on the breadboard except the motion sensor.

Although I have fully uninstalled and reinstalled VS 2015 Update 3 several times on the desktop, I suspect that there is something wrong with my understanding (and coding) of Event Handler for the PIRSensor class (using the PIRSensor class or GPIOInterrupt code in ms-iot/samples) in the Background task (headless) mode since the anomaly persists even on an alternate VM clean install of VS 2017 RC on Windows 10 Anniversary Update (and upon update to Insider Build 15031). It may turn out to be an operator error after all. But I will move on to other sensors now to chalk up the exercises that worked previously. Incidentally, Arduino Wiring app for the PIR sensor works fine in the same hardware configuration. And yes, I do revert to the Lightning drivers for Arduino Wiring and back to Direct Mapped for UWP.

Regards.

P.S. I have used the GPIOTestTool app from command line on both GPIO pins (26 & 6) but the findings indicate nothing is happening to the pins even when the state is being toggled – pin read commands do not change after explicit write commands.

From: IoTGirl [mailto:notifications@github.com] Sent: Thursday, February 23, 2017 02:52 To: ms-iot/pir-sensor pir-sensor@noreply.github.com Cc: Matha Goram baqwas@gmail.com; Author author@noreply.github.com Subject: Re: [ms-iot/pir-sensor] PirSensor Event Handler not invoked (#4)

Hi BaqWas, Have you looked at other IoT Core projects in the community that use a motion sensor? I did a quick search and found http://www.slideshare.net/andri_yadi/raspberry-pi-2-windows-10-iot-core-nodejs and they show a wiring diagram on slide 36 that might help. Sincerely, IoTGirl

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ms-iot/pir-sensor/issues/4#issuecomment-281932066 , or mute the thread https://github.com/notifications/unsubscribe-auth/AGvmF0cJedO5F5Yyf-lgVkV21rqZXRohks5rfUidgaJpZM4MJhXq .

saraclay commented 5 years ago

Closing this issue out as recent updates may have fixed this. If this is not the case, please file this issue at: www.github.com/MicrosoftDocs/windows-iotcore-docs