Handling mash temps and strike temps in arduino build

Homebrew Talk - Beer, Wine, Mead, & Cider Brewing Discussion Forum

Help Support Homebrew Talk - Beer, Wine, Mead, & Cider Brewing Discussion Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

waldzinator

Well-Known Member
Joined
Feb 17, 2013
Messages
147
Reaction score
11
Location
Waxhaw
Hi,

I've been slowly chipping away at making a fully automated, electric brewery for about 6 months now. Up until now, I've been focusing on the sensing, display, and user interface components, mainly because my current house doesn't have 240V hookups in my little detached garage. Big news though...I'm relocating to Charlotte, NC next month and my attached garage will have the necessary hookups. So, it's time to ramp up the work. My ultimate goal is to use an Uno for all my firmware. I figure the challenge of using a limited number of pins would be fun...lots of shift registers and heavy use of i2c.

I purchased a 4x3 matrix keypad and PCF8574 shift register. The idea is here is that under my setup function, I ask the user (me) for the number of mash steps. Once entered, I then ask for the mash length and temp for each. I started working on a function to write each to an array, but then it dawned on me that there are some issues here. Initially, I'm going to heat my water up to my strike temperature, not my target mash temperature. The remainder of the rests would not be an issue, since the grain is already mixed with the water. The issue comes up again when I sparge, especially if I am batch sparging.

Anybody run into this issue with their firmware? I guess my options are to manually heat the strike water, but what fun is that? Not looking for a "do you hez the codez" type of response haha, but suggestions would be great.

Here's the relevant code (the two input functions are untested) Once I got to the function void getmashsteptemp(), I realized I needed to rethink. If anyone is interested in full code or my ugly breadboard setup, let me know. For time display, I use a 4-digit 7-segment clock. :

EDIT: I do realize I could probably prompt for the strike temperature and not populate an entry in my time array (not shown below yet). I could then write some code in my loop to heat to that temperature, add the water, and once added, run through my mashtemp array. I was just wondering if there was a better way.

Code:
#include <stdlib.h>
#include <LiquidTWI2.h>
#include <i2ckeypad.h>
#include <Wire.h>

//mash temps and and times
int intMashSteps = 0;
double mashTemp[10];
int mashTime[10];

///more LCDs to be added later using i2c
LiquidTWI2 lcd(0x20);

void setup()
{ 
  lcd.setMCPType(LTI_TYPE_MCP23017);
  lcd.begin(16, 2);
  Wire.begin();
  kpd.init();
  while (intMashSteps == 0)
  {
    intMashSteps = mashNumStepsPrompt();
  }
  for (int c; c<intMashSteps+1;c++)
  {
     getmashsteptemp(c); 
  }
  Serial.begin(9600);
}

int mashNumStepsPrompt()
{
  int mashStepsIter = 1;
  char mashSteps[3];
  char key = kpd.get_key();
  //Need function for prompting 
  while (strlen(mashSteps) < 2)
  {
    lcd.setCursor(0,0);
    lcd.print("Type # mashsteps");
    lcd.setCursor(0,1);
    lcd.print("and press #");
    key = kpd.get_key();
     ///TODO: Error handling here
    if (mashStepsIter < 2 & key != '\0')
    {
      mashSteps[mashStepsIter] = key;
      mashStepsIter++;
    }
  }
  if (mashSteps[2] == '#')
  {
    int numMashSteps = mashSteps[1] - '0';
    return numMashSteps;
  }
  else
  {
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Invalid entry");
    delay(1000);
    return 0;
  }
}

void getmashsteptemp(int mashstepnum)
{
  char mashTempEntered[7]; ///6 spots for temp xxx.xx and one for null term
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Enter Mash1 Temp");
  lcd.setCursor(0,1);
  lcd.print("Use * and # end");
  key = kpd.get_key();
  
}
 
So, I thought more about this...I don't really need the PID running to heat my strike water. I think I'm going to have another button to switch between manual mode and automatic mode. THis is probably a good idea anyway, since I don't need the PID for boiling, either. I will still have to think about how to trigger the sketch to start internally timing each mash step and passing the correct temp to the PID.

Like I said, any alternatives are welcome...
 
For user input I prefer to use encoder (2 digital pins) and 2-4 buttons with resistor all connected to one analog pin.
 
I also don't really understand your issue with strike and sparge temperature. If you know what temperature for strike do you need why should you heat it manually? For example you can define 0 as indefinite time interval. So controller will keep that temperature forewer until user press some button than next step will start .


&#379;ycz&#281; powodzenia
 
I also don't really understand your issue with strike and sparge temperature. If you know what temperature for strike do you need why should you heat it manually? For example you can define 0 as indefinite time interval. So controller will keep that temperature forewer until user press some button than next step will start .


&#379;ycz&#281; powodzenia

Let's walk through a use case. Assume a brew day with a single infusion mash and batch sparge (keep it simple first). My setup is going to be a three vessel e-HERMS system using converted kegs. So there would be a heating element in my HLT and my BK. There would be a pump connecting the outlet of the MT to the the inlet of the HERMS coil in the HLT.

Let's say my strike temp is supposed to be 168 and my goal is to mash at 152 for 60 minutes. My strike temp for my sparge is 178 to arrive at 168 for 15 minutes (totally fictitious).

Upon startup, the LCD is going to prompt me to enter the number of mash steps. Technically, I have 2 "mash steps"...the infusion and sparge. I would enter 152 for 60 minutes and 168 for 15 minutes.

So, those are really only be used as input to my PID (note: I'm using the standard Arduino PID library). I'm not going to use the PID to heat up my strike water, so I imagine I need a button to turn on and off the PID (this is what I was referring to as manual vs automatic mode). To further automate it, I could get into some ugly stuff like measuing amount of liquid transfered from HLT to MT and automatically kick on PID when transfer complete. Once strike temp is reached, transfer liquid from HLT to MT. Add grain. Here is where the PID should kick on to control the HLT element. Also, pump turns on to start recirculating. Once 60 minutes is up, I need to lauter so pump from MT to BK kicks on. I need to go back to manual mode to heat up my sparge water. Once there, transfer water to MT and turn PID back on and recirculate for the 15 minutes (is this step necessary?)

Obviously multi-step mashes and fly sparging complicate things a little bit, but this is the baseline behavior I would expect.

So, I'm just trying to figure out if my approach makes sense. I'm also kinda using this post as a way to get all my thoughts down...sometimes sh*t be sounding crazy after you type it and read it later haha.

EDIT: Thinking about this some more, I could prompt for Grain/Water ratio and calculate it internally.
 
The Open Source BrewTroller does all of this. Take a look at their code, it should help.

Thanks for the tip. I have heard of the brewtroller, but I didn't know it was open source. That should help me figure out some of these stickier issues. :mug:
 
I started to do it all myself, then just decided to go with BrewTroller BX1, it's about $70 and I've just built up around that. I boil with gas but use the BT for heating strike water and running my RIMs (PID). It has a ton of features I haven't even tapped into.
 
I started to do it all myself, then just decided to go with BrewTroller BX1, it's about $70 and I've just built up around that. I boil with gas but use the BT for heating strike water and running my RIMs (PID). It has a ton of features I haven't even tapped into.

At times, building it on my own is a real PITA. However, it's been fun and educational overall. Satisfies my need to tinker. In the meantime, I still have my normal gravity feed propane and cooler rig!
 
Back
Top