When using the following code to read pulses from this sensor
import time
import datetime
import RPi.GPIO as GPIO
from collections import deque
counts = deque()
usvh_ratio = 0.00812037037037 # This is for the J305 tube
geigerChannel = 7
# https://sourceforge.net/p/raspberry-gpi ... asicUsage/
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(True)
# This method fires on edge detection (the pulse from the counter board)
def countme(channel):
global counts
timestamp = datetime.datetime.now()
counts.append(timestamp)
# Set the input with falling edge detection for geiger counter pulses
GPIO.setup(geigerChannel, GPIO.IN)
# https://sourceforge.net/p/raspberry-gpi ... ki/Inputs/
GPIO.add_event_detect(geigerChannel, GPIO.FALLING, callback=countme)
loop_count = 0
# In order to calculate CPM we need to store a rolling count of events in the last 60 seconds
# This loop runs every second to update measurements and removes elements from the queue
# that are older than 60 seconds
while True:
loop_count = loop_count + 1
try:
while counts[0] < datetime.datetime.now() - datetime.timedelta(seconds=60):
counts.popleft()
except IndexError:
pass # there are no records in the queue.
if loop_count == 10:
# Every 10th iteration (10 seconds), store a measurement in Influx
measurements = [
{
'measurement': 'sensor',
'fields': {
'cpm': int(len(counts)),
'usvh': "{:.2f}".format(len(counts) * usvh_ratio)
}
}
]
print(measurements)
loop_count = 0
time.sleep(1)
the following error occurs
GPIO.add_event_detect(2, GPIO.FALLING, callback=impulse) # определение внешнего прерывания
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Failed to add edge detection
how can it be solved if I have already tried to use other functions of this library, nothing helps. Although before reinstalling the OS this code worked more than correctly, but after updating the OS no.
import time
import datetime
import RPi.GPIO as GPIO
from collections import deque
counts = deque()
usvh_ratio = 0.00812037037037 # This is for the J305 tube
geigerChannel = 7
# https://sourceforge.net/p/raspberry-gpi ... asicUsage/
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(True)
# This method fires on edge detection (the pulse from the counter board)
def countme(channel):
global counts
timestamp = datetime.datetime.now()
counts.append(timestamp)
# Set the input with falling edge detection for geiger counter pulses
GPIO.setup(geigerChannel, GPIO.IN)
# https://sourceforge.net/p/raspberry-gpi ... ki/Inputs/
GPIO.add_event_detect(geigerChannel, GPIO.FALLING, callback=countme)
loop_count = 0
# In order to calculate CPM we need to store a rolling count of events in the last 60 seconds
# This loop runs every second to update measurements and removes elements from the queue
# that are older than 60 seconds
while True:
loop_count = loop_count + 1
try:
while counts[0] < datetime.datetime.now() - datetime.timedelta(seconds=60):
counts.popleft()
except IndexError:
pass # there are no records in the queue.
if loop_count == 10:
# Every 10th iteration (10 seconds), store a measurement in Influx
measurements = [
{
'measurement': 'sensor',
'fields': {
'cpm': int(len(counts)),
'usvh': "{:.2f}".format(len(counts) * usvh_ratio)
}
}
]
print(measurements)
loop_count = 0
time.sleep(1)
the following error occurs
GPIO.add_event_detect(2, GPIO.FALLING, callback=impulse) # определение внешнего прерывания
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Failed to add edge detection
how can it be solved if I have already tried to use other functions of this library, nothing helps. Although before reinstalling the OS this code worked more than correctly, but after updating the OS no.
Statistics: Posted by zatomaks — Fri Sep 06, 2024 10:35 am