Introduction: A Fully Automatic Coffee Bean Roaster (Arduino)
I got introduced into the world of Arduino when two friends informed me about this little device independently from each other. I read about it and was sold immediately. What if I had this so many years ago, how much would I have invented already, what would I have made? What would my house have looked like?
I ordered one directly and there I was playing with lights, sensors, etc. But then? ..... it has the potential to control everything, but what? What should I make?
I think this is where more people get stuck. What should I do with it?
Coincidently I just finished constructing a coffee roaster, made from an ordinary popcorn machine. In basic it works by a fan blowing air past a heating element through the green coffee beans. By controlling the fan speed, I was able to control the temperature of the air roasting the beans. But, the roasting process turned out to be quite hands on, as the temperature needed to be kept constant following a profile, which was done by measuring the temperature the whole time and adjusting the fan speed with a pot meter.
That, I thought, should be automated....
Step 1: Materials Used
For this project I used:
-1x Arduino Duemilanove
-1x Arduino protoshield v2 (sparkfun) with breadboard
-1x 12x2 LCD screen (use a parallel one, would recommend a serial LCD)
-1x electric popcorn machine
-4x 1KOhm resistors
-1x small push button
-2x 1KOhm potmeter variable resistor
-1x IRF540N
-1x temperature sensor ZTK 33 V/7 mA
-1x solid state relais S216S02 (sharp)
-19V adapter (used the one of my laptop)
-plugs, wires, etc
Step 2: Adjusting the Popcorn Machine
The popcorn machine itself is adjusted by placing a temperature sensor, disconnecting the heating coil and fan motor contacts and installing wires and a solid state relais. Be sure to read my previous instructable as well, since that was my starting point.
Temperature sensor:
The sensor is installed on the inside of the aluminium cup, just above the sleeves, as it needs to measure the temperature of the beans while roasting. I used a piece of silicon (from a silicon hose) to make a heat resistant housing to keep the sensor in place and prevent short circuit. Drill a hole in the cup and place the sensor as shown on the photo's. Take care the sensor leads don't touch the metal of the cup. Outside the cup, the sensor is connected to wires long enough the lead out of the popcorn machine. The sensor and wires are secured with a tierap. Take care that the wires don't touch the cup either, as they can melt.
Installing a solid state relais to the heating coil:
The heating coil needs to be disconnected from the motor and from the heat security build into the popcorn machine. The electricity cord of the machine (220V) should be directly connected to the heating coil and the switch. In this circuit you build the solid state relais. Wires to control the solid state relais run out of the popcorn machine to the Arduino.
Fan motor:
The contacts of the fan motor are disconnected from the rest of the electronics and connected to two wires running out of the popcorn machine. A diode is placed between the two contacts to stop electricity being produced by the motor, after it is switched off but still turning. As power supply, a plug is installed to attach the 19v adapter of my laptop.
Step 3: Connecting the Arduino
As the roaster should be able to operate without a pc connected to it, I installed it with a LCD screen. The LCD screen I have is parallel and a bit annoying to connect. I therefore made a LCD module I can simply take off and use on other projects. The module is on its own breadboard with a potmeter to control the light and 8 wires connecting to the Arduino. I would recommend getting a serial LCD as you only need 3 wires.
The Arduino is equipped with a protoshield with a small bread board. It consists of:
* The temperature sensor: a simple voltage divider connection with a 1KOhm resistor, using analog port 9.
* The fanspeed controller: pulse width modulator (PWM) of port 3, connected to a mosfet (IRF540N) which controls the fan motor with 19V coming from the laptop adapter. Use 1Kohm resistor between base and digital 3.
*Heater controller: turned on or off by the solid state relais, connected to digital port 5 (dont forget the 1KOhm resistor or you blow you relais).
*A potmeter to adjust the minimal fanspeed, connected to 5V, ground and analog port 0.
*A button to start the roasting, connected to digital port 6, use another 1KOhm resistor here.
*LCD connection Digital pins 7-13 connected to RS, RW, E, d4, d5, d6, d7 of the LCD screen (and of course 5V and ground)
The popcorn machine is connected to the Arduino through 4 wires, all connected to metal pins to easily stick them in the holes of the breadboard.
Step 4: The Arduino Program Code
The program to run the Arduino consist of work of others, as it include a library for the LCD display (LiquidCrystal.h) and the PID control (PID_Beta6.h) , and a protocol to communicate with the associated Arduino PID Tuning Front-end, running on Processing (same maker as the PID control library, great work from Brett Beauregard!)
The program does the following:
Display a welcome screen and waiting for you to push the button. Then it turns on the fan but not the heating coil and it allows you to set the minimal fan speed at which the beans still move a little (you can lower it during the roasting as beans get lighter). When you press the button again the heating coil is turned on and the roasting starts. The programcontinuously measures the temperature and adjusts the fanspeed in order to match the set point. It will lower the fan speed to increase the temperature of the beans of increase the fan speed to do the opposite. If the beans get more than 3 degrees above the set point the heating coil is switched of, which will lower the temperature directly. The set point is updated along a profile that is set into the program. First heat up to 150C and stay there for 1 minute, then slowly increase to 190C and stay there for 1 minute. Then slowly increase the temperature again until the final temperature is reached. At this point, the fan is set on max and the heating is turned down. The roaster stops when the beans are lowered to 40C.
After lots and lots of tweaking, the final program code to run the coffee roaster can be found in the file below.
Attachments
Step 5: Testing..... and Roasting Your Coffee Beans
Ok, so now you connect the popcorn machine to the Arduino, to the 19V and 220V power supply and you connect the Arduino to the LCD screen and your computer, and you are ready to test your roaster.
I guess if you use the program, the temperature sensor should be more or less ok. But better be to calibrate is, and if necessary to adjust is. For this you would need a thermometer which can measure up to 220C. Measure at difference temperatures and adjust "a = 0.6271 and b = -213.13"
Next I suggest to try out some things, see how it works and follow the temperature profile with the front-end program. You will need some beans to be able to follow the temperature profile. Take good care that you set a minimal fanspeed that still keeps the beans a little bit moving. Otherwise the beans might burn (can work out dangerously!). As the roasting progresses, the beans get lighter and therefore the minimal fanspeed can be lowered.
If this all works out, I suggest you try your first batch of coffee beans. Mine can take up to 100g of beans each time, which isn't so much (but then I dont drink THAT much coffee). If it works out fine, you can start to experiment with different profiles (I would suggest to start with the final temperature settings)
Good luck and enjoy.
I have thought about an additional controller that would keep an eye on the beans. If they stop dancing then the fan speed should be increased a little bit. Couldn't think of any way to sense this, so if you have any suggestion please let me know.

