Raspberry Pi Code does nothing...
Discussion
Hi
I have trying to connect a two wire reed switch anemometer to a Raspberry Pi to measure windspeed.
The project below has given me some code which I have created, but when I run it, nothing happens, literally nothing, the terminal window just returns to root. Can anyone point me in the direction of where I might have gone wrong?
Project:https://projects.raspberrypi.org/en/projects/build-your-own-weather-station/5[url]
Code:
|https://forums-images.pistonheads.com/49602/202502155348807[/url]
Result from running it:

I have trying to connect a two wire reed switch anemometer to a Raspberry Pi to measure windspeed.
The project below has given me some code which I have created, but when I run it, nothing happens, literally nothing, the terminal window just returns to root. Can anyone point me in the direction of where I might have gone wrong?
Project:https://projects.raspberrypi.org/en/projects/build-your-own-weather-station/5[url]
Code:
Result from running it:
It has no code to make it wait for a button press, so just runs and immediately exits. Normally there would be a while loop or similar that waits forever
If you can find a demo project from the button library, copy that and add your code into it
If you can find a demo project from the button library, copy that and add your code into it
Edited by essayer on Saturday 15th February 17:49
It occurred to me the instructions were telling me to write it in Idle or similar on the Pi, and I was writing it via Terminal on the Mac.
I plugged a monitor into the Pi and opened Thonny which told me there was a problem with the tabs on lines 7, 8 & 9. I have corrected that and I now get this mess:


ETA: Searching seems to suggest the GPIO is already in use, and running gpioinfo brings up all the pins and showed 5 as in use, restarting the Pi and it is no longer in use, but I am now back to the code doing nothing again...

ETA2: It seems my pin out diagram was wrong for my Pi and I was connected to what I thought was GPIO 5, but in all likelihood was GPIO 24 because connecting to a different pin, I have now got the script to count spins, but it will only do it in Thonny, not through the terminal window, I suspect this is because the code is incomplete. I shall carry on reading the project now I have got that part to work.
I plugged a monitor into the Pi and opened Thonny which told me there was a problem with the tabs on lines 7, 8 & 9. I have corrected that and I now get this mess:

ETA: Searching seems to suggest the GPIO is already in use, and running gpioinfo brings up all the pins and showed 5 as in use, restarting the Pi and it is no longer in use, but I am now back to the code doing nothing again...

ETA2: It seems my pin out diagram was wrong for my Pi and I was connected to what I thought was GPIO 5, but in all likelihood was GPIO 24 because connecting to a different pin, I have now got the script to count spins, but it will only do it in Thonny, not through the terminal window, I suspect this is because the code is incomplete. I shall carry on reading the project now I have got that part to work.
Edited by Megaflow on Saturday 15th February 16:20
Edited by Megaflow on Saturday 15th February 16:31
frisbee said:
Are you running it in IDLE? You would need some sort of shell to see any output from the call back you've assigned to the GPIO.
I am now running it in Thonny, similar to Idle, and I can see the output in Shell, that enabled me to get the script to count spins and see them.ETA: Much messing around, not actually sure I know what I am doing and we have a code that runs in terminal on the Mac:

Sadly I have got no idea if it is accurate or not because the eBay seller, who claimed to be in Ireland, but was actually in Hong Kong and took 3 weeks to deliver the anemometer has failed to provide any kind of calibration data for it and it seems to produce more than 1 actuation per rotation, so I need to work out a way of calibrating it. That is a challenge for another day.
Edited by Megaflow on Saturday 15th February 17:30
Gassing Station | Computers, Gadgets & Stuff | Top of Page | What's New | My Stuff