Table of Contents
Raspberry Pi Pico and MAX6675, Description:
Raspberry Pi Pico and MAX6675 based Industrial Temperature Monitoring System- You might have read my articles on DS18b20 one-wire digital temperature sensor, BMP180 Sensor which is capable of measuring the temperature, pressure, and Altitude, DHT11 sensor which is one of the most commonly used sensors and is capable of measuring the Temperature and Humidity, and my favorite one the MAX6675 K-type Thermocouple Temperature Sensor which I will be using today. I have already used all of these sensors in my previous projects based on the Arduino, Raspberry Pi, ESP32, ESP8266, STM32, etc.
The BMP180 and DHT11 sensors are good for monitoring the ambient temperatures and are used in places where surface contact is not needed between the sensor and the objects. The temperature range of the BMP180 Sensor is -40 to +85 Celsius while the temperature range of the DHT11 Temperature and Humidity sensor is 0 to +50 Celsius.
Now, the DS18b20 temperature sensor and the MAX6675 K-type thermocouple Temperature sensor; both are good for surface contact-based temperature monitoring. The temperature range of the DS18b20 is -55 to +125 Celsius while the temperature range of the MAX6675 K-type thermocouple is 0 to +1024 Celsius.
There is no doubt, the DS18b20 is an amazing temperature sensor, but due to its very limited temperature range, it just can’t be used in areas where you need to monitor high temperatures. DS18b20 has its own uses, personally, I have been using it with Arduino, STM32, Raspberry Pi, and IoT-supported controller boards like ESP32 and Nodemcu ESP8266 WiFi Modules. But, when it comes to the MAX6675 amplifier and the K-type thermocouple Temperature sensor, it’s just at another level, its ability to measure high temperatures makes it ideal for industrial applications.
In today’s article, you will learn how to make Raspberry Pi Pico and MAX6675 K-type thermocouple-based Industrial Temperature Monitoring System. You might be thinking why Raspberry Pi Pico if the same project can be built using the Arduino boards. There are some reasons which I have already explained in my article on the Raspberry Pi Pico for beginners, I did a side-by-side comparison of the Arduino and Raspberry Pi Pico and I built 10 beginners level projects, So, I highly recommend you should read my getting started article on the Raspberry Pi Pico. Anyways, some of the key reasons are.
- Raspberry Pi Pico is extremely cheap, you can get Raspberry Pi Pico only for 4 dollars from the DFrobot and it’s also available on Amazon.
- Raspberry Pi Pico is insanely fast.
- Raspberry Pi Pico is much easier to use than the Arduino boards.
- Low power consumption.
- More GPIOs and there are so many other reasons.
So, before I am going to explain the circuit diagram and programming, first let’s watch this Raspberry Pi Pico and MAX6675 K-type thermocouple based Industrial temperature monitoring system in Action.
Altium Designer is the world’s most trusted PCB design system. Altium Designer enables engineers to effortlessly connect with every facet of the electronics design process. Over 35 years of innovation and development focused on a truly unified design environment makes it the most widely used PCB design solution. With Altium Designer you can create PCB designs with an intuitive and powerful interface that connects you to every aspect of the electronics design process. Route it your way through any angle, tune for the delay, Push, Slide, and Walkaround faster than ever. Interact and collaborate with mechanical designers like never before in a photo-realistic, 3D design environment. If you want to get started with the Altium designer, you can click on the get started.
I started off by connecting the power supply, you can use your laptop or computer or an external 5V regulated power supply or you can use a 3.3V Lipo battery.
You can see Temperature on the SSD1306 Oled display module which means everything is wired up correctly and also the programming is done correctly. I am going to hold this sensor and let’s see how sensitive this sensor is and how quickly the temperature rises.
In just a few seconds the temperature raised from 20 to 32 Celsius. So, I am pretty satisfied with this whole setup, and as you can see the temperature is still rising. Now, let’s start the actual testing.
I am going to apply some heat to the sensor and let’s see if the buzzer will turn ON. In the programming, I set the maximum limit to 200 Celsius; so the Buzzer will only turn ON when the temperature exceeds 200 Celsius. You can change this limit as per your requirement.
When the temperature exceeded 200C, the buzzer turned ON. For the practical demonstration, watch the video tutorial given at the end of this article. The buzzer will automatically turn OFF when the temperature falls below the set limit.
With this K-type thermocouple temperature sensor, you can measure temperatures as high as 1024 Celsius with temperature measurement accuracy +/-1.5 Celsius which is quite acceptable when dealing with such high temperatures. If you are planning of making a plastic injection molding machine, a water boiler, a heater, etc.; then you should try this sensor. You can build yourself a low-cost industrial-level temperature monitoring system.
Now, you have got an idea of what exactly you are going to learn after watching this video. So, without any further delay, let’s get started!!!
Other Tools and Components:
*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!
MAX6675 K-Type Thermocouple:
This is the MAX6675 thermocouple temperature sensor amplifier breakout module. The temperature resolution capability of the MAX6675 Amplifier module is 0.25 degrees. The working voltage is DC 3.0 to 5V, the operating current is 50mA, the temperature range is 0 to 1024 Celsius with a temperature resolution of 0.25 Celsius, temperature measurement accuracy is +/-1.5 Celsius, and the output mode is SPI digital signal.
Specification of MAX6675 K-Type Thermocouple Temperature Sensor:
Working Voltage: DC 3.0 to 5V.
Operating Current: 50mA.
Temperature Range: 0°C – 1024°C, the converter temperature resolution is 0.25°C.
Temperature Measurement Accuracy: +/-1.5C.
Temperature Resolution: 0.25C.
Output mode: SPI digital signal.
The two wires of the thermocouple come with the Red and Blue sleeves. Red is connected with the + terminal of the MAX6675 module while the Blue wire is connected with the – terminal of the MAX6675 amplifier module. Now, let’s go ahead and take a look at the circuit diagram.
MAX6675 Interfacing with Raspberry Pi Pico:
The VCC and GND pins of MAX6675 and SSD1306 Oled display module are connected with the Raspberry Pi Pico 3.3 and GND pins. The SCK, CS, and SO pins of the MAX6675 amplifier module are connected with the Raspberry Pi Pico GP13, 14, and 15 pins. The SCL and SDA pins of the SSD1306 I2C supported Oled display module are connected with the Raspberry Pi Pico GP pins 17 and 16.
The red wire of the 5V buzzer is connected with the Raspberry Pi Pico VBus pin. The ground pin of the 5V buzzer is connected with the collector of the 2n2222 NPN transistor. The Base of the transistor is connected with the Raspberry Pi Pico GP28 pin through a 10K-ohm resistor. The emitter of the transistor is connected with the ground pin of the Raspberry Pi Pico. So, that’s all about the connections.
Raspberry Pi Pico and MAX6675 MicroPython Code:
This Raspberry Pi Pico and Max6675 based Industrial temperature monitoring system is based on two codes.
from machine import Pin,I2C import utime as time from ssd1306 import SSD1306_I2C from oled import Write, GFX, SSD1306_I2C from oled.fonts import ubuntu_mono_15, ubuntu_mono_20 from max6675 import MAX6675 WIDTH = 128 HEIGHT = 64 i2c = I2C(0, scl=Pin(17), sda=Pin(16), freq=200000) oled = SSD1306_I2C(WIDTH, HEIGHT, i2c) so = Pin(15, Pin.IN) sck = Pin(13, Pin.OUT) cs = Pin(14, Pin.OUT) max = MAX6675(sck, cs , so) buzzer = Pin(28, Pin.OUT) while True: print(max.read()) data= max.read() oled.fill(0) write20 = Write(oled, ubuntu_mono_20) write20.text("Temperature: ", 0, 0) write20.text(str(round(data,1)),0,20) write20.text("*C",44,20) oled.show() if data > 50: buzzer.value(1) time.sleep(3) buzzer.value(0) time.sleep(1.1)
This is the main code which displays the temperature on the SSD1306 Oled display Module and turns ON the buzzer when the temperature exceeds 200 Celsius. The Oled display module and its library installation I have already explained in Raspberry Pi Pico complete course article, link to the article I have already shared above.
import time class MAX6675: MEASUREMENT_PERIOD_MS = 220 def __init__(self, sck, cs, so): """ Creates new object for controlling MAX6675 :param sck: SCK (clock) pin, must be configured as Pin.OUT :param cs: CS (select) pin, must be configured as Pin.OUT :param so: SO (data) pin, must be configured as Pin.IN """ # Thermocouple self._sck = sck self._sck.low() self._cs = cs self._cs.high() self._so = so self._so.low() self._last_measurement_start = 0 self._last_read_temp = 0 self._error = 0 def _cycle_sck(self): self._sck.high() time.sleep_us(1) self._sck.low() time.sleep_us(1) def refresh(self): """ Start a new measurement. """ self._cs.low() time.sleep_us(10) self._cs.high() self._last_measurement_start = time.ticks_ms() def ready(self): """ Signals if measurement is finished. :return: True if measurement is ready for reading. """ return time.ticks_ms() - self._last_measurement_start > MAX6675.MEASUREMENT_PERIOD_MS def error(self): """ Returns error bit of last reading. If this bit is set (=1), there's problem with the thermocouple - it can be damaged or loosely connected :return: Error bit value """ return self._error def read(self): """ Reads last measurement and starts a new one. If new measurement is not ready yet, returns last value. Note: The last measurement can be quite old (e.g. since last call to `read`). To refresh measurement, call `refresh` and wait for `ready` to become True before reading. :return: Measured temperature """ # Check if new reading is available if self.ready(): # Bring CS pin low to start protocol for reading result of # the conversion process. Forcing the pin down outputs # first (dummy) sign bit 15. self._cs.low() time.sleep_us(10) # Read temperature bits 14-3 from MAX6675. value = 0 for i in range(12): # SCK should resemble clock signal and new SO value # is presented at falling edge self._cycle_sck() value += self._so.value() << (11 - i) # Read the TC Input pin to check if the input is open self._cycle_sck() self._error = self._so.value() # Read the last two bits to complete protocol for i in range(2): self._cycle_sck() # Finish protocol and start new measurement self._cs.high() self._last_measurement_start = time.ticks_ms() self._last_read_temp = value * 0.25 return self._last_read_temp
This is the library code, save the library code with the name max6675 and don’t forget to add the .py extension and save the main code with the name main.py. Let’s open the folder and you will get the idea.
You can see one file is saved as main.py and the other file is saved as max6675.py.
In the main code we simply import the max6675. Anyways, both the codes are saved on the Raspberry Pi Pico and now let’s watch the Raspberry Pi Pico and MAX6675 K-type thermocouple based industrial temperature monitoring system in action. Watch the video tutorial given below.
Watch Video Tutorial: