Remotely Monitoring Furnace Temperature Using a K Type Thermocouple, Raspberry PI and a Max31855

by kibade1 in Circuits > Raspberry Pi

402 Views, 0 Favorites, 0 Comments

Remotely Monitoring Furnace Temperature Using a K Type Thermocouple, Raspberry PI and a Max31855

furnace.jpg

I made a Thermocouple monitoring system for my wood furnace that allows me to monitor my furnace temperature from anywhere in my house.

My furnace is in my basement. It has 5 main stages to its use: 1) Prepping the furnace box. That requires a manual flap to be opened to increase airflow and wood and paper to be arranged inside. 2) Lighting. 3) Furnace box heat monitoring, waiting until the temp is between 260C and 315C. 4) Closing the manual flap. Engaging the catalytic converter. 5) Later, checking if the box temp drops too low, meaning more wood needs adding. Stages 1 - 4 need me to stand and watch the display on the furnace and sometimes it can take over 30mins. The danger if I don't watch the temperature is the furnace getting too hot before I close the manual flap. Too high a temperature would cause damage. Stage 5 needs me to pop down to the basement, just to see how the fire is doing, which is annoying.


My solution was to use a MAX31855 K-type module to read my furnace's K-Type Thermocouple, instead of the furnace thermometer/display. I then used a Raspberry PI to read the temperature from the MAX31855. I then installed a web server on the Raspberry PI (Apache) and instructed the webserver to display the furnace temp. Now all I do is point any browser to the Raspberry PI to see the value. I can use my laptop, my phone, even my smart TV! I then set my router to forward to my PI so I can access the live values from anywhere.

Supplies

Max31855 module.jpg
MAX31855-pinout.png
RaspberryPi.JPG

1 x Max31855 k-type module

1 x Raspberry PI (I used a model 3)

Downloads

Setup the PI

I chose the Raspberry PI model 3 because it has built-in WiFi. You don't need this if you are OK with using a network cable, but my furnace was too far for any switch and it gets quite hot, so the less cables I have the safer.

I used the Debian Lite OS as I didn't need any GUI as this project couldn't have a screen, keyboard or mouse when it was done, however, you could easily use the desktop version, it just means that the PI is going to be working harder for no good reason. When installing the OS you will need a screen and keyboard but once you have this installed and you enable WiFi and ssh (see below) you don't need the screen or keyboard. We do the rest via a laptop and Putty.

I will be assuming you are using a terminal window from this point onwards.

Once you have successfully installed the OS (The Raspberry PI website covers this in great detail) the Lite version seems to have the WiFi unit disabled by default. Run sudo raspi-config to access the default settings for the Raspberry PI.

  • Open a terminal
  • Type the following command to open the configuration tool:
  • sudo raspi-config
  • Go to Network Options > Wi-Fi
  • Follow the wizard to choose a SSID and enter the password.

(From https://raspberrytips.com/raspberry-pi-wifi-setup/)

  • Enable SSH
  • sudo raspi-config
  • Select 5) Interface Options
  • Select P2) SSH
  • Select Yes to enable SSH.

Reboot the Raspberry PI

Login and run ifconfig to find your IP address. Don't continue until this works. If you don't have an IP address there could be something wrong with your WiFi settings. Troubleshoot, Google is your friend here :-)


Now we can get rid of the keyboard and screen.

On your laptop install Putty, so we can SSH into the Raspberry PI.


If all went well you are now logged into your PI via your laptop.

Connecting the MAX31855 Module to the PI

I'm going to be using Tuckies Max31855 python project on Github that works great. https://github.com/Tuckie/max31855.

The Github code has the following pin assignments in the readme.md: GPID 22 = DO, GPIO = CLK, GPIO = CS.

Also, we will be using the 5V and Ground, not the 3.3V (Only connect the 3V if your circuit doesn't have a 5V, mine had a 5V to 3V converter built-in.)


Next, connect the thermocouple to the terminal block. In my case, I had a spare K-type that came with the module, so testing was simple. If you don't have that, you will need to directly connect to the furnace probe.

Reading Data

If you read the MAX31855 data sheet you can see the data is output serially via the DO and CLK pins. 32 bits of data are read. In this data are the furnace temp value, Cold Junction temp, and fault conditions. I can write code, but not well. Luckily on GitHub someone more talented than I already wrote the code needed years ago. To get this onto your PI is simple.

Putty into the PI and run the following commands:

sudo apt install git

sudo git clone https://github.com/Tuckie/max31855.git


Done :-)


To test that this is working create a test.py file with the following Python code:

sudo nano test.py

#!/usr/bin/python
from max31855 import MAX31855, MAX31855Error

cs_pin = 24
clock_pin = 23
data_pin = 22
units = "f"
thermocouple = MAX31855(cs_pin, clock_pin, data_pin, units)
print(thermocouple.get())
thermocouple.cleanup()


Python3 comes with the OS, so it is simple to run the following command:

python3 test.py

The result should be the thermocouple temp. If you get an error, read it. It might be telling you the probe is open circuit, closed circuit or out of range, etc.

Don't continue past this point until you have a successful temperature reading.

Webserver

Putty (SSH) into your Raspberry PI.

Run the following command to install the Apache webserver:

sudo apt install apache2


Next, edit the Apache server to allow Python scripts to run and default to a python script.

sudo nano /etc/apache2/sites-enabled/000-default.conf


Add this at the bottom, but before the </virtualhost>


DirectoryIndex index.py

<Directory "/var/www/">

  Options +ExecCGI

  AddHandler cgi-script .py

</Directory>


Add the www-data group to the GPIO group, so the Apache server can access the GPIO pins when running our Python script:

sudo usermod -a -G gpio www-data


Create a new file called index.py using sudo nano index.py (this is the file the apache webserver will open as default) and add the following:


#!/usr/bin/python3
from max31855 import MAX31855, MAX31855Error
cs_pin = 24
clock_pin = 23
data_pin = 22
units = "c"
thermocouple = MAX31855(cs_pin, clock_pin, data_pin, units)
print("Content-type:text/html\r\n\r\n")
print("<html><body>")
print("<font size=""10"">")
print(" <meta http-equiv=""refresh"" content=""5"" />")
print("Current Temperature of the furnace", thermocouple.get(), "C")
print("</font>")
thermocouple.cleanup()


Note: print(" <meta http-equiv=""refresh"" content=""5"" />") sets the refresh page rate to 5 seconds.


Now copy all the max31855 files including the new index.py into /var/www/html (assuming you are in the max31855 directory)

sudo cp * /var/www/html/

Reboot the Raspberry PI. I've found many of the permissions, especially the new addition to the GPIO group, don't get updated until a reboot.

Open a web browser to <your Raspberry PI's IP address>

You should see this:

Current Temperature of the furnace 46.75 C (or whatever temperature it is!)


If there is a problem, a good place to get some info is /var/log/apache/