# RPI4B Fan Control

**URL:** <https://forums.balena.io/t/rpi4b-fan-control/252386>\
**Category:** Project help\
**Tags:** raspberrypi4\
**Created:** [February 10, 2021, 8:30am UTC](https://forums.balena.io/t/rpi4b-fan-control/252386 "2021-02-10T08:30:52Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![casehighway](https://avatars.discourse-cdn.com/v4/letter/c/90db22/32.png) [@casehighway](https://forums.balena.io/u/casehighway)\
**Post date:** [February 10, 2021, 8:30am UTC](https://forums.balena.io/t/rpi4b-fan-control/252386/1 "2021-02-10T08:30:52Z")

</div>

Hi,  
Does anyone know if there is a way to configure the fan curve/behavior like within RaspbianOS?

I have a RPI4B with the official case fan (GPIO14) running balena-pihole and noticed the fans run quite loud without configuration.  
Thanks in advance

---

<div class="post-metadata">

**Author:** ![anujdeshpande](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/anujdeshpande/32/3155_2.png) [@anujdeshpande](https://forums.balena.io/u/anujdeshpande)\
**Post date:** [February 10, 2021, 8:49am UTC](https://forums.balena.io/t/rpi4b-fan-control/252386/4 "2021-02-10T08:49:18Z")

</div>

Hi

We don’t have anything for this yet - but feels like an interesting feature to add. I have created an issue to track this feature request here - [Add fan control utility · Issue #602 · balena-os/balena-raspberrypi · GitHub](https://github.com/balena-os/balena-raspberrypi/issues/602) - feel free to add more details if you feel like.

In the meantime - a simple way to do this would be to implement a small service that checks the temperature and controls the fan similar to what raspbian does.

---

<div class="post-metadata">

**Author:** ![casehighway](https://avatars.discourse-cdn.com/v4/letter/c/90db22/32.png) [@casehighway](https://forums.balena.io/u/casehighway)\
**Post date:** [February 10, 2021, 9:58am UTC](https://forums.balena.io/t/rpi4b-fan-control/252386/6 "2021-02-10T09:58:53Z")

</div>

Hi, thanks for getting back to me so quickly.  
Thanks for creating the issue, i’m looking forward to it.

Edit:  
I came across a few websites just now and it looks like python is required in order to get this working.  
This particular guide (click [here](https://howchoo.com/g/ote2mjkzzta/control-raspberry-pi-fan-temperature-python)) requires python3.  
But trying this on the pihole container via the balenaCloud terminal does not work (says unable to locate package).

---

<div class="post-metadata">

**Author:** ![vipulgupta2048](https://avatars.discourse-cdn.com/v4/letter/v/a183cd/32.png) [@vipulgupta2048](https://forums.balena.io/u/vipulgupta2048)\
**Post date:** [February 10, 2021, 10:49am UTC](https://forums.balena.io/t/rpi4b-fan-control/252386/7 "2021-02-10T10:49:00Z")

</div>

Can you send us the full error that you are getting and which command you are running that leads to this error, thanks.

---

<div class="post-metadata">

**Author:** ![casehighway](https://avatars.discourse-cdn.com/v4/letter/c/90db22/32.png) [@casehighway](https://forums.balena.io/u/casehighway)\
**Post date:** [February 10, 2021, 10:53am UTC](https://forums.balena.io/t/rpi4b-fan-control/252386/8 "2021-02-10T10:53:42Z")

</div>

Hi,  
I just tried both development and production editions - both show the same error.

Full terminal log is as follows:  
Connecting to 7f19ecf311cca2757386e9d6a05a1c40…  
Spawning shell…  
root@7f19ecf:/usr/src/app# sudo apt install python3-pip  
Reading package lists… Done  
Building dependency tree  
Reading state information… Done  
E: Unable to locate package python3-pip  
root@7f19ecf:/usr/src/app#

---

<div class="post-metadata">

**Author:** ![vipulgupta2048](https://avatars.discourse-cdn.com/v4/letter/v/a183cd/32.png) [@vipulgupta2048](https://forums.balena.io/u/vipulgupta2048)\
**Post date:** [February 10, 2021, 11:49am UTC](https://forums.balena.io/t/rpi4b-fan-control/252386/9 "2021-02-10T11:49:28Z")

</div>

Hello,  
Can you please try `apt-get update` first before installing python3-pip. `apt-get update` updates the package lists for upgrades for packages that need upgrading, as well as new packages that have just come to the repositories.

---

<div class="post-metadata">

**Author:** ![casehighway](https://avatars.discourse-cdn.com/v4/letter/c/90db22/32.png) [@casehighway](https://forums.balena.io/u/casehighway)\
**Post date:** [February 10, 2021, 12:35pm UTC](https://forums.balena.io/t/rpi4b-fan-control/252386/11 "2021-02-10T12:35:57Z")

</div>

Hi, perfect it works!  
Still quite new to linux and didn’t think to update/upgrade.  
Thanks for the help!

One more question though, the change I make in the container isn’t persistent is it? I’ll have to redo my work everytime the device reboots or restarts, is this correct?

---

<div class="post-metadata">

**Author:** ![StefKors](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/stefkors/32/3900_2.png) [@StefKors](https://forums.balena.io/u/StefKors)\
**Post date:** [February 10, 2021, 1:45pm UTC](https://forums.balena.io/t/rpi4b-fan-control/252386/13 "2021-02-10T13:45:00Z")

</div>

Indeed the changes you made in the container aren’t persistent, it will probably persist between restarts. A push or update to the device with definitely remove your manually added scripts and packages. To make your fan control script persistent you should create a second container in your app and include the python script there. I think these links could help you on your way:

- [GitHub - balena-io-examples/multicontainer-getting-started: Get up and running quickly with a multicontainer setup on balena](https://github.com/balena-io-examples/multicontainer-getting-started)
- [GitHub - balena-io-examples/balena-multiapp-project: Sample project to demonstrate how to integrate several existing balena projects in one](https://github.com/balena-io-examples/balena-multiapp-project)
- [GitHub - balena-io-examples/balena-python-hello-world: A simple Hello World server with Python Flask](https://github.com/balena-io-examples/balena-python-hello-world)
- [Balena base images - Balena Documentation](https://www.balena.io/docs/reference/base-images/base-images/#installing-packages)
