Thanks for a nice tutorial. I'm just wondering. Can your code be modified to count pulses from a anemometer? There are like 20 pules in one revolution.
Yes, but I find you need a dedicated device just to do that or the results are not very accurate. I have a few videos from this one to one about ultrasonic measurement, and they all have accuracy problems if you ask the microcontroller to do more than count.
@@tsbrownie One more question, tsbrownie. In your comment, the code, where # Pin 7 = 3,3V photodiode OFF. Maybe I don't get it, but how come the photodiode is off when detecting HIGH on pin 7? ( after interrupt on rising ).
@@geirha75 It's been a long time so I'm not sure, but if I remember correctly., it works backward from what you expect. It's an easy experiment to try both ways to see.
Wow... thinking outside the box... The only way i can think of achieving this will be to print the count to serial, then use some kind of application to stream/save the serial data to mysql database.
Just to be clear... There is no way that GPIO.input(channel) result be anything else except 0 or 1 (True/False), right? Can't be (in any circumstances) betveen 0 and 1?
It should be true or false (0 or 1). But since you don't know the logic / code behind the test, you can not say for sure there is "no way" for it to be other. Python is famous for its approximate math. I have some videos on that also. Why risk crashing a billion dollar lander over some little oddity in the code? It happens.
Thanks for a nice tutorial. I'm just wondering. Can your code be modified to count pulses from a anemometer? There are like 20 pules in one revolution.
Yes, but I find you need a dedicated device just to do that or the results are not very accurate. I have a few videos from this one to one about ultrasonic measurement, and they all have accuracy problems if you ask the microcontroller to do more than count.
@@tsbrownie One more question, tsbrownie. In your comment, the code, where # Pin 7 = 3,3V photodiode OFF.
Maybe I don't get it, but how come the photodiode is off when detecting HIGH on pin 7? ( after interrupt on rising ).
@@geirha75 It's been a long time so I'm not sure, but if I remember correctly., it works backward from what you expect. It's an easy experiment to try both ways to see.
Can this setup be used to input the "count" amount into a mysql database? If so could you demonstrate?
Don't know, never tried it. Almost sounds like someone got a homework assignment. ;)
Wow... thinking outside the box... The only way i can think of achieving this will be to print the count to serial, then use some kind of application to stream/save the serial data to mysql database.
Just what i was looking for. Thank you so much.
You are welcome!
Nice explanation. I didn't see where you declared 'channel'.
Excellent point. The first parameter in the interrupt (the "7") is moved to the variable "channel".
GPIO.input(channel) > 0.5
Why 0.5 and not == 1? Isn't GPIO on RPi digital?
Thank you!
Because > 0.5 is more inclusive than ==1. I got caught in school on a trick my teacher played and I never forgot it.
Just to be clear...
There is no way that GPIO.input(channel) result be anything else except 0 or 1 (True/False), right?
Can't be (in any circumstances) betveen 0 and 1?
It should be true or false (0 or 1). But since you don't know the logic / code behind the test, you can not say for sure there is "no way" for it to be other. Python is famous for its approximate math. I have some videos on that also. Why risk crashing a billion dollar lander over some little oddity in the code? It happens.
OK, that's fine answer! Thank you!