Closed seamusdemora closed 2 years ago
I thought it was just RPi.GPIO, but I could be incorrect. You might try installing a GUI-based system as that should take care of it.
No - that's incorrect. Never mind, I'll sort it. Apologies for the bother
OK - when you do get it worked out if you could let me know what you did, I would very much appreciate it!
Aptly enough it's called gpio
- aka "the GPIO utility". It's included with the Wiring Pi library. Most importantly, you should know that 1) it is now deprecated by its author, and 2) the version of Wiring Pi you get from the "official" Raspberry Pi repo does not support the Raspberry Pi 4B (though the author has provided some "non-standard" upgrade instructions).
You really should read through all of this - it impacts your GitHub info.
Thanks for the info. Did you eventually get things working?
Get the source code for WiringPi from
https://github.com/WiringPi/WiringPi
It will work with the pi 4 as normally expected..
I used raspi-gpio set 3 op dh
and it works for me without any additional libraries.
@JeremySCook : Yes, all is well with WiringPi - at least for now. It remains to be seen if the team at WiringPi will "keep the ball rolling" in Gordon's absence, but I am hoping for the best. As for now, with the RPi 4B hardware, Gordon's patch has bought the team some time.
That said, I'd suggest this thread has served its purpose, and so I'm recommending closure.
Oh - one other thing: If you're interested in collaborating on a couple of small hardware projects, please let me know. I liked what you did with the board you created for the "fan project" :)
You don't need any library to control simple fan on/off based on temperature. When you enable fan gpio using raspi-config or UI, it will add an entry in /boot/config.txt file: dtoverlay=gpio-fan,gpiopin=18,temp=60000
Even though the lower temperature limit you can set using raspi-config or UI is 60°C, you can bypass this limit by modifying the config.txt manually. I modified it like below: dtoverlay=gpio-fan,gpiopin=18,temp=45000
I tested on Raspberry Pi 4 with raspios-lite 64 bit in headless mode. My Noctua fan starts automatically at 45°C and stops at 35°C.
Notes: • dtoverlay can also be set in /boot/cmdline.txt. Documentation for overlays is available at /boot/overlays/README • GPIO Zero is the officially supported library for manipulating gpios by raspberry pi and installs by default on desktop os. • pigpio is another C/C++ based third-party gpio library mentioned in official docs. It could be used as an alternative to WiringPi in case the fork is deprecated as well.
I used
raspi-gpio set 3 op dh
and it works for me without any additional libraries.
Even though you can use raspi-gpio directly, it is not recommended to use it through programs/scripts. It writes directly to the registers. The recommended purpose of raspi-gpio is testing/debugging. You can check it using the command: raspi-gpio help
@ar51an That's fantastic info, thanks so much!
Even though you can use raspi-gpio directly, it is not recommended to use it through programs/scripts.
Just out of curiosity: Whose recommendation is this?
If you ran the command (raspi-gpio help) I mentioned in my comment you might have got the answer. It is the raspi's own recommendation. Pasting the output of the command for reference:
"WARNING! raspi-gpio set writes directly to the GPIO control registers ignoring whatever else may be using them (such as Linux drivers) - it is designed as a debug tool, only use it if you know what you are doing and at your own risk! ..."
You don't need any library to control simple fan on/off based on temperature. When you enable fan gpio using raspi-config or UI, it will add an entry in /boot/config.txt file:
dtoverlay=gpio-fan,gpiopin=18,temp=60000
Even though the lower temperature limit you can set using raspi-config or UI is 60°C, you can bypass this limit by modifying the config.txt manually. I modified it like below:
dtoverlay=gpio-fan,gpiopin=18,temp=45000
I tested on Raspberry Pi 4 with raspios-lite 64 bit in headless mode. My Noctua fan starts automatically at 45°C and stops at 35°C.
Notes:
• dtoverlay can also be set in /boot/cmdline.txt. Documentation for overlays is available at /boot/overlays/README
• GPIO Zero is the officially supported library for manipulating gpios by raspberry pi and installs by default on desktop os.
• pigpio is another C/C++ based third-party gpio library mentioned in official docs. It could be used as an alternative to WiringPi in case the fork is deprecated as well.
Excited to try this out. I finally am gonna buy a 3 pin PWM fan to do this. Does this fix still work? Has anyone else tried it? I'm running the official 64-bit release of Raspberry Pi OS on 8GB Raspberry Pi 4B. Thanks.
@bigbucketboy You are correct about not necessarily needing this script, though I don't think that was the case when I came up with this. Didn't realize you could modify it to come on under 60º. Very cool!
@JeremySCook Well that's awesome. Thanks for your reply. Your work is great and has helped me with a few projects of mine. Not sure if this is something you can update in your post here at https://www.embeddedcomputing.com/technology/processing/compute-modules/raspberry-pi-os-fan-control for anyone else interested in this project as well. It's really a game changer. Thanks again!
@bigbucketboy Well thanks so much - great to hear my work has helped you! I'll ping them and see if they can add something on there.
@bigbucketboy It works, used it for months including Raspberry Pi OS Bullseye (64bit). I have moved onto a different approach to control fan speed based on temperature dynamically with code. My git repo, may be helpful: https://github.com/ar51an/raspberrypi-fan-control
@ar51an I'd like that even better! I'll give it a look. Thanks!
@bigbucketboy Was going to propose another article for April, but looks like I already did one here!
@bigbucketboy Was going to propose another article for April, but looks like I already did one here!
Oh great! Was that with the update about being able to change the temp under 60 degrees Celsius?
@bigbucketboy No, it doesn't have that. I usually don't update articles there, but I'll ping them and see if they'd be interested - seems worth it.
@JeremySCook Definitely! I think people would like to have that option. Thanks again for all your work!
@JeremySCook I have a question. Does your EZFan2 completely cut off power to the fan when the Raspberry Pi powers down even though the Pi continues to power 5v pins when shutdown? I'm asking because I bought a 3 wire PWM fan with LED's on it. When the Pi shutdowns the fan turns off because the PWM wire controls it but that doesn't effect the LED's so those stay on all the time. Was wondering if your EXFan2 board would fix my issue.
Thanks.
@bigbucketboy Interesting it doesn't affect the LEDs, but I guess that makes sense from a hooked up correctly point of view. Yes, the EZ Fan2 board should take care of everything, though I believe you'll need to connect both the PWM wire and power wire to it.
@bigbucketboy Interesting it doesn't affect the LEDs, but I guess that makes sense from a hooked up correctly point of view. Yes, the EZ Fan2 board should take care of everything, though I believe you'll need to connect both the PWM wire and power wire to it.
@JeremySCook yeah I think the fan houses 2 isolated circuits to be honest. Maybe in parallel. Both are powered by the 5V wires. The the 3rd wire just controls whether or not the fan is on or not but it constantly powers the LED and the Fan. When I power down the raspberry pi I'm not sure if it "remembers" the last setting or still is reading cpu temp in a low power state or what but fan doesn't spin but the LED's are still on. Since the 5V rail is always on when plugged in. LED's still stay on when temp is below set threshold and raspberry pi is operating normally. So I think it's functioning correctly. I have the exact same fan but just a standard 2 wire one I'll just use with your EZFan2. Just mainly wanted to confirm it'll kill power to the fan and LED's when raspberry pi is off but still hooked to power and connected to 5V rail. Thanks!
@bigbucketboy Yep, should take care of it. Thanks for your order, btw :-)
@JeremySCook Awesome! Can't wait. And no problem!
@JeremySCook I just realized. This will also always keep the fan off including the LED's until the raspberry pi os tells the gpio pin the cpu is too hot. And then again turn it off once it meets the threshold. Correct? I was hoping the LED's would constantly stay on and the fan would just be controlled by the pin but I don't think either option whether using your gizmo or my three wire fan I'll achieve this though. If I want the fan and LED's to turn off on shutdown.
@bigbucketboy Unfortunately no, the LED would not stay on. Perhaps you could break the LED wiring out to a GPIO pin and power it separately.
@JeremySCook It doesn't seem to have an LED wiring. I think it's internal to the fan. Here is the fan I am using. The only thing I can think of else to do is run it from 3.3v rail which can be powered down in eeprom with the right settings. But not sure if I should run my fan on that rail. Unsure about amp draw or hardware failure after too long.
@JeremySCook okay I am done messaging after this. I think I've found a solution to fix my problem your board will still be needed so that's good. Does this PCB work with going from high to low or low to high on gpio inputs? If I so I think I can wire the gpio pin on PCB to activate the fan instantly at startup and shutoff the PCB instantly at shutdown. Then I can use the fan control wire on the fan also plug it in to control fan on and off. So that way the fan wire controls turning fan on and off while rpi board is running and then use the PCB to turn the entire fan on and off including LED's on startup and shutdown. Just need to verify if your EZ fan 2 will work in this scenario. I can draw it out if my writing didn't make sense please let me know. I currently have my rpi set to power everything down at shutdown. So only the 5v rail is lit up. Thanks!
@bigbucketboy I think what you're describing will work - basically using the EZ Fan2 as a secondary control for total power in series. I haven't tested this exact scenario of course, but seems plausible if I'm understanding correctly.
@JeremySCook That would be correct. I'll report back after testing and let you know what I find!
@JeremySCook Thanks so much for your product! It's excellent! It works as suggested in my prior comment using it solely as a 5V power switch. I just plugged into the TxD port and I didn't even need to write and code or implement any software. Just enabled it in the boot config file and bam! "Turns off" 5V rail when Pi shuts down and "Turns on" when Pi boots up. Then I used my fans PWM wire to control fan operation. LED's power up and down with system status. It's excellent!
@bigbucketboy Well thank you so much for letting me know - comments like that really mean a lot :-) Also I'm glad to see it got there quickly!
@bigbucketboy Was able to update the post here. Also added a separate PWM post.
Thanks for the inspiration :-)
@bigbucketboy Was able to update the post here. Also added a separate PWM post.
Thanks for the inspiration :-)
Thanks so much Jeremy! Glad I could help inspire. I very much appreciate the shout out and I'm hopeful those updates will help out someone looking for those same answers! Have a great one!
What library are you using?
gpio
gets onlycommand not found
on my RPiOS "Lite" system.