Home     Contact     Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science     RSS     Terms of services     Privacy policy  
 Home      Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science   

20 February 2010
Author: Giorgos Lazaridis
PIC Thermometer and Thermostat

Read this before taking any further action!!!
Precautions to avoid electric shock

The circuit on a breadboard for bench test

The circuit is designed for a very specific operation: For the etching bath heater. I use this circuit for my homemade etching bath. A thermostat is a device that measures the temperature (in this case the temperature of the etching liquid), and according to a temperature window, will turn on or off the heater. This circuit has a fixed temperature window between 37 and 41oC. This can be changed of course very easy. I am preparing an etching bath and got an aquarium heater. Unfortunately, the heater's thermostat can be set up to 32oC. Higher temperatures are not proper for fish aquariums (unless you think of a fish soup). Therefore, i had to design my own thermostat.

The Circuit

This circuit has many things in common with another older circuit, the Low Cost PIC Thermometer. Actually, it uses the same technique to measure the temperature, not to mention that i use exactly the same NTC sensor (found in this experiment). The visualization of the temperature is done with 2 7-segment digits, instead of the LCD that i used with the previous circuit. So, this circuit can also be sued as a plain thermometer!

Additionally, i have add a relay. This relay will be actuated according to the temperature. If the temperature is above the bellow threshold, then the relay is actuated. The relay is released when the temperature goes above the high threshold. This is the schematic circuit:

The circuit uses it's own power supply, composed of a 2 diodes, 3 capacitors and the 7805. I use half wave rectification with the 1N4001 diodes. So, it can be powered directly from a 7 to 12V transformer. The PIC i have chosen is the 16F526. Why is that? Well, its a dead-cheap chip, with less than few capabilities, but surely enough for this application. My opinion is to always use the best PIC for the job. OK, i do not have the complete line up of Microchip, but i have more than 15 different PICs that i can choose from. This PIC was the closest to my "choosing" criteria for this application. And why is all this blah blah? This PIC has one great disadvantage: Low memory and tiny program counter. For those who understand of PIC programming, the memory page is just 256 bytes! So, if you want to change this program and/or expand it, then i strongly suggest you move to another PIC, otherwise you may get a headache.

The temperature sensor is a 10K NTC sensor, performing a voltage divider with a 10K Resistor. The output is shown in 2 7-seg digits, multiplexed with a NPN and a PNP transistor. With this technique, i save another (precious) line from the small 14-pin PIC. The schematic is for a HDK123 dual 7-seg display that i had chopped from an old TV, a VERY old TV - ITT brand.

The relay is driven with a 2N2222 switching transistor. An 1 AMP fuse in the high voltage part of the circuit will save you from troubles. If you plan to draw a schematic, you should consider thicker lines for this part of the circuit. I used the other part of the relay for LED indicator. Originally, the LED was connected to a PIC output, but it occupied a (precious) I/O pin.

The pin 13 (LPS1) is a free I/O with weak pull-up resistor in the pic, that can be used directly for a push-button, in case you decide to upgrade this circuit.

The thermistor is connected directly to the "THERM" connector of the circuit. As for the bus:

  • a1 and a2 goes to pin RC0
  • b1 and b2 goes to pin RC1
  • c1 and c2 goes to pin RC2
  • d1 and d2 goes to pin RC3
  • e1 and e2 goes to pin RC4
  • f1 and f2 goes to pin RC5
  • g1 and g2 goes to pin RB4


Here is the complete project from the MPLAB for you to view/change and recompile:

 project.asm - The assembly listing

For compiling the above assembly sheet, you will need to have the P16F526 header file:

 The Microchip Standard Header File for PIC16F526

The two threshold points, LOW and HIGH can be changed from the two constants at the beginning of the program, with the names GLLowThreshold and GLHighThreshold. The current compiled binary has the temperature window between 38 and 42oC.

If the 38-42 window fits your needs (for FeCl3 etchant this is perfect), then you can directly upload the following binary file to a PIC

 project.hex - The binary file to upload directly to the PIC

Bill Of Materials
R1Resistor 330 Ohm 1/4 Watt 5% Carbon Film 
R2Resistor 1.5 KOhm 1/4 Watt 5% Carbon Film 
R3-9Resistor 150 Ohm 1/4 Watt 5% Carbon Film 
R10Resistor 10 KOhm 1/4 Watt 1% Metal Film
R11Resistor 2.2 KOhm 1/4 Watt 5% Carbon Film 
C10.1 uF ceramic capacitor
C21 uF 25 Volts electrolytic capacitor
C31000 uF 25 Volts electrolytic capacitor
D1-31N4004 General Purpose Diode Rectifier 
T12N2222 Switching NPN Transistor 
T2BC548 Switching and Applications NPN Epitaxial Transistor 
T3BC327 Switching and Amplifier Applications PNP Epitaxial Silicon Transistor 
IC1PIC16F526 Microcontroller 
IC27805CV Positive Voltage Regulator 

