Tom Lewis
Published © GPL3+

Grill & Deck-Door Monitor

Monitors if our barbecue grill is on, displays the grill temperature, and checks if it's okay to leave the deck-door open.

IntermediateWork in progress8 hours1,845
Grill & Deck-Door Monitor

Things used in this project

Hardware components

Arduino Pro Mini 328 - 3.3V/8MHz
SparkFun Arduino Pro Mini 328 - 3.3V/8MHz
×1
SparkFun MicroView - OLED Arduino Module
SparkFun MicroView - OLED Arduino Module
×1
SparkFun Thermocouple Breakout - MAX31855K
SparkFun Thermocouple Breakout - MAX31855K
×1
SparkFun Thermocouple Type-K Stainless Steel
×1
SparkFun Temperature Sensor - TMP36
×2
SparkFun Magnetic Door Switch Set
×1
LED (generic)
LED (generic)
×2
SparkFun microB USB Breakout
SparkFun microB USB Breakout
×1
SparkFun 0.1 uF Capacitor
×2
Resistor 330 ohm
Resistor 330 ohm
×2

Story

Read more

Schematics

Grill & Deck-Door Monitor Fritzing Diagram

Code

Grill & Deck-Door Monitor

Arduino
This code is for an Arduino Pro Mini 3.3V
//This code is for an Arduino Pro Mini 3.3V

//SET UP THE TMP36 SENSORS

int tmpOut = A0;//tmp sensor outside
int tmpIn = A1;//tmp sensor inside

const int numReadingsOut = 60;//This smooths out the readings
int readingsOut[numReadingsOut];
int indexOut = 0;
int totalOut = 0;
int averagetmpOut = 0;

const int numReadingsIn = 60;
int readingsIn[numReadingsIn];
int indexIn = 0;
int totalIn = 0;
int averagetmpIn = 0;

//SET UP THE DOOR CONTACT AND CLOSE NOTICE LIGHT

int magnetPin = 6;//to tell us if door is closed (LOW) or open (HIGH)
int blueLight = 5;//when this is on we need to close the door
boolean closeDoor = false;//we'll use this to determine what the OLED outputs

//SET UP THE OLED DISPLAY

#include <SFE_MicroOLED.h>
#include <Wire.h>
#include <SPI.h>
#define PIN_RESET 9  // Connect RST to pin 9 (req. for SPI and I2C)
#define PIN_DC    8  // Connect DC to pin 8 (required for SPI)
#define PIN_CS    10 // Connect CS to pin 10 (required for SPI)
MicroOLED oled(PIN_RESET, PIN_DC, PIN_CS); // Example SPI Declaration

//SET UP THE THERMOCOUPLE

#include <SparkFunMAX31855k.h> // Using the max31855k driver
// Define SPI Arduino pin numbers (Arduino Pro Mini)
const uint8_t CHIP_SELECT_PIN = 10; // Using standard CS line (SS)
// SCK & MISO are defined by Arduiino
const uint8_t VCC = VCC; // Powering board straight from Arduino Pro Mini
const uint8_t GND = GND;
// Instantiate an instance of the SparkFunMAX31855k class
SparkFunMAX31855k probe(CHIP_SELECT_PIN, VCC, GND);

//SET UP THE LED TO WARN GRILL IS ON

const int redPin = 7;

void setup() 
{
  delay(50);  // Let IC stabilize or first readings will be garbage
  oled.begin();
  pinMode(redPin, OUTPUT);
  digitalWrite(redPin, LOW);
  pinMode(magnetPin, INPUT_PULLUP);
  pinMode(blueLight, OUTPUT);
  digitalWrite (blueLight, LOW);

  for (int thisReadingOut = 0; thisReadingOut < numReadingsOut; thisReadingOut++)
  readingsOut[thisReadingOut] = 0;

  for (int thisReadingIn = 0; thisReadingIn < numReadingsIn; thisReadingIn++)
  readingsIn[thisReadingIn] = 0;
}


void loop() 
{
  float temperature = probe.readCJT();//for the thermocouple
  
  oled.clear(PAGE);//clear out the oled of previous garbage 

  totalOut = totalOut - readingsOut[indexOut];//need all this to average temp readings        
  readingsOut[indexOut] = analogRead(tmpOut); 
  totalOut = totalOut + readingsOut[indexOut];       
  indexOut = indexOut + 1;                    
  if (indexOut >= numReadingsOut)              
    indexOut = 0;                           
  averagetmpOut = totalOut / numReadingsOut; 

  float voltout = ((averagetmpOut)*3.3/1024.0);
  float tempOut = (((voltout-.5)*100*9.0/5.0)+32.0);

  totalIn= totalIn - readingsIn[indexIn];         
  readingsIn[indexIn] = analogRead(tmpIn); 
  totalIn= totalIn + readingsIn[indexIn];       
  indexIn = indexIn + 1;                    
  if (indexIn >= numReadingsIn)              
    indexIn = 0;                           
  averagetmpIn = totalIn / numReadingsIn;

  float voltin = ((averagetmpIn)*3.3/1024.0);
  float tempIn = (((voltin-.5)*100*9.0/5.0)+32.0);

  int magnetValState;//declare and read the door contact
  magnetValState = digitalRead(magnetPin);

//The following three (3) if statements compare the temperatures outside
//versus inside. I want it to be 2F warmer outside than inside to open the door.
//Once it drops to 2F colder outside than inside I want to shut the door. This
//gives us a 4F range.

if(magnetValState == LOW)//door closed
{
  digitalWrite(blueLight, LOW);//blue light off
  closeDoor = false;//logic for printing to OLED
}

if (magnetValState == HIGH && tempOut >= (tempIn+2.0))//door opened & warm
{
  digitalWrite(blueLight, LOW);//still no need for blue light
  closeDoor = false;//logic for printing to OLED

}
if (magnetValState == HIGH && tempOut <= (tempIn-2.0))//door open & cold
{
  digitalWrite(blueLight, HIGH);//turn on blue light to warn to close door
  closeDoor = true;//logic for printing to OLED
}
  
  temperature = probe.readTempF();//read thermocouple in F
  if (!isnan(temperature)) {

}

  if (temperature >= 120)//grill is "on" (hot), this overides other OLED displays
  {
    digitalWrite(redPin, HIGH);//red light remains on while grill is on
    oled.setFontType(3);//note the font size, it will change later
    oled.setCursor(0,0);
    oled.print(" ");//just to adjust the numbers to the center of the display
    oled.print(temperature,0);//prints grill temp in nice, big numbers
    oled.display();
  }
   
 if (temperature <= 116 && closeDoor == false)//grill is "cold", door closed
  {
    digitalWrite(redPin, LOW);
    oled.setFontType(1);//note the change in font size
    oled.setCursor(0,0);
    oled.print("Out ");
    oled.println(tempOut,0);//outside temp
    oled.println("");
    oled.print("In  ");
    oled.print(tempIn,0);//inside temp
    oled.display();

  }

if (temperature <= 116 && closeDoor == true)//grill "cold", door open, should shut
  {
    digitalWrite(redPin, LOW);
    oled.setFontType(1);
    oled.setCursor(0,0);
    oled.println(" Brrrr");
    oled.println(" CLOSE");
    oled.println(" DOOR!");
    oled.display();
  }

delay(1000);//a delay makes everything smoother

}

Credits

Tom Lewis

Tom Lewis

1 project • 0 followers

Comments