Bean Mass Probe – V2: Full Documentation

I wanted to be able to measure the bean mass temperature in my Gene Cafe coffee roaster to help improve my roasts.  This is a little tricky in this roaster because of the way the drum rotates (because there is no axle to pass a stationary probe through).

I developed a battery powered bean mass probe that attached to the rotating part of the coffee roaster and sent data back to a computer using Bluetooth.  Although this worked pretty well, I struggled a little bit with the reliability of the Bluetooth connection.  As a result, I developed the second generation system that is documented here.

System Overview

The purpose of the bean mass probe is to measure and report the temperature of the mass of coffee beans as they roast.  This can help you monitor and adjust the roast on the fly.  In my system the temperature is measured with a type K thermocouple that is inserted into the Gene Cafe rotating roast chamber.

Thermocouples require an amplifier to condition the signal (a very very small voltage generated at the thermocouple junction that is a non-linear function of temperature) before it can be read by a micro-controller.  Fortunately the MAX31855 breakout board from Adafruit that I use here makes all of that very simple.

Once the temperature signal is available, a micro-controller is used to capture and process the data and communicate it back to a data collection program or display system.  I have chosen to use an ESP8266 as it can handle the signal processing an also has integrated WiFi to accommodate communication back to a central server.  Again, Adafruit makes this very easy by providing a breakout board for the ESP8266 called the Huzzah.

I have elected to use MQTT as the communication protocol from the bean mass probe to the central server (in the case of MQTT this server is called a message broker).  This is a very simple, flexible, and well-supported protocol that makes the data from IoT devices available to any connected system that may wish to use it.  Adafruit has a public broker set up called AdafruitIO that also has a very simple to use dashboard display.  This tutorial shows how to set up the bean mass probe using the AdafruitIO system but there are many other ways to set this up and use the data.

This is the basic block-diagram for the V2 bean mass probe:

Architecture

The MQTT broker here is AdafruitIO.  The MQTT Client is the web interface to Adafruit IO.

Wiring Diagram

The wiring diagram and parts list are shown here.  Note that you need to connect the thermocouple directly to the thermocouple amplifier without any other connections or lead wires.  If you need to make a connection in the thermocouple, it is important that you use proper thermocouple connectors or you will create very significant inaccuracies in your temperature readings.

schematic

Thermocouple Installation

The thermocouple is installed in the end of the roasting chamber opposite of the door.  I found that the measurements obtained with the thermocouple on the door end were far less accurate (more on that later).  To install the thermocouple, first drill a small hole (3/16″ will do nicely) in the location shown here all the way through into the roasting chamber

HoleLocation

The thermocouple junction is just two wires of dissimilar material twisted together.  You can purchase sheathed thermocouples but what has worked best for me is a simple bare, fine-gage thermocouple wire. It is important that the thermocouple is small so that it will respond to temperature changes quickly.

tc

Insert the junction into the chamber about 1 1/2″.  I found that by doing this, you can later bend the wire into position and allow some adjustment to get it where you want it be in the shifting mass of coffee beans.

tc2

At this point, you should leave plenty of wire to route to where you are mounting the thermocouple amplifier and micro-controller.  For this tutorial I am mounting these components on the handle of the roast chamber but as you can see in other posts on this page, I have tried a number of different locations.  The thermocouple wire will lay nicely in the corner between the flat part of the end of the roast chamber and the transition to the inlet.

route

Secure the thermocouple wire in place and seal the hole using Sugru.  This material seems to handle the temperature well though it is at the top end of its rating.  You will need to know where you are going to place the thermocouple amplifier before you do this.  The installation I show here has the amplifier attached to the drum which eliminates the need for a thermocouple connector.  I have also experimented with mounting the electronics off the drum on the rotating part of the roaster — this is a little less convenient as you have to disconnect the thermocouple when removing the drum to load your coffee

FullView

Check the fit of the modified roast drum into both the drum stand and the roaster itself to make sure the Sugru covered thermocouple wire does not interfere with them.

Bend the thermocouple so that the twisted end of it is tucked into the corner of the shield inside the roast chamber.  You are trying to keep the junction immersed in the rotating bean mass as much as possible but you also need to keep the junction away from hot surfaces.  As the drum rotates, the beans will periodically come in contact with the thermocouple (about half of the time).  Because of this, the temperature the thermocouple reads is the temperature of the bean mass only some of the time.  The rest of the time it is measuring the environment temperature (which is much hotter during the roast).  I correct for this in the software simply by detecting the lowest temperature in each revolution and assuming that this is the bean mass temperature.  It seems much closer than I had originally thought it would be.

IMG_0542

Attaching the Electronics

I have been looking for the perfect solution to attaching the electronics to the roaster.  If you mount things on the drum itself, you have to deal with the fact that 1) the drum gets very hot and 2) there is not a lot of space to package things.  If you mount the electronics off the drum you still have to use a surface that rotates with the drum and you also have to deal with connecting / disconnecting the electronics every time you replace/remove the drum.  I designed the simple mounting system shown below to eliminate the need for connectors.  This works pretty well but makes it difficult to handle the drum since you can’t grasp the handle as well.

mounting

The yellow parts are 3D printed and the STL files are available on thingiverse.  The bracket is intended to be attached to the drum handle using zip ties.  The Huzzah is mounted to the bracket using #2 machine screws and nuts.  The amplifier is mounted to the bracket using short pieces of filament  inserted through the mounting holes like rivets.  The LiPo battery is mounted to the battery clip using zip ties.  VERY IMPORTANT NOTE: Make sure that the battery clip can not slide down the handle and allow the battery to contact the hot drum.  Overheating LiPo batteries can cause explosions and fires.

