loading
Hello everybody! I will be showing you how to make a digital 7-segment thermometer using the LM335 temperature sensor.

This a guide for an Arduino version, but I am working on a mini ATtiny84 version. Once I get that working, I will post another Instructable on how to make it.

I'm sure you could make this same thermometer with an LM35 also, if that's what you have, and you probably won't have to modify the code.

This is an entry in both the LED contest with Elemental LED and the Hurricane Lasers contest, so if you like it, vote for it! Thanks!

Also, I am considering starting an electronics kit business to sell kits for the Instructables that I make, so if you like the idea, drop a comment or PM me!

Step 1: Parts List

Here are the things you will need for this project. You can get all these parts from a wholesale supplier like Mouser or Digi-Key for around $10-$15 or less, except for the Arduino board. You can get this from Mouser for around $30.

Parts:
1x Arduino Uno/Duemilanove/maybe Diecimila or equivalent
1x LM335 temperature sensor (I'm sure you could make it work with a LM35 too)
2x Single digit 7-segment display, common cathode (or a single 2 digit one)
1x 2.2k ohm resistor (not sure if you need this if you are using an LM35)
Jumper wires

Tools:
USB A-B cable
Breadboard

Step 2: Program the Arduino

The code I wrote requires you to have the Arduino Seven Segment library installed. To do this, go here and download all the files by going to "File>Download" at the top of the page.

Then locate you Arduino sketchbook folder (should be located in "Documents>Arduino" on Windows) and create a folder called "hardware" if there isn't already one. Go in that folder, and paste the folder you downloaded before into the "hardware" folder.

It should not be in a .zip or .rar format, which it will most likely come as when you download it, you must extract the entire folder and place it in the hardware folder.


After you installed the library, upload the code below to the Arduino board, and proceed to the next step.


#include "SevSeg.h"

SevSeg sevseg;

int tempUnits = fahrenheit; //which unit of temperature do you prefer?

int refreshTime = 5000; //how many seconds should it wait before it checks and displays the temp again? 1000 = 1 second

unsigned long timer;
float celsius = 0, kelvin = 0, fahrenheit = 0;

void setup()
{
  sevseg.Begin(0,2,3,4,5,6,7,8,9,10,11,12,13);
}

void loop()
{
  sevseg.PrintOutput();
 
  //Reads the input and converts it to Kelvin degrees
  kelvin = analogRead(0) * 0.004882812 * 100;
 
  //Converts Kelvin to Celsius minus 2.5 degrees error
  celsius = kelvin - 2.5 - 273.15;
 
  //Converts Celsius to Fahrenheit minus 2.5 degrees error
  fahrenheit = ((kelvin - 2.5) * 9 / 5) - 459.67;
   
  unsigned long mils=millis();
  if (mils-timer>=refreshTime) {
    timer=mils;
    //Print teperature to the displays
  sevseg.NewNum(tempUnits,(byte) 2);
  }
}

Step 3: Modify the Code to Use a Common Anode Display (optional)

Changing the code to work with a common anode display is simple. Change this line of code:

sevseg.Begin(0,2,3,4,5,6,7,8,9,10,11,12,13);

to:

sevseg.Begin(1,2,3,4,5,6,7,8,9,10,11,12,13);

Step 4: Change the Units and Refresh Time (optional)

To change the units of the temperature displayed to Celsius or back to Fahrenheit, change the line of code at the top that says:

int tempUnits = fahrenheit;

to:

int tempUnits = celsius;

if you prefer Celsius.

To change the rate at which the display updates the temperature, change the line of code at the top that says:

int refreshTime = 5000;

to:

int refreshTime = <however many seconds you want it to wait before updating * 1000>;

The code is set to refresh every 5 seconds by default. If you put a number that is too low, it will update so fast that you won't be able to read it.

Step 5: Put It Together!

Here is the schematic for the thermometer. I made mine on a breadboard.

Step 6: Done!

Plug it in and it should display the temperature in Fahrenheit or Celsius, depending on which unit you chose.

Done!
<p>I made it with LM35 and thank you! but the code did not work.SevSeg.h header file is now updated and i downloaded the old version.If not the old version, it will not verify and upload.I edited some....</p><p>#include &quot;SevSeg.h&quot;<br><br>SevSeg sevseg;<br><br>unsigned long timer;<br>float celsius = 0;<br>int refreshTime = 5000; //how many seconds should it wait before it checks and displays the temp again? 1000 = 1 second<br><br>void setup()<br>{<br> sevseg.Begin(0,2,3,4,5,6,7,8,9,10,11,12,13);<br>}<br><br>void loop()<br>{<br> sevseg.PrintOutput();<br> celsius = analogRead(0);<br>float mv = ( celsius/1024.0)*5000;<br>float cel = mv/10;<br><br>unsigned long mils=millis();<br> if (mils-timer&gt;=refreshTime) {<br> timer=mils;<br> //Print teperature to the displays<br> sevseg.NewNum(cel,(byte) 2);<br> }<br>}</p><p>thank u ...</p>
<p>Please help. I unable to compile the above code an I don't have SevSeg.h file.</p>
<p>Hey There !! Nice Tutorial, Please Send Code to edunhenry@yahoo.com, Thanks :)</p>
<p>Ok I modify some things on the code and got it work on a LM35, If anyone want the code just reply this comment and I let you know.</p><p>Great job in this project, thank you. Helped a lot!</p>
<p>Hello, can you please send me the code?</p>
<p>hello. I used your lm35 modified code in a larger project sוrrouding the lm35, I wanted to ask for an explanation of every line in the code to help me understand it better.(i'm a student it is for my final project) leshetzlee@gmail.com</p>
<p>I need code rpd1210@gmail.com</p>
<p>i need code </p><p>saxenanoop@gmail.com</p>
<p>will you please to help he.i have LM35 . can you sent the code to me</p>
<p>Read the comment i send to @SaironN, theres the code.</p>
<p>I want to know please!! <br>vih_neta@hotmail.com</p>
<p>I don't send by email, but I let you know here :D</p><p>#include &quot;SevSeg.h&quot;<br><br>SevSeg sevseg;<br><br>int refreshTime = 2000; //how many seconds should it wait before it checks and displays the temp again? 1000 = 1 second<br><br>unsigned long timer;<br>float celsius = 0, kelvin = 0, fahrenheit = 0;<br><br>void setup()<br>{<br>sevseg.Begin(1,2,3,4,5,6,7,8,9,10,11,12,13);<br>}<br><br>void loop()<br>{<br>sevseg.PrintOutput();<br><br>//LM35 code to display celsius<br>celsius = (5.0 * analogRead(0) * 100.0) / 1024;<br><br>unsigned long mils=millis();<br>if (mils-timer&gt;=refreshTime) {<br>timer=mils;<br>//Print teperature to the displays<br>sevseg.NewNum(celsius,(byte) 2);<br>}<br>} </p><p>Thanks to :</p><p><a href="https://www.instructables.com/member/xBacon/" rel="nofollow">salexandridis</a></p><p><a href="https://www.instructables.com/member/xBacon/" rel="nofollow">xBacon</a></p><p></p>
<p>Took me a while to know how this is done but it was mostly adding the library the author included on the libraries folder and wiring it as the diagram says.</p><p>Using this as my 5th semester final project on the 2nd submodule.. Wish me luck!</p>
<p>i want to use a 3 digit 7 seg display instead of 2 digits . what is the code for it?</p>
Hi.i 'd like if someone help me to modify the code so it can mesure temperatures from -20 to any other.<br>Thank you in advance.
<p>hello i try many time but still hv problem for uploading this code</p>
<p>hello may i know why serial.begin(1,2,3,4,5,6,7,8,9,10,11,12,13);totally hv 13pin? because what i know is 2digit + A to dot just only need 10pin, can u please explain for more detail thank you.</p>
<p>The code won't let me upload to my arduino because its saying Fahrenheit isn't defined in this scope. How should I fix this? </p>
<p>no works sorry bad code</p>
<p>Same Here..</p>
I want this, send to me please dianneschuur@gmail.com
<p>does this work? i'm having a common cathode display</p>
<p>@salexandridis has made the proper code. Check my instructable(PING with 2 LED seven segment displays) for the proper diagram if you have any difficulties in assembling the project.</p>
It seems that Mr/Mrs xBacon is unwilling to answer any question related to this instructable. He/She obviously doesn't even read the comments....or his/her inbox! So, that's why I undertook to search and evntually find the solution to the 'Zeros Problem&quot; ! Here's the CORRECT, 100% WORKING code: <br> <br>#include &quot;SevSeg.h&quot; <br> <br>SevSeg sevseg; <br> <br>int refreshTime = 2000; //how many seconds should it wait before it checks and displays the temp again? 1000 = 1 second <br> <br>unsigned long timer; <br>float celsius = 0, kelvin = 0, fahrenheit = 0; <br> <br>void setup() <br>{ <br>sevseg.Begin(0,2,3,4,5,6,7,8,9,10,11,12,13); <br>} <br> <br>void loop() <br>{ <br>sevseg.PrintOutput(); <br> <br>//Reads the input and converts it to Kelvin degrees <br>kelvin = analogRead(0) * 0.004882812 * 100; <br> <br>//Converts Kelvin to Celsius minus 2.5 degrees error <br>celsius = kelvin - 2.5 - 273.15; <br> <br>//Converts Kelvin to Fahrenheit minus 2.5 degrees error <br>fahrenheit = ((kelvin - 2.5) * 9 / 5) - 459.67; <br> <br>unsigned long mils=millis(); <br>if (mils-timer&gt;=refreshTime) { <br>timer=mils; <br>//Print teperature to the displays <br>sevseg.NewNum(celsius,(byte) 2); <br>} <br>} <br> <br>If you want to change the unit of temperature, all you have to do is to change the last command: sevseg.NewNum(celsius,(byte) 2); <br>Instead of &quot;celsius&quot;, you can type &quot;fahrenheit&quot; or &quot;kelvin&quot;. It seems that all this &quot;tempUnits&quot; thing doesn't work, so I totally excluded it from the code. <br>You may also change the delay by following the steps of this instructabe. <br>Have fun!
<p>is it possible to display the readings on serail as well as on the LED Dsiplay?</p><p>I've tried but I can only get one or the other but not both.</p>
<p>is it possible to display the readings on serail as well as on the LED Dsiplay?</p><p>I've tried but I can only get one or the other but not both.</p>
<p>Shouldn't there be resistors connect for each LED in the 7-Segment Display ? </p>
<p>thank you</p>
<p>ythghgd</p>
how exactly do i wire all this up? the image is blurry and i really dont get the schematic. Can anyone please help??
Love the simplicity of your project. I'm trying to make this work but it only gives zeros. The wiring is correct. Is the sketch missing something? <br>Thx.
I get the 0s too. There are no problems in wiring and I'm using the LM335.
professorred <br> <br>did you use this wiring diagram? <br>http://mysite.du.edu/~etuttle/electron/circ186.gif
if i want to add a 3rd digit 7 segment, the common cathode is connected to D3? <br> <br>more importantly, will you be selling/making ready-made pcbs? it would be alot easier than buying a prototyping board and using crude solder traces.
Hi! I've tried doing this. It seems I wired everything correctly. However, it displays &quot;00.&quot; I'm using a LM335 temp sensor with common cathode 7-segment as you've done in your demonstration. Is this a problem with the sensor? do I need to calibrate it? thanks!
Can it work with individual 7-seg displays?
Is there supposed to be seven series resistors in line with each segment on the display?
can it work with 3 digit 7-segment?? thanks in advance.
Yes, it can work with that. Since the 3 digit is already multiplexed, you just connect the segment pins to the arduino, and the first 2 digit pins to the arduino. It should work then.
Hi. No matter how I set up the LM35, I am getting a result of 00. I am not sure what is going on. Thank you.
you must use the LM335, not the LM35.
Ah. I was wondering because of the line in the parts list that mentioned that it should work with the LM35 but thank you. :)
well, it should work if you connect the lm35 in the correct way. the connections are different for the lm35 and he lm335. try going on google and searching &quot;lm35 arduino&quot; and you should come up with a circuit diagram. just follow the diagram and connect it to the analog input used in the sketch.
Hi. I copied and pasted the code to my arduino program and when I hit verify, it came up with an error saying Fahrenheit was not declared in this scope. Please help. Thank you.
Try moving the line:<br><br>int tempUnits = fahrenheit;<br><br>to under the line that says:<br><br>float celsius = 0, kelvin = 0, fahrenheit = 0;<br><br>Tell me if this works.
Thank you much. That worked like a charm. Now to build it. Thanks again. <br>
No problem :)
Do you have any further plans for this project? Are you going to use the thermometer for anything?
I am working on developing a version of this that runs on an ATtiny84 or ATtiny44 chip. I am designing the PCB in Eagle as we speak, and last night I ordered the parts to prototype it on a breadboard. <br> <br>I was thinking about making a waterproof and or heatproof version that is wireless (maybe xBee).

About This Instructable

78,514views

62favorites

License:

Bio: I'm a big Arduino fan. I'm always looking for new and exciting things to do with electronics and Arduino. I also like video ... More »
More by xBacon:DIY Infrared Proximity Sensor (Arduino Compatible) Color Changing LED Tree Plug-in LED Color Fading Night Light 
Add instructable to: