I've got a problem with my RetroPie cooling fan
I am trying to get this 5v fan to turn on and off based on temp, and I am a complete programming noob, so I am mostly relying on copy-paste.
I also now realize that I could just wire the fan right to the board and have it be always on, but I have already assembled the wiring depicted in this diagram, and I don't want to tear it apart just yet.
My programming comes from the method outlined on this page. I can get everything working up to the point where I set the python script to load at the startup.
The page tells me this:
One more thing… Obviously we don’t want to manually run the program each time we reboot the pi, won’t we? We want everything to be loaded at startup, right? Then let’s create a boot script in /etc/init.d simply called “fan”:
> nano /etc/init.d/fan
…and copy-paste in it the following code:
> #!/bin/sh
> ### BEGIN INIT INFO
> # Provides: dnscheck
> # Required-Start: $remote_fs $syslog
> # Required-Stop: $remote_fs $syslog
> # Short-Description: Start fan script at boot time
> # Description: Enable service provided by daemon.
> ### END INIT INFO
> python /home/pi/Development/run-fan.py
…then create the symbolic links by running:
> update-rc.d /etc/init.d/dnscheck defaults
…and next time you’ll reboot your pi, your fan script will run automatically.
So, I believe I successfully created a boot script but it I did not have editing permission when I just typed:
nano /etc/init.d/fan
So I tried typing:
sudo nano /etc/init.d/fan
And that created a version that I could edit. I copy-pasted the code and it seemed to save properly. Getting the script to auto-start at startup is the real issue I suppose, but I don't know where along the line I screwed up.
So the next step is to type:
update-rc.d /etc/init.d/dnscheck defaults
But I get an error message:
update-rc.d: error: initscript does not exist: /etc/init.d//etc/init.d/dnscheck
I tried following one commenter's suggestion and typed
update-rc.d /etc/init.d/fan defaults
But that returned the similar error:
update-rc.d: error: initscript does not exist: /etc/init.d//etc/init.d/fan
But then I was told to use this command instead:
sudo update-rc.d fan defaults
And that returned this error:
insserv: Script fan is broken: incomplete LSB comment.
insserv: missing 'Default-Start:' entry: please add if empty.
insserv: missing 'Default-Stop:' entry: please add if empty.
Insserv: Default-Start undefined, assuming empty start runlevel(s) for script 'fan'
Insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script 'fan'
So the above code copied from the source website is messed up somehow, but I have no clue where.
I also got this suggestion from another reddit thread:
OK, that article is making that a lot more complex than it needs to be. Run these commands from the terminal to boot your script on startup: chmod +x /home/pi/scripts/run-fan.py echo @/home/pi/scripts/run-fan.py >> /home/pi/.config/lxsession/LXDE-pi/autostart The first command makes the file executable, and the second command adds it to the list of programs to start at boot. You can edit that list manually in any text editor if you want.
So that didn't quite work, but after changing the line to read:
echo @/home/pi/scripts/run-fan.py >> /home/pi/.config/autostart
The terminal didn't return an error. I then restarted the Pi, but the fan never comes on.
So that's where I am at. Totally unsure of how to proceed or where my problem might be. I'm gonna give it like 48 hours more of casual troubleshooting before I just wire the fan to the board directly.
Posted Jul 21, 2017, 9:48 PM UTC