- Basic setup & Power
- PIR sensor
- IR lamp
- IR filter
- Completed pics, improvements and parts list
The first main alteration has been to swap out the pi model A for a pi zero, partly to save power and partly to save space.
The main board is set up for a 26 pin header and not the 40 pin of the pi zero, so for the time being I’ve chopped a section out of a spare 26pin connector so that it fits. I intend to convert the whole setup to 40 pins in time.
The pyhon prog that controls the light is a massive mess so I’ve streamlined it a bit after some further reading form mod my pi. This is a lower resource bit of code and I’ve also incorporated the date time module so that it doesn’t waste battery power turning it on it the daylight.
Initial results weren’t too good so I’ve tinkered with it a bit and will continue to do so until it works as required.
#!/usr/bin/python import RPi.GPIO as GPIO import time import datetime #setup date and time vars now = datetime.datetime.now() dusk="2130" dawn="0500" # Set pins to BCM GPIO.setmode(GPIO.BCM) #PIR setup #set up PIR pin PIR_PIN = 22 #set PIR pin as input GPIO.setup(PIR_PIN, GPIO.IN) #relay setup # Set relay pin GPIO_LIGHT_ON = 17 # Set relay pin as output GPIO.setup(GPIO_LIGHT_ON,GPIO.OUT) def MOTION(PIR_PIN): print "motion detected" if now.strftime("%H%M") > dusk or now.strftime("%H%M") < dawn: GPIO.output (GPIO_LIGHT_ON,1) print "light on" time.sleep(10) while GPIO.input(PIR_PIN)==1: time.sleep(10) GPIO.output (GPIO_LIGHT_ON,0) print "Light off" print "motion stopped" print "PIR Module test press Ctrl+C to exit" time.sleep(2) print "ready" try: GPIO.add_event_detect(PIR_PIN, GPIO.RISING, callback=MOTION) while 1: time.sleep(100) except KeyboardInterrupt: print "quit" GPIO.cleanup()
After fitting the lens in front of the filter I began to get lens glare. After a bit of experimenting I ended up turning the lens round so that the glass touched the end of the filter tube and the back end of the lens created a hood.
Initially the pi had 3 buttons, temporarily fitted to a small breadboard. When the pi is setup outside it is put in position then the “reboot wifi” button is pressed to re-establish a link to the network.
In practice this soon became an issue as the buttons had to be forced in to the enclosure then the lid screwed on, resulting in lost screws and accidental shutdown by pressing a wrong button.
The box now sports a lovely maplin waterproof switch – this operates the wifi reboot and nothing else (the led to signal that it has worked is fitted in the box). Overall, much easier to use.
The light from the lamp has been disappointing recently. It could be due to a variety of reasons including the angle (it is fitted to look downwards), battery voltage (it needs 12v but is getting 8.4v max from the rechargeable) & the settings within pikrellcam (e.g. white balance, night etc).
I had another kit so I’ve built it and swapped out the 220 ohm resistors for 100 ohm, based on information and calcs via ledcalc.net. Whist buiding the kit I took the opportunity to modify the way the lamp connects as the soldered joints were prone to detaching and multiple resolders have messed up the solder pads. Finally, I’ve changed the angle on it so that the downward angle is reduced.
It remains to be seen if this helps!
it does – the video below was taken with the altered lamp and offers a significant improvement over the old. I just need to sort the white balance out (I’ve converted this to B&W to try and reduce the effect but it still “pulses”)