Software

Step 1: AdafruitIO (MQTT Broker & Dashboard)

The easiest way to consume data from the bean mass probe is to use the AdafruitIO MQTT broker.  Go sign up for access to this nifty tool. It has a nice dashboard feature to display data in real time and also to plot graphs.  Here is a screen shot of some recent roasts I did.

AdafruitIO

There is a bunch of information on the Adafruit site on how to use this tool.  Take a look at some of the tutorials there to get a feel for how it works.

Once you have your AdafruitIO account, take note of your userid and your AIO key.  You will need these things to set up the bean mass probe code to send data to AdafruitIO.  Go to the AIO settings page to get the AIO key.

The program that I wrote to run on the ESP8266 will produce three data feeds that correspond to the most recent maximum temperature reading from the thermocouple as well as the most recent minimum.  Additionally the current temperature reading is sent.  The feeds are sent to your account on AdafruitIO with the names MaxT, MinT, and CurT.  You will need to set up each of these feeds in your account on the “Your Feeds” page.  Once you have set up the feeds, you can create a dashboard like the one shown above to display the data however you wish to see it.

 Step 2: Programming the Huzzah

Follow the instructions on setting up the Huzzah on the Adafruit site.  You will also need to get the Arduino library for the Max31855 thermocouple amplifier.

Note: The Adafruit MAX31855 library will not work out of the box with my code.  You need to edit the Adafruit_MAX31855.cpp file as follows:

  • On windows you will likely find the file (after you have installed the library) at this location:  C:\Users\YOURUSERNAME\Documents\Arduino\libraries\Adafruit_MAX31855_library\Adafruit_MAX31855.ccp
  • Find this section of code

#include "Adafruit_MAX31855.h"
#ifdef __AVR
#include <avr/pgmspace.h>
#elif defined(ESP8266)
#include <pgmspace.h>
#endif

And change it to:

#include "Adafruit_MAX31855.h"
#ifdef __AVR
#include <avr/pgmspace.h>
#include <util/delay.h>
#endif
#ifdef __arm__
#define _delay_ms(ms) delayMicroseconds((ms) * 1000)
#endif
#if defined(ESP8266)
#include <pgmspace.h>
#define _delay_ms(ms) delayMicroseconds((ms) * 1000)
#endif

  • Get my code for the Huzzah from github.  Note that you will need to edit the code to allow the bean mass probe to connect to your network and to talk to your AdafruitIO account. Following are the lines you will need to edit:


#define WLAN_SSID "YOUR SSID"
#define WLAN_PASS "YOUR WLAN PASSWORD"


#define USERNAME "YOUR ADAFRUIT IO USERNAME"
#define PASSWORD "YOUR ADAFRUIT IO KEY"

The rest you can leave alone if you wish.  Once you load this up and apply power, the Huzzah will begin transmitting the temperature data to your AdafruitIO account.

Fire up your roaster and enjoy!

13 thoughts on “Bean Mass Probe – V2: Full Documentation”

  1. This looks great and cheaper to implement than the bluetooth version! But it seems reliant on an internet connection or is it just LAN?

    I was thinking of mounting the original version on the handle but didn’t want anything to get in the way of removing the drum to dump beans in an emergency. In this version there appears to be a little space at the back of the handle to mount the two chips on the other side (so long as they don’t extend beyond the top of the rotating plate they should fit fine).

  2. It requires an MQTT broker – so if you set one up on your LAN you do not need internet. If you want to use AdafruitIO as your MQTT broker then you would need to be connected to the internet. The dashboard shown is part of AdafruitIO.

    There is actually a fair bit of space on top of the handle before you interfere with the body of the roaster. I am working on another version that packages the electronics as you have described. This also has the benefit of keeping things further from the heat of the drum.

  3. Thank you for the great information. Does the board come with the cable so I can upload the software or I have to buy it separately? Thanks.

    Tamas

  4. I get this error:

    Arduino: 1.6.9 (Windows 10), Board: “Adafruit HUZZAH ESP8266, 80 MHz, 115200, 4M (3M SPIFFS)”

    C:\Users\Hunor\Documents\Arduino\libraries\Adafruit_MAX31855_library\Adafruit_MAX31855.cpp:30:24: fatal error: util/delay.h: No such file or directory

    #include

    ^

    compilation terminated.

    exit status 1
    Error compiling for board Adafruit HUZZAH ESP8266.

    This report would have more information with
    “Show verbose output during compilation”
    option enabled in File -> Preferences.

    I could not find a solution yet…

    How do I get the util/delay.h?

    Thanks

  5. Do you have any issues with the battery? Mine is getting pretty hot during use. I can barely touch it.

    Thanks.

    1. If you put the battery too close to the roasting chamber it could get dangerously hot. You need to make sure that it is protected from the heat – space it away from the hot surfaces and/or provide some shielding to help address radiated heat. This is important. I did not have any problems with my setup.

      1. I kept the battery in the handle as per your build (inner side) . (It was hot for me. The whole device uses 230V here in Europe, reaches temp quickly.) Then I moved it to the outer side and I covered with a heat barrier shield. Hopefully this helps.

    1. Hi Scotty,

      I’ve thought about that – I’d love to see more people benefit from a BM probe on their Genecafe but I am afraid that I would provide such poor technical support that nobody would be happy. No time you know…

      Evan

Leave a Reply

Your email address will not be published. Required fields are marked *