Coffee Shop
Transform an old air popcorn popper into a coffee bean roaster controlled by a Raspberry Pi and a slick user interface.
Transform an old air popcorn popper into a coffee bean roaster controlled by a Raspberry Pi and a slick user interface.
A quest for delicious coffee led me to roasting my own coffee beans at home. Using fresh-roasted coffee beans produces coffee that is considerably better than even the most expensive commercial coffee. The home roasting process only requires two things: heat and a mechanism to keep the beans moving. The beans must be agitated so they are not burned when exposed to the heat. One device commonly used by home roasters is an air popcorn popper, which simply blows hot air into a chamber. The popper is ideal because it roasts the coffee beans and circulates them at the same time.
Coffee starts out as a green bean (Figure 1). Heat is applied over a period of 7 to 15 minutes to produce roasted coffee. The roasted coffee bean can reach temperatures close to 500°F (260°C). If the beans are roasted too fast, however, they can burn, imparting some unsavory flavors to the coffee.
To get started, I visited a nearby thrift store, which resulted in the purchase of two identical Presto PopLite poppers for a total of $8. I began to use one popper immediately without modification. It roasted the beans in less than five minutes, which is too fast, so I began unplugging the popper for 30-second periods to slow the roasting process. This process grew tiresome quickly, so I extracted the fan and heater assembly from the second popper and added a thermocouple, an AC relay, some LEDs to simulate a flame, and a Raspberry Pi (Rasp Pi) to create the Electric Lights and Fire (ELF) coffee roaster (Figures 2 and 3). The smoke stack on ELF is the roasting chamber, and this is where the coffee beans are placed for roasting. Video of the ELF in action exists on my blog [1], and all the source code is available in a Bitbucket archive (see the "Downloading Source Code" box).
Downloading Source Code
The source code is kept in a Bitbucket archive, which is a tool to track changes made to all the source files for a project. To download the source, visit the link for the ELF source repository [2]. On the left-hand toolbar is a cloud icon, which, when clicked, will bring up a page where you can download the repository as a ZIP file. After downloading the repository, unzip it and go to the root directory of the unzipped source. From there, follow the directions in the README.md
file located in the root directory of the project source to get your ELF up and running.
As I mentioned, the temperature inside the popper can reach close to 500°F. At these temperatures a thermocouple, which can withstand temperatures up to 2,300°F (1,260°C), is needed to measure the internal temperature. A thermocouple is made by welding two wires made of different kinds of metal together at the end and placing them where the temperature is to be measured. The two metals react differently to changes in temperature, producing a small electrical voltage. The K-type thermocouple chosen for ELF is shown in Figure 4 and was purchased from Adafruit [3]. It is the most common type of thermocouple, which is made from chromel and alumel, two alloys made mostly of nickel. The output voltage increases 2-3mV for every 100°F (38°C) increase in temperature.
To gain access to the underside of the popper, where the heated air originally entered the popping chamber, I disassembled the popper and removed and took apart the heater/fan unit (Figure 5). The thermocouple fit nicely through a hole in the heater assembly (Figure 6), sitting beneath a screen through which heated air discharges. In this position, the thermocouple will not be damaged from the circulating beans or a spoon I sometimes use to stir the beans, and it will measure the air temperature immediately before the heated air enters the roasting chamber, resulting in an accurate reading of the roasting temperature.
The MAX31855 [4] integrated circuit by Maxim Integrated Products reads the thermocouple voltage, determines the corresponding temperature, and provides the temperature digitally via a serial peripheral interface (SPI) bus. SPI [5] is a method for communicating between a master device, in this case the Rasp Pi, and one or several peripheral devices. Rasp Pi has hardware and software support for SPI communications. Python source code available from Adafruit [6] can be configured to use either hardware or software SPI to interface with the MAX31855. For the ELF unit, I chose to use hardware SPI. The schematic in Figure 7 shows how to connect the MAX31855 to the Rasp Pi (see the "MAX31855 Update" box). By default, the hardware SPI bus is disabled, so read the "Enabling SPI on the Rasp Pi" box for instructions on setting up SPI on your Pi.
MAX31855 Update
The current version of the MAX31855 breakout board looks slightly different from the one shown in the schematic of Figure 7. As you can see in Figure 8, the pinouts have slightly different labels. Table 1 matches the old pin names with the new ones. Also helpful on the new board are the little triangles below the pins that indicate direction of information/ current.
Table 1
MAX31855 Pin Labels
Old | New |
---|---|
GND |
GND |
VCC |
Vin |
SO |
DO |
CS |
CS |
SCK |
CLK |
T- |
Red- |
T+ |
Yellow+ |
Enabling SPI on the Rasp Pi
Whether you enable SPI from the desktop or the command line, you have to reboot for your changes to take place. From the desktop, click Menu | Preferences | Raspberry Pi Configuration. In the resulting dialog box, click the Interfaces tab and the radio button next to SPI. Now click OK and Yes to reboot.
To do the same thing from the command line, open a terminal (if you're in the GUI) and enter sudo raspi-config
, select Advanced Options and SPI, then choose Yes to the question Would you like the SPI kernel module to be loaded by default? The new setting should be reflected in the dialog box. Now, choose OK, Finish, and Yes to reboot.
Another option is to edit the /boot/config.txt
file manually, which you can read about online [7].
Listing 1 shows the Python code, which uses the MAX31855 Python library provided by Adafruit [6] to create the Python object sensor
. The get_temp_f
function is called every 0.1 seconds when ELF is running. The sensor
object reads the thermocouple temperature from the MAX31855 and puts it in temp
. From this information, the heater is turned on if the temperature is below the desired setting and turned off if it is above.
Listing 1
thermo.py
01 # Raspberry Pi hardware SPI configuration. 02 SPI_PORT = 0 03 SPI_DEVICE = 0 04 sensor = MAX31855.MAX31855(spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE)) 05 06 07 def get_temp_f(): 08 temp = sensor.readTempC() 09 return c_to_f(temp)
Price $15.99
(incl. VAT)