Further update.
The detector works fine powered from Raspberry Pi GPIO pins as expected.
However, the Raspberry Pi data connection didn't work as expected; no counts counted despite the detector clicking away.
I decided to add a simple decoupling capacitor - 100 nF in between the VIN output pin and the GPIO pin. Still no success when looking for either falling or rising edges. I thought the 'clicks' were likely being swamped by the software 'pull up' - and as soon as I disabled that it counts correctly.
An improved version of the program is below.
I also looked at the "Geiger Bot" iPad/iPhone program. It runs on an old iPad I had lying around, but not on current models. It has some excellent features which I will adapt for future Raspberry Pi programming, but a big downside that it does NOT use the audio cable even when plugged in - it just relies on the iPad microphone picking up the clicking noise, and will not cope with very fast rates. I need to experiment with decoupling and a correct cable (the device outputs a mono signal on L and R channels of a headphone socket; need to decouple that to the 2nd ring (microphone) of iPad input connector, I think.
My next problem is that I have reasonable indoor counts (eg 30/min), but outdoors I'm getting an outrageously high 100,000 counts/min. Explanation awaited but I'm bothered about that nearby recently disturbed ex-radioactive waste dump site. Maybe there's a correlation with wind direction and dust particle counts. Luckily I'm acquiring all the monitoring gear!
Code: Select all
# Raspberry Pi connection:
# Maybe the code can be optimized but it works and that's good.
# VIN = INT connected to pin#12 via a 100nF decoupling capacitor
# 5V to pin#2
# GND to pin#6
import time
from datetime import datetime
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD) # use RaspPi board layout pin numbering
GPIO.setup(12, GPIO.IN) # Only works if do NOT have a pull up or down
counter = 0
def tube_impulse_callback(channel): # threaded callback -- falling edge detected
global counter # make counter global to be able to increment it
counter+=1
# print("Click",counter,"!") # disabled to hide display of individual clicks
# when a falling edge is detected on pin#12, regardless of whatever
# else is happening in the program, the tube_impulse_callback will be run
GPIO.add_event_detect(12, GPIO.FALLING, callback=tube_impulse_callback)
try:
while True:
currentMinute = datetime.now().minute
while datetime.now().minute == currentMinute: # this minute..
time.sleep(1) # .. wait while add_event_detect detects pulses
print("Minute",currentMinute, ":", counter,"/min")
counter=0 # reset counter
except KeyboardInterrupt:
GPIO.cleanup() # clean up GPIO on CTRL+C exit
except:
GPIO.cleanup() # clean up GPIO on normal exit
You do not have the required permissions to view the files attached to this post.