Monday, 5 June 2017

ZeroView IR-Cut hack

This is hopefully the beginning of something beautiful...  This a ZeroView, which is a neat way to attach a Raspberry Pi zero-W + camera module to a window:


I've modified modified the ZeroView (+IR camera module) to squeeze in an infra-red cut filter (IR-cut) between the ZeroView and the PiZero, making a wifi enabled 8MP camera that can see in the dark (+IR illumination)...


This is still very much a work in progress as I need to add an IR illumination source too.  Some incarnation of this will find its way into a nest box or a trail camera.  As-is it does stay stuck to a window, but the addition of the perfboard does make it a bit top-heavy.  I'm sure it can be refined a bit...

IRcut OFF (top) & ON (bottom)

Here is a video showing filter on and off.  This was captured using PikrellCam:


Filter is switched using a L293DNE, connected in the above example as follows:


Sample python script:
import RPi.GPIO as GPIO
import time
import datetime as dt
import os

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.cleanup

IRcutEnable=13
IRcut1A=6
IRcut2A=9

IRcutPins=[13,6,9]
for IRcutPin in IRcutPins:
    GPIO.setup(IRcutPin,GPIO.OUT)

#Default states:
global IR_cutState
IR_cutState="not_set"

def separator():
    print "---------------------------"

def IRcut_DayTime():

    print "IR cut DAY"
    print "============="
    GPIO.output(IRcutEnable,GPIO.HIGH)
    GPIO.output(IRcut1A,GPIO.LOW)
    GPIO.output(IRcut2A,GPIO.HIGH)
    print "IRcutEnable ("+str(IRcutEnable)+") = HIGH"
    print "IRcut1A ("+str(IRcut1A)+") = LOW"
    print "IRcut2A ("+str(IRcut2A)+") = HIGH"
    print ""
    
    global IR_cutState
    IR_cutState="IRcut_DAY"
    time.sleep(0.5)

def IRcut_NightTime():    

    print "IR cut NIGHT"
    print "============="
    GPIO.output(IRcutEnable,GPIO.HIGH) #was LOW
    GPIO.output(IRcut1A,GPIO.HIGH)
    GPIO.output(IRcut2A,GPIO.LOW) #was HIGH
    print "IRcutEnable ("+str(IRcutEnable)+") = LOW"
    print "IRcut1A ("+str(IRcut1A)+") = HIGH"
    print "IRcut2A ("+str(IRcut2A)+") = L"
    print ""
    
    global IR_cutState
    IR_cutState="IRcut_NIGHT"
    time.sleep(0.5)

def IRcut_STOP():    

    print "STOP"
    GPIO.output(IRcut2A, GPIO.LOW)
    time.sleep(2)

while True:
 IRcut_NightTime()
 time.sleep(2)
 IRcut_DayTime()
 time.sleep(2)