Temperature monitoring is an essential part of many DIY electronics projects, from weather stations to home automation systems. In this article, we will build a temperature monitoring system using the PIC12F508-I/P microcontroller and a 10k thermistor as the temperature sensing element. This system will display the temperature on a simple LED array and alert the user when the temperature exceeds a certain threshold. This project is a great way to get hands-on experience with microcontrollers and basic sensor interfacing without delving into overly complex systems.
Project Overview
In this project, we will create a simple temperature monitoring system using the PIC12F508-I/P, a small 8-pin microcontroller with limited features but sufficient for this application. We will use a 10k thermistor as our temperature sensor, which will change its resistance with temperature. The PIC12F508 will read the sensor's resistance through an ADC (Analog-to-Digital Converter), convert the data into a temperature value, and display the result on a 3-digit 7-segment LED display.
If the temperature exceeds a user-defined threshold (for instance, 30°C), the system will activate an LED indicator to signal the alert.
This project is ideal for beginners who are comfortable with basic electronics and want to dive into the world of microcontrollers and analog-to-digital conversion (ADC) without the complexity of coding for more advanced MCUs.
Components Needed:
· PIC12F508-I/P Microcontroller (8 pins)
· 10k Thermistor
· 3x 7-segment LED displays (common cathode or common anode)
· Resistors:
o 10kΩ (for the thermistor)
o 220Ω (for current limiting in LEDs)
o 330Ω (for pull-up resistors)
· LED (Red) for alert
· Capacitors:
o 100nF (for decoupling)
· Power Supply: 5V DC
· Push Button for resetting the system
· Miscellaneous: Breadboard, jumper wires, soldering iron (for final assembly), and a power supply.
Understanding the PIC12F508-I/P Microcontroller
The PIC12F508-I/P is an 8-pin microcontroller from Microchip’s PIC family. It is a very simple microcontroller but capable enough for small embedded applications like this one. Key features of the PIC12F508-I/P include:
· 8-bit architecture: It can perform 8-bit operations, which is sufficient for basic control systems like temperature monitoring.
· 4 MHz internal clock: It operates at a frequency of 4 MHz (default), which is adequate for this project.
· 1 ADC channel: This microcontroller features a built-in 8-bit ADC, which will be used to read the thermistor’s voltage divider output.
· GPIO pins: The remaining pins can be used for controlling outputs like the LED displays and the alert LED.
Circuit Design
1. Thermistor and Voltage Divider
The thermistor is a type of resistor whose resistance varies significantly with temperature. For this project, we will use a 10k thermistor that decreases in resistance as the temperature rises.
The thermistor is connected in a voltage divider configuration. In a voltage divider, two resistors (in this case, one being the thermistor) are connected in series, and the voltage at the junction of the resistors is measured. As the temperature changes, the resistance of the thermistor changes, which in turn changes the output voltage that will be read by the ADC pin of the PIC12F508.
· Thermistor (R1): Connect one leg of the thermistor to Vcc (5V).
· Fixed Resistor (R2, 10kΩ): Connect the other leg of the thermistor to the ADC pin (RA0) of the PIC12F508 and also to the fixed resistor.
· Ground Connection: The fixed resistor (R2) will then connect to ground.
As the temperature increases, the resistance of the thermistor decreases, which alters the voltage at the junction between R1 and R2. The PIC12F508 will measure this voltage using its ADC functionality.
2. Microcontroller (PIC12F508)
The PIC12F508 microcontroller will read the voltage from the thermistor using its ADC channel (RA0) and then convert this voltage into a digital value. Based on this value, the microcontroller will display the temperature on a 3-digit 7-segment display.
· GPIO Pins: The remaining pins of the PIC12F508 will be used to control the 7-segment displays and the alert LED.
· 7-segment displays: We’ll use a common cathode 7-segment display to show the temperature in Celsius. The microcontroller will control each segment of the display by toggling its corresponding GPIO pin high or low.
· Alert LED: If the temperature exceeds a set threshold (such as 30°C), the microcontroller will activate an LED (a simple red LED) to alert the user.
3. 7-Segment Display Connections
Each 7-segment display has 7 LEDs arranged in a figure-8 pattern. Each of these LEDs can be turned on or off to display numbers 0-9. To control a 7-segment display, we use 7 GPIO pins (one for each segment). However, to reduce the number of required pins on the PIC12F508, we can multiplex the displays, meaning we will activate each display one at a time in rapid succession to create the illusion of all of them being on simultaneously.
· Segments: Connect the segment pins of each display (A-G) to the GPIO pins of the microcontroller through appropriate current-limiting resistors (typically 220Ω).
· Common Cathode: Connect the common cathode of each 7-segment display to a GPIO pin of the PIC12F508, which will control whether the display is powered.
4. Alert LED
A simple Red LED will be connected to another GPIO pin. The LED will be used to signal when the temperature exceeds the set threshold. It can be activated by the microcontroller whenever the temperature surpasses, say, 30°C.
· Resistor: Place a 220Ω resistor in series with the LED to limit the current and prevent damage to the LED.
5. Power Supply
The circuit will be powered by a 5V DC supply. The PIC12F508 operates at 5V, and the thermistor and LEDs can also function well within this range. You can use a regulated 5V adapter or a USB power supply to power the circuit.
Schematic Diagram
Here’s a simple schematic outline of the connections: