Nick Pettefar
Published © GPL3+

Cheap as Chips Chappy Checker

Detect people! The LED lights when someone is detected.

BeginnerShowcase (no instructions)1 hour2,561
Cheap as Chips Chappy Checker

Things used in this project

Hardware components

C.H.I.P.
C.H.I.P.
6 quid computer
×1
HC-SR501
PIR Human detector, cost one quid.
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1
5 mm LED: Yellow
5 mm LED: Yellow
×1

Software apps and online services

AdaFruit C.H.I.P. GPIO library

Story

Read more

Schematics

Wiring the thing

If you can't see the pin notations, pull the plastic dome off, they are usually under there!

Red wire goes to CHIP 5V, Black to CHIP Gnd and Blue to CHIP XIO-P0.

Connect the Yellow LED from CHIP Gnd to CHIP CSID0 (longest lead goes in CHIP CSID0).

Code

The Code!

Python
You need to install the AdaFruit C.H.I.P. GPIO library first of all. See here for instructions, usage guides and tips and other stuff: https://bbs.nextthing.co/t/adafruit-gpio-library-for-chip/2696

This Is What I Did:
sudo bash
apt-get update
apt-get install build-essential python-pip python-dev python-smbus git
git clone https://github.com/adafruit/Adafruit_Python_GPIO.git
cd Adafruit_Python_GPIO
python setup.py install
git clone git://github.com/xtacocorex/CHIP_IO.git
cd CHIP_IO
python setup.py install
cd ..
rm -rf CHIP_IO
#!/usr/bin/python
#
import CHIP_IO.GPIO as GPIO
import time
LED = "CSID0"
GPIO_PIR = "XIO-P0" (From the HC-SR501 Output pin.)
print "HC-SR501 Human Sensor test (press ctrl-C to quit)."
# Set LED pin as output
GPIO.setup(LED, GPIO.OUT)
GPIO.output(LED, GPIO.LOW)
# Set PIR pin as input
GPIO.setup(GPIO_PIR, GPIO.IN)
Current_State  = 0
Previous_State = 0
try:
 print "Waiting for PIR to settle down."
 # Loop until PIR output = LOW
 while GPIO.input(GPIO_PIR)==1:
   Current_State  = 0
 print "Scanning..."
 # Loop until user types ctrl-C
 while True :
   # Read PIR state
   Current_State = GPIO.input(GPIO_PIR)
   if Current_State==1 and Previous_State==0:
     # PIR is triggered
     print "  Human detected!"
     GPIO.output(LED, GPIO.HIGH)
     # Record previous state
     Previous_State=1
   elif Current_State==0 and Previous_State==1:
     # PIR has returned to ready state
     print "Scanning..."
     GPIO.output(LED, GPIO.LOW)
     Previous_State=0
   # Wait for 10 milliseconds
   time.sleep(0.01)
except KeyboardInterrupt:
 print "Goodbye"
 # Reset GPIO settings
 GPIO.cleanup()

Credits

Nick Pettefar

Nick Pettefar

2 projects • 1 follower
Unix biker Radio Ham bad Ukulele player.

Comments