I need to find a solution for my project. Basically I just need to define if there is a voltage or not by using GPIO event detection.
For my basic scheme I used 3.3v pin and one of the GPIO pin for the pull_down input:
GPIO.setmode(GPIO.BCM)
GPIO.setup(24, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.add_event_detect(24, GPIO.RISING, callback=rising_callback, bouncetime=200)
That code worked fine for me. However, I want to make possible to detect voltage up to 16.5v. I don't need to read its exact value.
How can I setup everything so the 'add_event_detect' will run a callback if some voltage is received?
Some notes: I'm using Pi-3 b+. I also have an ADC0832 and a Voltage Sensor. And I know how to use the ADC to read the exact voltage. But I don't like to run a loop to always read the ADC value to define if there is some voltage. Also it is possible that the voltage will appear for a very short period of time, so I can't add a delay between ADC readings. Also I want to avoid the situation when the voltage is lower than 3v so the event detect might not trigger the callback (this is why and don't like a solution to reduce high voltage by using a voltage divider). I wonder if it is possible to use the ADC and the sensor with the event_detection to trigger a callback if there is a 0.5-16.5v voltage received without using 'read_adc_value' loop.