Pimp my Raspberry Pi 3 (video #131)
In my last mailbag, I got an ordinary Raspberry Pi Model 3 with an acrylic housing, a fan, and a battery power supply. All nice things, but not good enough for me. I will pimp my Raspi!
A small fan will keep the Raspi 3 cool
A simple hardware switches a fan on and off
A Python program reads the CPU temperature and switches the fan
So, we have a cool Raspi without too much noise
I will auto-launch Python applications during boot (including error logging)
Build-in a nice “battery fuel gauge”
Hack the gauge to provide a “battery low” signal for automatic shutdown
Useful commands:
Create Scripts directory:
cd
mkdir Scripts
cd Scripts
Python program:
wget http://www.sensorsiot.org/transferFiles/Pi_Zero_MQTT_Broker/fan_shutdown.py
Automatic Startup
cd
mkdir logs
cd Scripts
wget http://sensorsiot.org/transferFiles/Pi_Zero_MQTT_Broker/launcher.sh
chmod 755 launcher.sh
sudo crontab -e (select “nano editor” if asked)
Fill in:
@reboot sh /home/pi/Scripts/launcher.sh >/home/pi/logs/cronlog 2>&1
Stress test:
wget http://www.sensorsiot.org/transferFiles/Pi_Zero_MQTT_Broker/powerTest2.sh
Additional links
http://www.instructables.com/id/Raspberry-Pi-Launch-Python-script-on-startup/?ALLSTEPS
https://www.element14.com/community/docs/DOC-78055/l/adding-a-shutdown-button-to-the-raspberry-pi-b
Luca Bertagnolio
14. April 2017 @ 15:34
Grüzi Andreas, good to see your personal blog! And it’s even better to see the teaser to the next video just here!
Quick question, though I am sure you will address it in your video: what is the USB dongle you have in your RasPi? Is that a remote keyboard + mice combo so that you can access the Raspi GUI?
I have never used the Raspi GUI much at all, all my Raspis have been headless, and managed via SSH from client machines.
Happy Easter!
Ciao, Luca
admin
14. April 2017 @ 20:07
You are right. It is a Logitec keyboard dongle. I used it because I did some tests with shutdown and this was not possible with SSH. I lost the connection too fast and was not able to see, if it worked.
Erich Müller
13. May 2017 @ 8:15
Hallo Andreas,
on the fuel gauge display you used seem to be unpopulated parts locations, any idea what these could be and what additional usage would they provide?
Dank und Gruß aus Darmstadt,
Erich
admin
13. May 2017 @ 8:21
I just used a pin on the IC (I soldered a wire to that pin).
Andreas
22. May 2017 @ 11:15
What is the value of electrolytic capacitor used at 14:14?
Iain Henderson
19. December 2017 @ 2:00
If you wanted an easier way to run some python as a service (one that will run in the background every time). You could create a file called /etc/systemd/system/fan.service containing the following:
“[Unit]
Description=Fan Controller
[Service]
ExecStart=/usr/bin/python
[Install]
WantedBy=multi-user.target”
After that exists (with path to script referencing the actual path) do:
sudo systemctl daemon-reload
sudo systemctl enable fan
That will cause the script to be triggered at startup with the following starting or stopping the service respectively
sudo systemctl start/stop fan
admin
5. January 2018 @ 16:04
Thank you for your info. A few of my viewers also pointed me to this concept. I am still a Linux beginner…
VALDO LOPES
4. March 2018 @ 22:01
Good job! could you tell me this script without the battery part? I use Rasp right in the source and I can not find a suitable PWN script anywhere.
I’m sorry, I’m still learning
Marco
9. September 2018 @ 12:39
Hi Andreas,
What NPN transistor are you using for this setup?
admin
9. September 2018 @ 22:46
I do not remember. If it is an NPN I probably used a 2N2222. But most other small transistors will do.
Ricardo
5. December 2019 @ 13:46
Hi Andreas,
After the ‘sudo shutdown -h now’, did you figure out a way to auto-switch the PI on once the power is back?
Maybe via a diode+resistor from VCC, switching on a NPN between GPIO3 and GND?
Best regards from Brazil
Ricardo
admin
5. December 2019 @ 14:00
No, I do not know how to do that.