Coolio is a Raspberry Pi Python fan and temperature controller using a Flask webserver. I developed it to control the temperature in our electronics room, which is the room under the stairs - we call it the Harry Potter room.
- Flask-APScheduler is used to run background tasks to asynchronously perform functions like reading temperature sensors and not be blocking to the webserver answering requests. I considered redis, but that seemed excessive for the relatively simple tasks this project needs.
- Python Statemachine is used in automations to tie together the temperature readings of the sensors with the operation of fans
- Flask-WTForms is used to render forms and Jinja2 as well to assist with dynamically creating HTML at runtime.
- Flask SQLAlchemy is used to save state to a local SQLite database. Again, nothing particularly robust needed here for a db.
For controlling the Pi and attached fans and sensors, the following libraries are used:
- RPi.GPIO is used to turn pins on and off, though I am considering switching to gpiozero.
- rpi_hardware_pwm to control the PWM fans because RPi.GPIO uses software and kicks up the CPU (making more heat).
- vcgencmd for the internal temperature sensor on the Pi.
See the wiki for diagrams on the protoboard I use, circuit diagrams and connections to the Pi.
The Python code was originally inspired from Miguel Grinberg's Flask Mega-Tutorial.
- See the Wiki for details.