Gene Cafe Bean Mass Probe

I just tested out the bean mass probe proof-of-concept on my hacked Gene Cafe.  It worked even better than I had expected.  The probe itself is a bare type-K thermocouple that I inserted through a small hole I drilled near the inlet of the roast chamber.



The thermocouple is positioned to keep it out of the airflow and to maximize the time it spends buried in the bean mass.

I am using a MAX31855 thermocouple amplifier on an Adafruit breakout board. This is attached to the roast chamber itself.


I attached a chunk of perf board on the rotating plate that the drum snaps into using some stand-offs to help keep it cool during the roast.  On this perf board is a Pro-Trinket, a Bluefruit EZ-Link, and a lithium-polymer battery.  This was extremely easy to get working.


This interfaces with my laptop to display the temperature once per second.  The sketch I am using right now is the example code “serialthermocouple” that is in the MAX31855 library.


Forgive the mixed units here… it works!  The temperatures in the chart below are taken at somewhat random intervals during a roast.  I recorded the lowest temperature for both outlet and bean mass during the drum rotation.  You can see a significant difference between the temps.  Note that the outlet temperature was being controlled at 510F.  Once the outlet reached this temperature, it stopped climbing but the bean mass temperature continues to rise.


Lots of work to do here to get the bean mass probe temperature readings integrated into the Roast Genie but I am very pleased with the results.  This should provide a fantastic opportunity to get a better window into the roast.

Some additional thoughts:

  • The li-po battery is not contacting any hot surfaces but the radiant heat load is significant.  I am guessing it gets up to 140F +.  Some shielding may help keep this cooler.
  • The thermocouple amplifier gets warm since it is directly mounted to the roasting chamber (using Sugru).  It has cold junction compensation but any temperature difference between the amplifier chip and the connection point for the thermocouple will create errors.  This may not be very significant but future versions should be designed to avoid this.
  • Because of the way the beans move around in the roast chamber, sometimes the thermocouple is buried in the bean mass and sometimes it is exposed.  During heating, the lowest temperature read during a cycle is closest to the bean temp.  The thermocouple responds very quickly so I don’t think that this will be a big problem.  I will probably set up the software to compensate for this.

