PIR Motion Sensor returns wrong values

Hi,

I have PIR Motion Sensor with old GrovePi, see photos on http://imgur.com/a/pEUt7.

When I run grove_pir_motion_sensor.py sample script it prints “Motion Detected” few times and then “-” few times. Those values are flapping all the time every ~0.5-1.3 sec. I tried putting a sensor towards a wall or waving for longer time, but output doesn’t change.

Do you have any idea why the sensor doesn’t recognize motion properly?

Thanks,
Marcin

P.S. I’m attaching output from grove_pir_motion_sensor.py script and troubleshooting logs.txt with hardware info.

Hey marcin,
Can you run the troubleshooting script a couple of times and upload the logs here. Also, can you upload a picture of your setup.

-Karan

Hi Karan,

Thanks for reply. I already shared photos with previous post: http://imgur.com/a/pEUt7

I’ll attach more logs in few hours when I’ll have more time.

Best Regards,
Marcin

Hi Karan,

I’m attaching logs from several runs, but unfortunately they don’t differ.
You can see photos os setup here: http://imgur.com/a/pEUt7

Any idea what might be wrong?

Thanks,
Marcin

Hey Marcin,
Looks like there is some problem with the firmware on your grovepi. You can try this example and check that https://github.com/DexterInd/GrovePi/blob/master/Software/Python/grove_firmware_version_check.py. The firmware version is being reported as 255.255.255 instead of 1.2.2 You’ll have to do a firmware update on it. Can you follow the guide here: https://docs.google.com/document/d/1fe2uCjoLpAE6Vt2HS28n_dhSfbVXZ1p-PhG1aEvIQSM/edit. Here is another forum thread where people had solved a similar problem: http://www.dexterindustries.com/topic/grovepi-firmware-update-v1-2-2/page/2/#post-79976.

Do let us know if this works.

-Karan

Hi Karan,

I have good and bad news :).

Bad news are that firmware update didn’t solved my issue.
I can now see new version:
GrovePi has firmware version: 1.2.2
Update was successful (see attached logs), but motion sensor was behaving the same.

Good news are that motion sensor started working after connecting to port D7. I checked multiple times the source code:

# Connect the Grove PIR Motion Sensor to digital port D8
# SIG,NC,VCC,GND
pir_sensor = 8
....
motion=grovepi.digitalRead(pir_sensor)

Any idea why it’s working on D7 port instead of D8?

Thanks,
Marcin

Hey marcin,
Great to hear that the PIR motion sensor is working for you. It might be working on D7 with the code stating D8 because there are 2 pins in D7 port (7,8). Most of the sensors use pin7 so it corresponds to the same name as that of the port. Can you try out another port like D5, where the pin number should be 4. Can you also post a picture of the sensor.

-Karan

Hi Karan,

I uploaded sensor photos to: http://imgur.com/a/BcnYq

Is pin number the value passed to grovepi.digitalRead method?

If yes, then after connecting motion sensor to port D5:

  • pin 4 returns always 0,
  • pin 5 returns random values,
  • pin 6 works correctly.

Thanks,
Marcin

Hey Marcin,
Can you post a picture of the bottom side of the sensor too, where the pinout is mentioned. Yes the pin number is passed to digitalRead. Can you repeat this test on Port D6 and D7 too. I expect pin 7 to work on port D6 amd pin 8 to work on port D7.

-Karan

Hi Karan,

You can find 2 photos on http://imgur.com/a/BcnYq, one of the top and second one of the bottom of the sensor.

Yes, pin 7 works with port D6, and pin 8 works with port D7.

Thanks,
Marcin

Hey Marcin,
It looks like the grove PIR sensor comes in two variants, one with the sensor out connected to the yellow wire and the other with the sensor out connected to the white wire, which is why you are getting the readings on the other port. We’ll update the documentation on github.

-karan