Runner Up in the
Arduino Contest
45 Comments
Question 2 years ago
The code doesn't work, I can´t download PID library, does somebody know how can a get it?
5 years ago
these are the errors
5 years ago
i downloaded the code and tried compiling it. it says there are many errors in the PID part of the program. Could anyone help me in this. I am trying to recreate the same project using arduino UNO. i am using a k thermocouple with Maxx6675 for temp measurement.
6 years ago
Hallo,
could you tell me more details about the Fan, how strong the fan in CFM ? (or label specs on the motor)
8 years ago
iam a total noob in electronics (interested in coffee :D ) so i wanted to ask if i can use my arduino uno r3 instead of the arduino Duemilanove?
Reply 7 years ago
https://forum.arduino.cc/index.php?topic=51889.0
Reply 7 years ago
You should be able to use whatever Ardunio/Microcontroller you want to as long as you have enough input/output pins. I haven't looked into the diagrams of this project in particular, but the Uno is almost exactly the same as the Duemilanove (just a bit faster boot load time), so you should be fine with an exact substitute.
7 years ago
just thought about this, did a search and instruct ables came up. great job! I was wondering if you can hear 1st and second cracking over the sound of the fan. I was thinking of incorporating an audible sensor that would listen into that frequency and apply that into the equations for roasting...
My first thought was to use a heat gun with an air stream temperature monitor, is air roasting better than direct contact and turning?
7 years ago
You could use a pressure sensor at the fan outlet. This should give you a reasonably steady state signal between the two flow regimes for static beans (higher pressure), and fluidised beans (lower pressure). I'm not sure if the relationship will be linear, but there will be a relative pressure drop (pressure over fan speed) once the beans fluidise. You could slowly increase fan speed until you notice a step change in pressure.
12 years ago on Introduction
would a better way to do this be to always run the fan at full and use PWM + solid state relay to adjust power input to the heating element? Seems to me like this would offer more direct temperature control and could overcome minimum fan speed problem.
Reply 7 years ago
He chose the easier problem, since the heating element requires way more power to regulate. It would be a whole other issue putting your board in the way of that.
9 years ago on Step 3
Why did you run the fan off of 19 volts not 240 from the wall?
9 years ago
what program do you used in step 5 to make some pid graph? I'm in progress to make some incubator and need to plot the response. Roby
Reply 9 years ago
Hi Roby,
That is the PID Front-End that was developed by the guy that made the PID library. It is written in processing and works very nicely. You should be able to find it here: http://playground.arduino.cc/Code/PIDLibrary
regards,
rutger
p.s. let me know if you document your works somewhere, Ill be interested to have a look :)
14 years ago on Step 5
A microphone could not only tell if the beans were moving but could also tell when they crack :)
Reply 14 years ago on Introduction
Nice idea. But the fan would make too much noice to hear the difference between moving and non-moving beans. I thought about an infrared sensor to measure bean movement, but you would be blowing hot air against the sensor and I dont think that will be succesfull either
Reply 10 years ago on Step 5
Piezoelectric sensor will be enough to pick up cracks and bean movements.
Just JB Weld it to the outer cup,or to the case of popcorn popper.
It is used to detect knocks on some security systems(such as window break sensor),and it's fairly cheap(on RadioShack,search for piezoelectric speaker,and buy some of them and pry open the case. You can reverse it to make speaker,or the contact microphone.).
Hope this helps.
"tilas75" said this first,but it was too short to give some solutions.
12 years ago on Introduction
ah just read lower comment about max temp not being achieved with fan on full. Makes sense. Guess other approach could be set fan at speed that would allow adequate top temp and then adjust heat source.
12 years ago on Step 5
If the beans lift up a bit, you could set up what is known as a 'reed switch'. Two thin strips of metal, say Stainless steel, 1/16th apart. As the beans lift up they close the switch. That would make the logic easy. Or even bump it over and over, as long as it is closing and opening the controller would know that they were moving.
To add function, mount it on a threaded rod so you can tune the level easily.
This is the method used in polyethylene plants to measure the level in holding tanks. Poly is made as small pellets, shaped like a coffee bean but smaller. Of course they don't move around, just fill or drain.
12 years ago on Introduction
Nightlife - noticed you temperature were in Celsuius so your 300dC resistor would be able to measure 572dF - plenty!
Again, great job.