I am trying to get the falling edge of a HB100 doppler radar with a Lm358 amplifier module.
The error is RuntimeError: Error waiting for edge
It was working great and stopped suddenly.
I have already tried with another radar and amplifier modules and the error continues. I have tried to switch the GPIO pins with no success.
The code is below
I am using Raspberry-Pi 4 and Python11
The error is RuntimeError: Error waiting for edge
It was working great and stopped suddenly.
I have already tried with another radar and amplifier modules and the error continues. I have tried to switch the GPIO pins with no success.
The code is below
I am using Raspberry-Pi 4 and Python11
Code:
import RPi.GPIO as GPIOimport timeGPIO.cleanup()AMPLIFICADOR_INPUT_PIN = 23GPIO.setmode(GPIO.BCM)GPIO.setup(AMPLIFICADOR_INPUT_PIN, GPIO.IN)MAX_PULSE_COUNT = 10MOTION_SENSITIVITY = 10def count_frequency(GPIO_pin, max_pulse_count=10, ms_timeout=50): start_time = time.time() pulse_count = 0 for count in range(max_pulse_count): edge_detected = GPIO.wait_for_edge(GPIO_pin, GPIO.FALLING, timeout=ms_timeout) if edge_detected is not None: pulse_count += 1 duration = time.time() - start_time frequency = pulse_count / duration return frequencywhile True: doppler_freq = count_frequency(AMPLIFICADOR_INPUT_PIN) speed = doppler_freq / float (31.36) print (speed) if (speed>2): print ('high Speed'+ "Your speed="+ str(speed) +'Mph') if doppler_freq < MOTION_SENSITIVITY: print("No motion was detected") else: print("Motion was detected, Doppler frequency was: {0}".format(doppler_freq)) GPIO.cleanup()
Statistics: Posted by guidupas — Fri Apr 26, 2024 3:16 pm — Replies 0 — Views 20