Introduction: Beer Fermentation Temperature Controller
As a homebrewer the idea of a controlled fermentation isn't new to me, there are many products out there that do this type of thing.
The problem with most of the products, in my opinion, is their sometimes insane price tag or lack of features.
So i set out to make a DIY version that satisfies most of my needs with materials I already had. This prototypes isn't by any means perfect and will definitely improve in the future.
disclaimer: this is part of a school project.
Step 1: Materials
- Arduino Uno
- Raspberry Pi 3 (with power adapter and micro sd card)
- DS18b20 temperature sensor
- Common anode RGB led
- 16x2 Character lcd screen
- 4.7k ohm resistor
- 4x 220 ohm resistor
- an old power cable
- 2 channel relay board
- 2 outlets
For the enclosure:
- Drill (with drill bits)
Step 2: Building the Box
This step is pretty straightforward, use a saw to cut out some 20cm long planks, drill some holes and glue/screw the planks together. But here are some remarks:
- I used a 1cm thick, 11cm wide piece of wood I had laying around, but feel free to change the dimensions to what fits for you.
- Use some scrap pieces of wood to reinforce the sides, so the glue has more surface to stick to.
- Drill the holes before putting the box together, this is also true for cutting out the hole for the character lcd.
Step 3: The Magic Pixies
The electronics, probably the most important part of this project. You can place these on a breadboard (like I did) or solder them on a piece of perf board for a more permanent solution. As there are quite a lot of components here I'll explain them all one by one.
- RS to digital pin 12
- Enable to digital pin 11
- D4 - D7 to digital pins 5 to 2
- RW to GND
- Vo to GND
- + and - to 5v and GND respectively
- + and - for the backlight als to 5v and GND (with a 220 ohm resistor in series with +)
- VCC to 5V
- GND to GND of the arduino
- In1 to digital pin 8
- in2 to digital pin 9
- Data pin to digital pin 7
- Place a 4.7K ohm resistor between 5v and the datapin
- Cathode to GND
- The other pins go to A0, A1 and A2 (which we'll use as digital outputs later)
Step 4: The Code
Next up, making it all work. The code is spread over a few scripts and devices, you can find the on GitHub here: https://github.com/squareflux/NMCT_Project1 .
Take the code from GitHub, located under "arduino" and upload it to your arduino.
The code reads the temperature, sends it to the lcd and over the serial bus (which we will use later with the raspberry pi). It will also keep track of the desired temperature and controls the relays.
Here things get a bit more interesting. We'll start of the same as with the arduino, copy the code from GitHub and place them in your home directory.
Next up open up the terminal and type: sudo apt-get install python3 python3-flask python-pip -y
after this type: sudo apt-get install mysql-server, when the prompt comes to choose a password, type a password of your choosing.
After the install has finished type: sudo pip install flask-bootstrap
and sudo pip install MySQLdb.
we now have all the prerequisites to start our server.
Step 5: The Database
Still in the terminal type: mysql -u root -p
and type in your password.
next up create a database by typing: CREATE DATABASE `db_pibrew`.
exit mysql and type: mysql -u root -p >> /home/pi/pibrew/dump.sql, this will import the database so we can use it later with python.
Step 6: Automating the Scripts
Good news everyone, we're almost finished with the pi.
There are probably better ways of doing this, bit it works so I'm happy with this.
Back in the terminal type: sudo crontab -e, and choose the second option (nano) .
All the way at the bottom of this file copy and paste these two lines:
@reboot sudo python /home/pi/pibrew/server/app.py
/10 * * * * /home/pi/pibrew/updatetemps.py
The first line will make sure that every time you power up the pi there will be a flask app waiting for you.
The second one runs every 10 minutes and updates the temperatures in the database.
Step 7: Finishing Things Up
The last step is to put everything inside the box you made earlier.
- Screw on the outlets like you would inside your home.
- Place the arduino and raspi inside the box
- Close the box
- Power it up and enjoy a nice controlled fermentation.