32 thoughts on “Gene Cafe Bean Mass Probe”

  1. Do you plan on open sourcing the code? I’m about to throw my gene cafe out the window and/or burn it because I can’t gauge when first crack starts. A bean mass probe is imperative if you want accuracy and consistency.

    1. Yes — happy to share. I’ve had great luck with this, much more reliable than I had even expected. I generally don’t have too much trouble identifying first crack by sound (some beans are easier than others) but knowing bean mass temp helps to know when to start watching. Project files are all located here: Good luck and let me know if you have any questions.

      1. Hi,

        I’m thinking of doing this mod so I can control and record the rate of rise. Would it interface with my windows laptop via Bluetooth or would I have to do the rest of the mods you’ve done and hook it up with cables?

        1. The version of the bean mass probe documented here worked fine over Bluetooth with my windows laptop – so it should also work for you.

          Recently I built a new version (which I need to document) that is based on an ESP8266 wifi board that broadcasts to an MQTT server I set up. This approach has some advantages but the Bluetooth solution is pretty easy to implement. Both give great bean mass readings but make sure you don’t put the thermocouple on the outlet end of the roast chamber – that tends to read 50 degrees or so higher that the actual temp.

          1. Thanks for the reply. Your images appear to show the probe mounted at the inlet side. Would I have to make changes to the code if mounting it from the outlet or have you already made those changes after moving the probe yourself?

            What do you do with the excess thermocouple length? Still run it up and don the length of the chamber handle? It appears the MAX31855 thermocouple amplifier is connected to the pro trinket with wires. Are these quick and easy to reconnect after removing the drum? I thought it might be easier to put the aplifier on the perf board with everything else and then just plug/unplug the thermocouple.

          2. Hi Rob,

            When I mounted the probe on the outlet end, I did not change the code. That said, it did not work all that well (readings seemed way off). I never investigated that carefully enough to determine if this is something that could be compensated for in the software. You might be able to. Instead, I moved the probe back to the inlet and mounted the electronics to the inlet side of the roaster. I also mounted the amplifier to the roaster instead of the drum as you suggest here (indeed it is easier to plug/unplug the thermocouple). I did not do this originally because I didn’t have proper thermocouple connectors but do now (get them from Omega Engineering). As for the excess thermocouple wire — just cut it to the length you need. The insulation is a bit of a pain to deal with but certainly doable. You can make junctions by simply twisting the bare wires together tightly and trimming. I will try to get details of the new version loaded onto the site.

          3. Thanks for the advice. I’ll be sure to mount it on the inlet side as pictured (with the probe hiding behind the metal away from the airflow). Could you possibly link to the connectors you used? I’m in the UK and can only find “mini k type connectors”. I can’t seem to find a female connector to solder to the amplifier.

          4. I’ve got all of the parts together now and soldered but I can’t seem to get any data to transmit to my computer. I’ve uploaded the program to the pro trinket, soldered everything together, and paired bluetooth. When I open com4 on serial monitor I don’t get any data.

            Is there some other software you’re using, particularly to create the graph? I’d like to add some programming to calculate the rate of rise in addition to current bean temp, but that can wait until I’ve got this working!

          5. Have you looked at the output through the serial monitor when the ProTrinket is connected to your PC through the FTDI cable? This is the easiest way to debug the setup initially.

          6. I haven’t tried that but I successfully uploaded and receive comms via Bluetooth last night. I think there was a problem caused by a Bluetooth mouse…anyway its giving me a series of 0 readings with the serial thermocouple sample, I haven’t uploaded your code again yet but it’s not looking good for the amplifier, it might be fried.

          7. Hopefully you can get this working. Let me know if I can be of any help. One thing to check out is the version of amplifier you are using. Adafruit started using a different MAXIM chip a couple of years ago. There are different libraries for the old one. I am guessing that the code would have failed to compile if you didn’t have the correct library though. Another thing to think about — I have started working on a different version of the bean mass probe using an ESP8266 and MQTT (AdafruitIO dashboard). Better results with less hardware. Some preliminary details are posted here and I am working on full documentation now.

        2. I did a search for some code that stood out to me (Sprintf) at the end. It seems as if the reason I’m not getting any comm from the thermocouple is because it’s reading 0.

          So I added this code:

          else Serial.println(“Something Went Wrong”);

          to the end and it sent it back to me constantly.

          Sprintf causes the readouts to end when at 0?

          I also changed this:

          #define DO 5
          #define CS 6
          #define CLK 3

          I’m connecting to the pins on the pro trinket from G, Bus (data out), 5v, 8, 6

          I’m not a coder so I have no idea what I’m doing here, but it seems I need to tell the pro trinket what DO, CS, CLK are connected to.

          1. Your code with added line which produces expected result error message “something went wrong”.


            The MIT License (MIT)

            Copyright (c) [2014] [Evan Graham]

            Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

            The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.


            #include “Adafruit_MAX31855.h”

            #define RATE 2 //rate = # of times/second a temperature reading is taken
            #define DO 5
            #define CS 6
            #define CLK 3

            Adafruit_MAX31855 thermocouple(CLK, CS, DO);

            int t_delay = int(1000/RATE); // this is the number of thousandths of a second between temp readings
            int TmaxLoopCount=0; // # of measurements since Tmax was set
            int TminLoopCount=0; // # of measurements since Tmin was set

            double Tmin; // best estimate of minumum temperature (this is bean mass temp)
            double Tmax; // best estimate of maximum temperature (this is environmental temp)
            double Tnow; // current thermocouple reading (t=0)
            double Tlast; // last thermocouple reading (t=-1)
            double T_dif_now; // temp difference between most recent readings(t = 0 and = -1)
            double T_dif_last; // temp difference between previous two readings (t = -1 and t = -2)

            char buffer[81] = “”; //a place to put fomatted data for printing

            long interval = 500; // interval at which to read thermocouple (milliseocnds)
            unsigned long currentMillis = millis();
            long previousMillis = 0; // will store last time thermocouple was read
            int inByte = 0; // incoming serial byte

            void setup() {
            // wait for MAX chip to stabilize
            Tmin = thermocouple.readFarenheit();
            Tlast = Tnow = Tmax = Tmin;
            T_dif_now = 0;
            T_dif_last = 0;

            void loop() {
            currentMillis = millis();
            if(currentMillis – previousMillis > interval) {
            previousMillis = currentMillis;
            Tnow = thermocouple.readFarenheit();
            TminLoopCount ++;
            TmaxLoopCount ++;
            T_dif_now = Tnow – Tlast;

            if (T_dif_now >= 0.0 && T_dif_last 1){ // this is a local minimum
            Tmin = Tlast; // best estimate of environmental temp
            TminLoopCount = 0; // reset loop counter

            if (T_dif_now 0.0 && TmaxLoopCount > 1){ // this is a local maximum
            Tmax = Tlast; // best estimate of bean mass temp
            TmaxLoopCount = 0; // reset loop counter

            Tlast = Tnow;
            T_dif_last = T_dif_now;

            if (Serial.available() > 0) { // send temp when character is received
            inByte =;
            if(inByte == ‘?’){
            sprintf(buffer,”%03d, %03d, %03d”,int(Tnow),int(Tmin),int(Tmax));
            else Serial.println(“Something Went Wrong”);

          2. As I said, the original code from github doesn’t send anything to the computer. The basic serialthermocouple program runs but returns temp readings of 0 with or without the Max31855 chip attached.

          3. Oh – this code is set up specifically to integrate with the RoastGene system. If you send a ‘?’ character to it, it will respond with the temperature. If you take this part:

            if (Serial.available() > 0) { // send temp when character is received
            inByte =;
            if(inByte == ‘?’){
            sprintf(buffer,”%03d, %03d, %03d”,int(Tnow),int(Tmin),int(Tmax));

            and replace it with just this

            sprintf(buffer,”%03d, %03d, %03d”,int(Tnow),int(Tmin),int(Tmax));

            It should send three temperatures (current, minimum, and maximum) every 500 ms

          4. I have observed that if I have a connection problem with the thermocouple it will report a temperature of 32 F. You might want to check this too.

          5. Ah, thanks that got me somewhere. Now I get a reading of either:




            After switching to readCelsius

            I’ve checked connections with a multimeter and everything is ok there. I’m pretty certain the chip has gone. I might have let one of the jumpers from 5v slip onto a data pin when trying to twist them around, though I don’t remember having it incorrectly connected to anything but ground.

          6. I’ve done it! Turns out I’d misread something and BUS can’t be used as data output, so I switched to another port and got actual readings. It’s all mounted to the end roasting plate now using Sugru and I’m pleased to say the temp doesn’t get very high at all, maybe into the 50c range. Thermocouple readings are slightly inaccurate with First crack occurring at 109c and finishing at 121c, but accuracy isn’t as important as having the temps as a point of reference. When you know how far off your equipment is you can compensate easily.

            I downloaded Artisan roast logging software but couldn’t get it to record anything. Will have to look around for something to help log so I can concentrate on responding to the temp changes rather than writing them down.

            Thanks a million!

          7. Very glad to hear that this worked for you! It is odd to see the temps so low – I get very consistent readings with 1st crack starting at 400 to 420F (204-215C). You might want to do a calibration the the thermocouple in boiling water just to rule out other possible issues. I’d be interested to see pics of how you mounted it.

  2. Hi. I am trying to make a control board for Genecafe.
    It reads the temp and time information from the i/o board
    and adjust the temp/time.

    I found there is a i/o bard inside in it. How to take the data from the I/O board and wondering how to control the temp/time.

    I appreciate if you give me some advice.

    1. Hi ChanLee – I can imagine that it might be possible to use the existing GeneCafe control board but this is not the approach I took. I removed the controls and replaced them with an Arduino.

  3. This is awesome. I won’t be building a board and driving the Gene like you are but seeing where you placed the heat probe and your belief that having the beans out of contact with the bean mass is acceptable is great!

    I have purchased a Lascar EL-USB-TC that I will be using to capture bean temperature data. It has an operating temperature of 104F so I will be enclosing the Lascar device in 1/2″ thermal blanket material and attaching it to the side of the drum handle so it won’t add to the circumference.

    It comes with software to read the data log and it provides an export feature to Excel. From there I’ll take your suggestion and separate the lower numbers (probe in bean mass) from the higher numbers (probe exposed) then plot graph the result as ambient drum interior and bean mass.

    While I’m not as ambitious as you I want to thank you for posting this; absolutely outstanding!

    1. Thanks for the kind remarks George. The bean mass probe has probably been the best addition to my setup. I am thrilled to hear that it helped you with your project. I have found the readings remarkably consistent with roast stages. Good luck with your probe – please let me know how it works out for you.


      1. I will be happy to let you know how it turns out, Evan.

        I will do my best to take pictures of how and what I’ve done with any notes. I will then get back with you and if you want to look at them and see if they are suitable for your site I would be happy to share them. I will also take screen captures of any graphics and data analysis.

        BTW – did you ever get a temperature reading on the outside of the drum? I’m hoping 1/2″ ceramic thermal blanket will be sufficient to keep my thermocouple device from being destroyed.


  4. Did you come up with an automated method of separating the cyclic sensor readings of “in bean mass” vs “out of bean mass” for the data stream? If you did and you are not using Excel then your solution will probably be of limited value to me but understanding your logic may still help.

    Based on the charts you’ve posted, running a straight “line with markers” scatter plot chart in Excel for the data stream will graphically represent the separation of readings due to the cyclic nature of the sensor being in “bean mass” and “out” quite nicely.

    For clarity, I would like to separate the cyclic sensor readings into two separate line graphs (as you have done). For me, this means going through the data and manually separating the stream into two columns with headers similar to “Sensor in Load” and “Sensor in Air” with #NA values in blank cells.

    Given the amount of data, I’m interested in automating this separation.



    1. Sorry for the delinquent reply George. I am using a very simple algorithm to identify local minimum and maximum temperatures. The logic works like this:

      1) Check the reading of the bean mass probe every 1/2 second
      2) Compare the current temperature (To) the previous reading (T1) and the one before that (T2)
      3) If To > T1 and T1 < T2 then T1 is a local minimum, the lowest temperature the thermocouple has read over the past second. I take this to be the bean mass temperature. You can do this on a spreadsheet but I do it in the code I use to collect the data. A couple of things to note: 1) With this very simple algorithm, you will get some excursions in the data (seen as rapid, temporary increases in temperature) that are not good readings. These could be filtered out with a little more coding. 2) It is important to use a thermocouple with a fast response time. I use a bare thermocouple wire of about 30 gage. When using a thicker thermocouple wire (probably 24 gage). I noticed a markedly higher temperature (> 50F) this is probably due to the fact that the thicker thermocouple can’t change temperature fast enough. A sheathed thermocouple may not work well at all.

  5. Hi,

    I plan to do something similar. I don’t have the Gene Cafe yet, but I was wondering about the probe. The wire does not twist while the drum rotates? Or there is something that rotates along with the drum , therefore the probe won’t twist?
    I plan to do something simple. My goal is to see the temperature of the beans, I don’t plan to connect anything to a computer. Connecting to an android phone would be nice though.

    Do you have any suggestions? Any clue is highly appreciated.


    1. Hi Tamas,

      The setup I built rotates with the drum. It is battery powered (LiPo). The first version I built (documented here) uses Bluetooth to communicate the temperature data. I built a second version (not yet documented) that uses WiFi and could be linked to any number of IoT servers (Adafruit’s for example). I will try to document this soon – it is a better solution. The bean mass probe is a really nice addition to this roaster.


  6. I haven’t tried that but I successfully uploaded and receive comms via Bluetooth last night. I think there was a problem caused by a Bluetooth mouse…anyway its giving me a series of 0 readings with the serial thermocouple sample, I haven’t uploaded your code again yet but it’s not looking good for the amplifier, it might be fried.

Leave a Reply

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