Relative pages
  • High accuracy temperature meter
  • A 2-speed PWM temperature fan controller
  • High accuracy humidity and temperature sensor
  • Low cost medium accuracy PIC temperature meter
  • Experimenting with a thermistor
  • The voltage divider theory
  • Dr.Calculus: Voltage divider calculator

  • Comments


      Email (shall not be published)


    Notify me of new posts via email

    Write your comments below:
    BEFORE you post a comment:You are welcome to comment for corrections and suggestions on this page. But if you have questions please use the forum instead to post it. Thank you.


  • At 19 October 2014, 21:05:02 user Giorgos Lazaridis wrote:   [reply @ Giorgos Lazaridis]
    • @Ureche http://pcbheaven.com/exppages/Experimenting_with_a_thermistor/

  • At 19 October 2014, 16:41:27 user Ureche wrote:   [reply @ Ureche]
    • Hi, any chance to tell us how do you calculate the temperature from adc? After you acquire the adc value what do you do with it? I saw you posted the code but i don't understand asm. Thanks.

  • At 2 February 2014, 9:28:03 user Giorgos Lazaridis wrote:   [reply @ Giorgos Lazaridis]
    • @canal The code is only for PIC16F526 assembly. sorry

  • At 23 January 2014, 0:21:48 user canal wrote:   [reply @ canal]
    • Hi sir, i can't find like your use pic microcontroller. have you code for pic16f628a? and using ds18b20. thank you very much.

  • At 20 December 2012, 5:43:35 user Giorgos Lazaridis wrote:   [reply @ Giorgos Lazaridis]
    • @Dante no i do not have pcb files

  • At 16 December 2012, 22:26:27 user Dante wrote:   [reply @ Dante]
    • @Giorgos Lazaridis would you have any pcb files for this project?

  • At 1 November 2012, 13:18:09 user Giorgos Lazaridis wrote:   [reply @ Giorgos Lazaridis]
    • @Noso I'm sorry, i do not do circuits or changes on demand.

  • At 1 November 2012, 7:38:17 user Noso wrote:   [reply @ Noso]
    • Dear sir ,
      I would like to thank you for this nice circuit , please if you can solve two issue :
      1- let circuit show result in 3 segment it is very important if there is tempreture 37.5 for exaMPLE .

      2- WHO to reste and set up set down the tempreature vie switch not from software .

      please send to me the final update with hex code file and diagram .


  • At 8 July 2012, 20:40:14 user gina wrote:   [reply @ gina]
    • Hi I am an Engineering student do you know of a circuitry with a job of providing power to two rods to heat up to a max and fixed temp of 45 degrees C and give an indication if the temperature is reached?

  • At 23 June 2012, 7:44:47 user OSEGO MOKWALENG wrote:   [reply @ OSEGO MOKWALENG]
    • @Robert Thank you for your help.but what i want now is,how can i improve this circuit so that it can have 3 seven segments display so that it can write temperature in this way e.g 37.6.Plz PLZ PLZ help.the second thing is;i want u to show how to multiplex 2 or 3 separate 7 segments displays NOT THE WAY U HAVE DONE BECAUSE IT DOES NOT SHOW HOW ALL THE WIRES ARE CONNECTED TO THE 7 SEGMENT DISPLAY.

  • At 18 June 2012, 20:06:34 user Giorgos Lazaridis wrote:   [reply @ Giorgos Lazaridis]
    • @Jugurtha Thank you Jugurtha, i look forward to receive the files and upload them! Do not forget your digital signature in the assembly listing ;)

  • At 18 June 2012, 17:49:31 user Jugurtha wrote:   [reply @ Jugurtha]
    • I will send you the schematic whenever I finish it, so you can put it in here if you wish.

      When I manage to have a decent board layout (.brd), I will send it to you too.

      I have recompiled the code too, I had made very little arrangements to it (Labels, etc..).

      Will ship the whole to you, just a sign of gratitude for your cool work.

  • At 18 June 2012, 17:45:29 user Jugurtha wrote:   [reply @ Jugurtha]
    • @Giorgos Lazaridis

      Thanks for the prompt reply. I am almost done with the schematic, I didn't find the PIC16F526 in the library, nor anywhere else. I chose a generic 14 PIN socket and went through the datasheet of the PIC to get the connections right.

      Again, thank you for taking the time to answer me Giorgos. I appreciate.

      All my best,

  • At 18 June 2012, 17:36:19 user Giorgos Lazaridis wrote:   [reply @ Giorgos Lazaridis]
    • @Jugurtha i do not have the sch any more... old project. The image can be zoomed if you click on it, and the assembly files are also there.

  • At 18 June 2012, 14:33:09 user Jugurtha wrote:   [reply @ Jugurtha]
    • Hello,

      Do you happen to have the project files ? The sch & libraries.

      Thank you,

  • At 16 April 2012, 8:29:53 user Giorgos Lazaridis wrote:   [reply @ Giorgos Lazaridis]
    • @probe it is a simple 5V relay with 5A contacts, and the heater is connected to the X1-1 and X1-2 in series with the 220V

  • At 14 April 2012, 16:11:14 user probe wrote:   [reply @ probe]
    • @Giorgos Lazaridis

      what type of relay are you using and how did u connect the heater.

  • At 2 April 2012, 4:44:50 user Giorgos Lazaridis wrote:   [reply @ Giorgos Lazaridis]
    • @probe the pic has internal oscillator, no need for external crystal.

  • At 2 April 2012, 4:40:02 user probe wrote:   [reply @ probe]
    • did you have to use a crystal oscillator to run your chip?

  • At 26 March 2012, 5:24:19 user Giorgos Lazaridis wrote:   [reply @ Giorgos Lazaridis]
    • @bone i'm afraid you haven't deactivated the "case sensitive".

  • At 26 March 2012, 2:38:28 user bone wrote:   [reply @ bone]
    • hi, i am having trouble building your code on mplab. what is the value of passarg1-13 and waitcounter, waitcounter2. i think there are mistakes in the asm file.

  • At 21 March 2012, 8:02:06 user Giorgos Lazaridis wrote:   [reply @ Giorgos Lazaridis]
    • @probe it does not have the ability to change temeprqature, only if you change the software.

  • At 20 March 2012, 18:18:28 user probe wrote:   [reply @ probe]
    • does this circuit just work as a thermostat and thermometer because i want to have the ability to set it to a specific temperature manually

  • At 26 September 2011, 16:30:57 user Kammenos wrote:   [reply @ Kammenos]
    • @Ethan it is the coil of the relay

  • At 26 September 2011, 13:48:31 user Ethan wrote:   [reply @ Ethan]
    • I don't really understand the component below 2n2222.. what is that?

  • At 3 July 2011, 17:13:46 user Robert wrote:   [reply @ Robert]
    • hi there is a problem in the acm programing code is ther a updated one thats working

  • At 3 July 2011, 16:34:47 user Robert wrote:   [reply @ Robert]
    • hi ther is a problem in the .asm file is ther someone that can help?

  • At 12 June 2011, 7:25:23 user tot wrote:   [reply @ tot]
    • This is OK! Asm wrong somewhere, I do not know your Hex-paid.

  • At 11 June 2011, 11:17:40 user Kammenos wrote:   [reply @ Kammenos]
    • there are 2 registers, GLLowThreshold and GLHighThreshold. These are the values that you need to change.

  • At 10 June 2011, 19:56:02 user tot wrote:   [reply @ tot]
    • Kammenos HI! Thanks, I solved the problem, my browser did not support the download. Hex file is good, the switching temperature can not be rewritten, MPLAB asm file write error. Could some solution to the PROBLEM? thank you ......

  • At 10 June 2011, 18:04:14 user Kammenos wrote:   [reply @ Kammenos]
    • @tot the download works correct. there is something wrong with your browser. remove any script blocker or other protection. or use mozilla firefox to download it.

  • At 9 June 2011, 6:52:14 user tot wrote:   [reply @ tot]
    • Giorgos Hi! or who can help! Pic thermometer and thermostat built the project, but I can not download the HEX file. Please help. Enable download, MPLAB Asm file error, unfortunately I can not rewrite. Thank you for your help! László Tóth, Budapest, Hungary

  • At 15 March 2011, 9:37:19 user Sayan wrote:   [reply @ Sayan]
    • thank you for the quick reply!!

      And well im trying hard to learn, or and if i get stuck i can ask my college professor to program it for me. Trying to follow you tutorial in my spare time.
      i wish they taught PIC programming in mechanical engineering too.

  • At 15 March 2011, 6:59:54 user Kammenos wrote:   [reply @ Kammenos]
    • @Sayan yes leave pin12 unconnected is ok.
      Pin 13 is explained in the document above (section "The Circuit")
      If you lack of PIC programming knowledge, this is going to be tough...

  • At 14 March 2011, 18:02:45 user de.das.dude (Sayan) wrote:   [reply @ de.das.dude (Sayan)]
    • if i dont need to use the relay function, can i just not connect anything to the 12th pin?

      or is it i HAVE TO connect an LED like sir ou have done here??

      also i lack PIC programming knowledge.

      and what is pin number 13 for??

      i am planning on making a circuit for measuring PC Case temp.

      Thanking you for help. Keep up the good work !

  • At 12 April 2010, 4:32:31 user Kammenos wrote:   [reply @ Kammenos]
    • I am sorry, i programm in assembly.

  • At 12 April 2010, 2:41:38 user lizzy wrote:   [reply @ lizzy]
    • hello, how to store data temperature inside EEPROM code in c? can teach me?

    reddit this Reddit this

     HOT in heaven!

    NEW in heaven!

    New Theory: AC electric motor working principle

     Contact     Forum     Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science     RSS   

    Site design: Giorgos Lazaridis
    © Copyright 2008
    Please read the Terms of services and the Privacy policy