I want to build a circuit as simple as possible in order to detect the ambient light level.
It is going to be run by an RPiZero-W which right now also reads and logs a DS18B20 temperature sensor.
It is going to be used for switching on/off outdoor tree lighting etc.
The switching of the lighting is already taken care of, right now I have it running on a schedule with fixed on/off times.
But since the sun rise/set times change a lot from now until March I want to use a crude light detector with some way to adjust the switching level.
After googling a bit I found this Youtube video from 2019 where the detection is simply done by hooking the photo resistor and a capacitor to an RPi GPIO pin with the capacitor between GND and the pin and the photo resistor between the pin and 3V3 supply.
The idea seems to be to set the pin as a 0V output to empty the capacitor and then switch the pin back to input and time how long it takes to get to a high state.
But he uses Python code to do it and I would rather not use Python, which I am not familiar with.
Can this be done directly in a shell-script instead using the raspi-gpio functions available in PI-OS?
I need to switch the pin from input to output and set it to 0 to discharge the capacitor, then back to input and wait for it to get high and then read the time it took, probably in milli/micro-seconds.
It is going to be run by an RPiZero-W which right now also reads and logs a DS18B20 temperature sensor.
It is going to be used for switching on/off outdoor tree lighting etc.
The switching of the lighting is already taken care of, right now I have it running on a schedule with fixed on/off times.
But since the sun rise/set times change a lot from now until March I want to use a crude light detector with some way to adjust the switching level.
After googling a bit I found this Youtube video from 2019 where the detection is simply done by hooking the photo resistor and a capacitor to an RPi GPIO pin with the capacitor between GND and the pin and the photo resistor between the pin and 3V3 supply.
The idea seems to be to set the pin as a 0V output to empty the capacitor and then switch the pin back to input and time how long it takes to get to a high state.
But he uses Python code to do it and I would rather not use Python, which I am not familiar with.
Can this be done directly in a shell-script instead using the raspi-gpio functions available in PI-OS?
I need to switch the pin from input to output and set it to 0 to discharge the capacitor, then back to input and wait for it to get high and then read the time it took, probably in milli/micro-seconds.
Statistics: Posted by Bosse_B — Mon Dec 02, 2024 12:09 pm