Motion Sensor Always On

Using a Raspberry Pi 3 with the 4.4 Kernel.

After hooking up the Motion Sensor it always remains at 1 or the On state. It never goes to 0 even if I completely shield it from light or any movement.

It’s happening both on the online dashboard and the iOS app

Out of curiosity, what pin on the Pi do you have it wired to?

Pin 17

Hi @julian,

Are you using resistor with your motion sensor?


I have the same issue, either I have a bad HC-SR501, or my NodeMCU doesn’t like the pin.

try changing pins. As I remember, ESP8266 itself only offers 2 real pins. NodeMCU seems to offer more digital pins to use

1 Like

I am not using a resistor. I’m hooking it up exactly as shown in the tutorial. Tutorial - Cayenne - myDevices

Hey @julian, I know in our other troubleshooting you were using MQTT. Is this the case on this Pi as well? I ask because it’s a fairly simple system of sending and receiving sensor values, so I wonder if it would be good to troubleshoot by logging each of the motion sensor values to the console right as they are sent to Cayenne.

The idea being to find out if this is a wiring/hardware/sensor code issue where the motion sensor isn’t even sending Cayenne a 0 value to work with (so of course we would show all 1’s) or if your agent is publishing a 0/OFF state and for some reason on our end we’re not changing the widget state properly.

This time I’m not using MQTT. I simply followed the tutorial and then added the device on the dashboard.

Hi @julian,

I think a good test would be to run this python code on the Pi while monitoring the Cayenne widget as well. All it does is loop and check to see what value it’s getting from the Motion Sensor and print it to the console. Just save it to a file named something like and run with python

import RPi.GPIO as GPIO
import time
GPIO.setup(11, GPIO.IN)         #Read output from PIR motion sensor
while True:
       if i==0:                 #When output from motion sensor is LOW
             print "No intruders",i
       elif i==1:               #When output from motion sensor is HIGH
             print "Intruder detected",i

In my case, the motion sensor widget in Cayenne and the console output match up exactly. If they do for you, then I imagine Cayenne is just happily reporting what it is getting from the device, even if that is all 1’s. In that case I’d be more suspect of the sensor itself or its wiring. If they differ, it could be something on our end.

Speaking of wiring, you mentioned you had a resistor in place, but do you know what resistor type you’re using? In my case, and the tutorial image, it’s a 100 ohm resistor (brown/black/brown/gold). I’ll admit I’m not as good with electrical stuff as I am with software to know if a different resistor here would make a difference, but just so we can compare setups. :slight_smile:

I am getting all 1’s. It might be the wiring. I did not see a resistor in the aforementioned tutorial so I did not use one. Am I looking at the wrong thing? Should I have a resistor?

I also don’t think the hardware is broken as I tried it with 3 different sensors (all the same model)

In the Technical specs it says that it sometimes doesn’t play well with the Raspberry Pi 3, which I have. Could this be the issue?

HI @julian,

I see now. I suspect the tutorial page you linked earlier has an error. I think you need the resistor. Here is the instructions I was using to set mine up, which is what I’m going to suggest we change that tutorial to:

Also, silly question, but if you remember – how did you get to that page you linked a week ago? It’s clearly got an error, but I can’t figure out where it was linked on our website.

I tried it with a 100 ohm resistor but that hasn’t changed anything. I ran the code again as well and it still outputs all 1’s.

I found the tutorial by searching “motion sensor tutorial mydevices cayenne” on Google. It showed up as the first hit.

Hmm… that’s really strange. I’d say maybe it is the Pi 3 thing you read about, but my tests above were all on a Pi 3 as well.

I think where I’d go next is through the items on Adafruit’s page for the device. In those Connecting and Testing sections they talk about using a 10K resistor (this wasn’t necessary for me) and adjusting sensitivity if you’re not getting variable output. These seems like the next best things to play with to see if you can get an alternating output, at which time I’m sure Cayenne would pick up on it.

Hey, I got it to work. Turns out all 3 sensors I bought were faulty. What are the odds.

Sorry to make you go through so much trouble when the problem was on my side.


It’s no worry at all, I’m here to help troubleshoot. And every time I walk through these things I learn something about the platform and find potential bugs and improvements. So it was a learning experience for me too :slight_smile:

Glad to hear things are working OK now, sometimes sourcing these electronic components can be a pain with all of the different distributors/manufacturers.

1 Like