Oven Temperature Controller (#MakeWithMaxim Contest)

Introduction
I'm using the MAX31856EVSYS to build a oven temperature controller. Recipes tend to use different units of temperature: centigrade, fahrenheit & gas mark. It is not difficult to convert between these (many ovens also show both on the temperature dial), but I thought of building a system which allows the user to set the temperature (in any unit) and the baking time.

For now, the system will only monitor temperature and alert the user if it exceeds a narrow limit (if the oven's inbuilt temperature control system isn't working correctly or isn't calibrated well enough) or if the baking time is up.
My plan is to incorporate a closed loop temperature control system that lets the user set a desired temperature profile (eg. 200C for 15 minutes, 300C for 10 minutes). The system will then automatically sense the temperature and increase/decrease the temperature by controlling the power input to the oven (using a SSR for electric ovens, and a servo motor that controls the knob position for gas fired ovens).

I initially planned on using an ESP8266 for this project, but after taking a closer look, I realised that it would be easier to get it working with a Raspberry Pi (I was short on time since I received my board very late). The Pi is overkill for this, so I'll be porting it over to the ESP8266 eventually - using the ESP8266 lets me generate alerts on my phone since its got WiFi.

For now, I'm building a control interface for the temperature controller using the Raspberry Pi 3. I'm using a Python application to display a GUI on the Pi's 2.4" touchscreen HAT that lets the user view the status of the system. The user will be able to set & adjust the temperature using a rotary encoder.

BOM
For Sensing:
Type K Thermocouple
MAXIM MAX31856
Raspberry Pi
Rotary encoder

For control (to be implemented):
SSR/ relay for electric oven, servo for gas.

Schematics
View attachment 189070

Instructions
Using the MAX31856 with the Raspberry Pi is very easy: there are a couple of Python libraries available, which greatly simplifies the software side of things. Using the board without an existing library isn't a problem either: the datasheet contains all the details of the registers that need for be read.

I used Stephen Smith's Raspberry Pi Python Library for the MAX31856 which uses a software implementation of SPI which allows you to use any GPIO pins for SPI. The USB2PMB1 (PMOD to USB board) wasn't needed for this, but I did try it out: the evaluation software lets you play around with a range of configuration options for the MAX31856.

View attachment 189093

Use jumpers to connect the MAX31856PMB1 module (or any breakout board with the MAX31856) to the Raspberry Pi.
6 connections need to be made:
  • VCC (+3.3V)
  • GND
  • SCK (SCLK or SPI Clock)
  • CS (Chip select)
  • SDI (Serial Data Input - MOSI on the Pi)
  • SDO(Serial Data Output - MISO on the Pi)
View attachment 189092
Also connect the Type K thermocouple to the terminal block, with the yellow wire on the plus side.
View attachment 189087

View attachment 189091


Source Code
I used this script to read data temperature from the MAX31856 and print it to the Python terminal.

Code:
import time, math
import max31856

csPin=19
misoPin = 26
mosiPin = 16
clkPin =20

while csPin == 19: #run an infinite loop

#all the following code is in the loop, so indent it

max = max31856.max31856(csPin,misoPin,mosiPin,clkPin)
thermoTempC = max.readThermocoupleTemp()
print( "Thermocouple Temp: %f degC" % thermoTempC)
juncTempC = max.readJunctionTemp()
print ("Cold Junction Temp: %f degF" % juncTempF)
print()
time.sleep(0.5)
I'm also did a little work on the GUI for the Python app that I'll be displaying on the Pi Display HAT.
It's far from complete, but this is what I have in mind.
I'll be adding options to set the temperature (in C, F or Gas Mark), and an option for a timer.
Once the user sets all the parameters, I'm thinking of displaying another page which will display a graph of temperature vs time for the duration of that particular session. At the end, it automatically turns off the oven (I'm sticking with an electric oven for now) and rings an alarm.
This code is only for the GUI of the first page, I''ll be adding including the MAX31856 library so that it can read temperature, and I've got to add functions to read the rotary encoder which will be connected to the GPIO pins.

This is a screenshot of the Python GUI program (taken on a Windows PC, but all I need to do is run it on Pi - porting Python is very easy!)
View attachment 189088

Code:
from tkinter import Tk, Label, Button, Entry, StringVar
LARGE_FONT = ("Verdana", 12)

class GUI:
    def __init__(self, master):
        self.master = master
        master.title("Oven Temperature Controller")

        self.label = Label(master, text="Oven Temperature Controller", font=LARGE_FONT)
        self.label.place(x=60,y=0)

        self.label2 = Label(master, text="Current Temperature: ")
        self.label2.place(x=0, y=40)
        self.templabel = Label(master, text="234.9")
        self.templabel.place(x=120, y=40)
        self.templabel1 = Label(master, text="°C")
        self.templabel1.place(x=150, y=40)

        self.templabel2 = Label(master, text="234.9")
        self.templabel2.place(x=120, y=60)
        self.templabel21 = Label(master, text="°F")
        self.templabel21.place(x=150, y=60)

        self.templabel3 = Label(master, text="Gas Mark")
        self.templabel3.place(x=120, y=80)
        self.templabel31 = Label(master, text="9")
        self.templabel31.place(x=172, y=80)

        self.label2 = Label(master, text="Set New Temperature: ")
        self.label2.place(x=0, y=120)

        #v=StringVar()

        self.enter = Entry(master,width=6)
        self.enter.place(x=130,y=120)

        self.c_button = Button(master, text="Set New Temp")
        self.c_button.place(x=180, y=116)


    def greet(self):
        print("Greetings!")

    #temperature conversion units

    def CtoF(C):
        return (C*(9/5) + 32)

    def FtoC(F):
        return ((F-32)*(5/9))
    #gas mark only works for ranges >1

    def GasMarktoF(gasmark):
        return (275+(gasmark-1)*25)

    def GasMarktoC(gasmark):
        return (((275+(gasmark-1)*25)-32)*(5/9))

root = Tk()
my_gui = GUI(root)
root.title("Oven Temperature Controller")
root.geometry("360x220")
root.mainloop()

Blog entry information

Author
ck_007
Views
115
Last update

More entries in General

Share this entry

Top