Hello people, it’s been a while since I have posted projects on this website. This semester was really busy, I didn’t have time to much else, but soon I will have my winter holiday (Here in the south our summer holiday is from December to February).
Today I am going to show you how to build a simple temperature sensor using one LM35 Precision Temperature Sensor and Arduino, so you can hookup on your future projects. The circuit will send serial information about the temperature so you can use on your computer, change the code as you will. I’m planning to build a temperature sensor with max/min + clock + LCD, and when I get it done, I will post here.
Parts:
- Arduino (You can use other microcontroller, but then you will need to change the code).
- LM35 Precision Centigrade Temperature Sensor, you can get from any electronic store. Here is the DATA SHEET.
- BreadBoard
Assembling:
This is a quick and simple step. Just connect the 5V output from Arduino to the 1st pin of the sensor, ground the 3rd pin and the 2nd one, you connect to the 0 Analog Input.
Down goes some pictures that may help you, click to enlarge:
Here is the Arduino Code, just upload it and check the Serial Communication Option.
You can also download the .pde HERE.
Anything just ask!!!
nice and quick project! 🙂
You rock man… Your website is awesome!
Hey Daniel,
I did almost the same thing back in May and posted it to LadyAda’s website. However, mine didn’t have the nice pictures yours has. Nice job.
http://forums.ladyada.net/viewtopic.php?t=5763
I don’t understand where the multiplying by 5 comes from here:
samples[i] = ( 5.0 * analogRead(pin) * 100.0) / 1024.0;
Cool Project, thanks!
Hello guys,
Cool and easy to understand circuit. Well done!
I have made a similar one as tutorial at my friend blog uchobby.com using Arduino adn LM35, including RPM fan control. I’ve used basicaly the same this as well as same formula to get temperature value. You can heck it out here:
http://www.uchobby.com/index.php/2007/09/23/arduino-temperature-controlled-pc-fan/
Also would be fun to check also by website (in spanish):
http://www.bricogeek.com
Best regards from spain and keep on the good work!
Oscar G.
Hi,
Thanks for sharing; it will be helpful to me. I’m working on a similar project. I used Silver’s code, mentioned above, to get me off the ground, but now I have to advance it and your code will help improve my understanding and capability, so thanks again.
Currently, I’m on the hunt for code that will display a bar graph in real time of the temperature data. So far, this has been daunting.
Regards,
Les
how many of the sensors can be connected to 1 arduino, and how long can the wires be? thanks, and sorry for the ignorance….
Great post!
I am also currently working on a similar project. I have the LM35 working and have just received my LCD 16 X 2 screen. Now to solder on the header pins….
How would you alter your code to not only give a readout of the temperature, but also turn something on and off like a small fan?
John,
Short answer:
The 5 refers to the 5v supply voltage.
Long answer:
The Analog to Digital Converter (ADC) compares a sample voltage to the supply voltage and provides a digital number based on 1024 steps. The formula (Sample Voltage * 1024 / Supply voltage) shows that 2.5volts * 1024 / 5volts would result in a digital number of 512 which is what we would expect for a voltage half the supply voltage.
To get the find the sample voltage from a digital number the formula is reversed (Digital number * supply voltage / 1024). So our count of 512 would give (512 * 5volts / 1024) and tell us that there is 2.5volts on the sample pin.
However, that doesn’t explain the 100 in his formula. That is there because the LM35 supplies 10 millivolts per degrees Celsius. So, let’s look at an example. The room temperature is 19 Celsius which means the LM35 supplies 190 millivolts, or .190volts. Putting that number into the first formula (.19volts * 1024 / 5volts) means we would expect to see a digital number of 39 on the analog pin. So let’s say we do get a reading of 39, what does the program do with it?
The formula in the program says ( 5volts * 39 * 100 / 1024) which equals 19 meaning 19 Celsius. As I said in my program, a close approximation of the temperature in Celsius can be found by dividing the input number by 2. Daniel’s program divides the number by 2.048 (5 * 100 / 1024) which is a little more accurate but because both programs are using integer values, the result is roughly the same. Use which ever formula you will be able to understand when reading your program six months from now. (grin)
Silver
I like this! I previously used a Dallas 18B20 sensor, which is far more accurate but works over a one-wire interface, making it tough to program. This seems plenty accurate enough, so I’ll give it a try!
Not that it makes much of a difference, but you really don’t require the array samples[i] to perform averaging. A single variable can easily be used to keep a running total, which can be zeroed out after each reading.
Hey,
Can you tell me how you connect the Arduino board to PC? What is the cost of that board?
Great tutorial! This makes a very nice and easily put together temperature sensor.
Didn’t you use any resistance from 5v to the temp sensor?
@Raj Just use a USB cable. It costs around U$34.
@Flavio No need to.
Just played with this and changed one thing:
Since the Arduino default vref is 5V, the analog read from 0 to 1024 represents 0 to 5V.
Changing the Vref to internal, means the Arduino will use 1.1V as a reference. This gives you more precision in the reading, and helps calm down the 19/20 degrees changes you see. the 0 to 1024 now represents 0 to 1.1V (So long as your arduino uses the ATmega168)
In your setup(), add this line:
analogReference(INTERNAL);
and your formula:
samples[i] = ( 5.0 * analogRead(pin) * 100.0) / 1024.0;
could be changed for simplicity to
samples[i] = ( analogRead(pin) * 500.0) / 1024.0;
and so you would update to
samples[i] = ( analogRead(pin) * 110.0) / 1024.0;
This will give you a more precise reading from the sensor. (Just don’t exceed 100 degrees Celsius with the sensor, as it will then generate a voltage higher than vref)
Also.. a delay(200) is quite enough of a delay between sample reads.. the sensor output is constant, so the 8 samples can be accomplished in 1/5 of the time. Just change your main loop delay to a higher value, something of the order of delay(5000).
At least here, I noticed a more stable operation.
If your arduino uses the ATmega8, the above will still give a more precise reading, but you will need to change the formula to:
samples[i] = ( analogRead(pin) * 256.0) / 1024.0;
which in this case could be simplified again to
samples[i] = analogRead(pin) / 4.0;
AnalogReference page:
http://www.arduino.cc/en/Reference/AnalogReference
I´m using ARDUINO Diecimila.
Will my LM35 sensor is faulty? For my reading in celcius have very high values, 99, 104 degrees ?
@Brutus great comment, I will take a look at that! Thanks for sharing!
Is there a way to make this sensor work for liquids, in particular pond water. what is the max length for a cable between board and sensor. I hope this string has not been abandoned.
SOLAR WATER HEATER PUMP CONTROLLER
I want to make a simplistic controller for a solar water heater pump, for a fish pond. It would consist of a solar water heater panel with an air temp sensor LM35 inside panel box. A 120VAC submersible pump, a 3000gal fish pond with a water temp sensor LM35 (waterproofed), and a controller box supplied by 120VAC.
The logic should be
1. If the pond water Temp is below ~75°F, and the Solar Panel Temp is above ~90°F, Turn ON AC to the pump.
2. If pond water Temp reaches ~80°F, Turn OFF pump
3. If pond water drops to ~68°F sound remote alarm
*Temperatures should be variables that can be adjusted
What do I need to make this controller and program it, I am thinking this is well within the capabilities of the Arduino board. But maybe someone has a better solution. I am a novice but have skills in board assembly but little programming experience.
is it possible to save the temperature readings to an SD card or USB flash drive?
@Michael Higgins, yes, it’s possible to do that, take a look gere: http://www.instructables.com/id/Waterproof-a-LM35-Temperature-Sensor
@action_owl Yep, on the web you will find information about that. I haven’t tried yet, but I want to do it too. If you do it, please share with us!! 😀
hey i tried using the same code and the sensor, the only problem i faced it it doesn’t show anything. I am working with arduino decimila 0011 is it anything related to software or the hardware ??
it just shows
Done uploding
Binary sketch size: 3578 bytes (of a 14336 byte maximum)
@dharmang After uploading, you must check the serial communication option. have you tried that?
This is great! I’m using your code to make an Arduino thermostat. Im going to use it to control the temperature in my Bull Snakes cage. But Im sure it would work great for a Kegerator or various other projects.
Heres what Ive come up with so far.
/*
An open-source LM35DZ Temperature Sensor for Arduino. This project will be enhanced on a regular basis
(cc) by Daniel Spillere Andrade , http://www.danielandrade.net
http://creativecommons.org/license/cc-gpl
*/
int heat = 2; // heater output on pin 2
int pin = 0; // analog pin
int tempc = 0, tempf = 0; // temperature variables
int samples[8]; // variables to make a better precision
int maxi = -100,mini = 100; // to start max/min temperature
int i;
void setup()
{
pinMode(heat, OUTPUT);
Serial.begin(9600);
backlightOn();
}
void loop()
{
for(i = 0;i maxi) {maxi = tempf;} // set max temperature
if(tempf = 85) {digitalWrite(heat, LOW); // turn heater off if temp is 85 or higher;
clearLCD();} // Removes HEATING from lcd
delay(10);
Serial.print(0xFE, BYTE);
Serial.print(128, BYTE); //position line 1 c1
Serial.print(tempf); //display Temp F data
delay(10);
Serial.print(0xFE, BYTE);
Serial.print(132, BYTE); //position line 1 c4
Serial.print(“fahrenheit”); //display Temp F
delay(10);
Serial.print(0xFE, BYTE);
Serial.print(192, BYTE); //position line 2 c1
Serial.print(tempc); //display Temp C data
delay(10);
Serial.print(0xFE, BYTE);
Serial.print(196, BYTE); //position line 2 c4
Serial.print(“Celsius”); //display Temp C
delay(10);
Serial.print(0xFE, BYTE);
Serial.print(148, BYTE); //position line 3 c1
Serial.print(“Max”); //display Temp Max
delay(10);
Serial.print(0xFE, BYTE);
Serial.print(152, BYTE); //position line 3 c4
Serial.print(maxi); //display Temp Max data
delay(10);
Serial.print(0xFE, BYTE);
Serial.print(212, BYTE); //position line 4 c1
Serial.print(“Min”); //display Temp Min
delay(10);
Serial.print(0xFE, BYTE);
Serial.print(216, BYTE); //position line 4 c4
Serial.print(mini); //display Temp Min data
tempc = 0;
delay(500); // delay before loop
}
void backlightOn(){ //turns on the backlight
Serial.print(0x7C, BYTE); //command flag for backlight stuff
Serial.print(157, BYTE); //light level 157 = 100% 128 = off
}
void clearLCD(){
Serial.print(0xFE, BYTE); //command flag
Serial.print(0x01, BYTE); //clear command.
}
hi again but i was thinking if you can guide me out with sending real time data on to web for temperature and humidity !!! through http://www.pachube.com !!!
I set up something similar with a LM34 (which reads in degrees F).
The device would overheat unless I put a current limiting resistor in series with the LM34. (10K at Vs). I don’t see the resistor on anyone else’s circuit, am I missing something?
Hi,
Would any one have any idea how to modify this to work with an LM135?
http://www.jaycar.com.au/products_uploaded/LM135.pdf
Thanks
Hey Paul,
This can easily be used with an LM335 (135,235). The only modification to the code is to subtract 273.15 from your samples[i]to convert from Kelvin to Celsius.
On the hardware side, you only use 2 pins with the LM335. Your reference voltage connects to the center( ) pin through a 2k2 resistor and the negative pin goes to ground, Analog 0 then connects directly to the center pin.
That’s the way I have things set up, and it seems to be working well.
How to do this with Temprature-Sensor SMT 160-30 ?
Hi Daniel,
Any progress on adding the LCD and RTC to this project yet? Im a noob and i will be using this as part of my own learning project.
Richard, not yet, right now I am traveling in USA, but this year I will do for sure! Thanks for reading!
The ladyada.net link shows the use of a resistor – your circuit doesn’t .. was it an omission or is it not needed?
Ok,
Just to reply to my own question. Without the resistor you will only be measuring temperatures of +2 Deg C to 150 Deg C. If you want to measure the full -55 Deg C to +150 Deg C you need the resistor.
@ScaredyCat Thanks for sharing this! 🙂
can i use zilog? what is the code when i use zilog?
pls help me by sending details about the arduino lilypad,for doing my project related to robotic textiles
You guys are so admirable that you can build a solution like this. I am in the market looking for a temperature sensor which can alert me should the temperature goes out of range. To do this, I want to use SNMP utilities to make query on the temperature and send email alert if it is too high. The SNMP utility will also log data and plot graph.
How can we further develop your project to make it SNMP ready? Am I asking for too much?
Hi, can you tell me what kind of temperature sensor you used? is it a 1K or 50? i want to try this project out and im buying the temp sensor you used. please email me back with the answer at Atoweha11@yahoo.com
thanks!
Hi, awesome tutorial !
I’m testing the code using an Arduino NANO and some LM35DZ-NS
The LM35 is hooked to 5v, Grd, A0
I’m getting “weird” temperature readings:
109 Celsius, 228 fahrenheit -> 109 Max, 100 Min
109 Celsius, 228 fahrenheit -> 109 Max, 100 Min
109 Celsius, 228 fahrenheit -> 109 Max, 100 Min
What can be the cause of this false reading ..?
Best regards
Good stuff, but I’m having a similar problem to Rudolph above – my temperature readings are all over the place. My room is warm, but I think I’d notice if it really was 415 deg C 🙂
>415 Celsius, 779 fahrenheit -> 416 Max, 100 Min
>415 Celsius, 779 fahrenheit -> 416 Max, 100 Min
I note in one of the entries above it says –
>Changing the Vref to internal, means the Arduino will use 1.1V as a reference. This gives you more precision in the reading, and helps calm down the 19/20 degrees changes you see. the 0 to 1024 now represents 0 to 1.1V (So long as your arduino uses the ATmega168)
I’m using a 328 – would that make a difference?
Hi
I don’t understand
i copy your sketch ( the first without LCD) but i obtain lot of warnings when i try to compil.( with Arduino v. 0017 )
for exemple this :
Serial.print(” fahrenheit -> “);
error: missing terminating ” character In function ‘void loop()’:
oups
sorry
i found the error with the “
@Edward
i have a lm335 and i try to do what you say , but i don’t understand
what is your your reference voltage ? 3,3 V or 5 Volts ? and why a resistance ? is the same with 3,3 v then with 5 v ?
why don’t use the pin Adjust on the LM335 ?
i connect as you say but the temp doesn’t move (with or without my finger on the lm335)
can you show me your code, please ?
Sorry for my bad english, I’m french….
ok , it’s good
@Brutus
i don’t understand how
this
samples[i] = ( analogRead(pin) * 500.0) / 1024.0;
you update to this:
samples[i] = ( analogRead(pin) * 110.0) / 1024.0;
@yalefe
you need to use the 5V for the code to work, otherwise the Analog-Digital converter will not work right.
Check the datasheet to see how many mV per temp.
The jumpy temperatures also come from the arduino not rounding for example
19.1 will become 19
and
19.6 will become 19
you can add 0.5 to your analog readout and with this you numbers get rounded
like this :
room_temp = ( analogRead(ro_temp) * 110.0) / 1024.0 0.5;
(using internal ref)
19.1 0.5 = 19.6 > 19
19.6 0.5 = 20.1 > 20
I’m so confused! I’m using the LM335AZ, and I’ve tried original method, and.. well realized it wasn’t the same part.. so that was no good! But then I tried Edwards post.. and again, it was just way off. The original(obviously) was very high, 230C, and after trying Edwards.. dropped down to too low, almost a -3C, and it’s not freezing(yet) in my room 😀
@Edward, when you connect it as you were saying, just the 2 pins, AREF to center pin through a 2.2k resistor, and ground, grounded, with the output pin between the resistor and the thermistor, are you changing the analogReference in software to anything? I tried (INTERNAL) and still, way off.
But great write up on the sensor in use, haha hope you don’t mind if I ask some questions!:X
i connect a LM335 and it’s good for me
i connect it as a calibrated sensor ( p. 4 on the datasheet : http://www.datasheetcatalog.org/datasheet/nationalsemiconductor/DS005698.PDF)
but when I try the changes proposed by Brutus (internal ref) is not working anymore
i don’t get it, im getting readings like this.
?¦?Ť??¦ä?îÄ????Dæb?¼¦?E¤??Îä??Ä????Dæ?¡¦?ÅX??¦ä??8???NDæb?½¦?ÅX??¦ä??D???FDæb
?¦æŤ??¦ä¶?Ä????´æb??¦?Å\??¦ä??$???NDæb??¦þŤ??¦ä¦?Ä???Ds1
Any one who knows what the problem can be?
@Anders, that’s strange! Check only the analogRead of your AD, to see if it’s working.
@Anders – you’ve got the wrong baud rate set. Try 9600
Hi,
I’ve been trying to get this working in exactly the same way as you did (also with arduino duemilanova).
I’m using the same code and hardware setup. Everything seems to be working just fine, but the temperatures i get are just not right, its giving me 71 degrees celcius when it should be like 20 degrees (room temperature).
I’ve tried different LM35’s but they all do the same, what am i overlooking here? any help would be appreciated!
I have a tip if you are powering through USB. Since it doesn’t go through the voltage regulator, and USB rarely gives exactly 5v, you need to adjust for the voltage your USB port puts out.
Change “samples[i] = ( 5.0 * analogRead(pin) * 100.0) / 1024.0;” to “samples[i] = ( voltage * analogRead(pin) * 100.0) / 1024.0;”
and at the top, add “float voltage = 5.0;”
Then measure the 5V and GND pins with a volt meter, and put in the actual voltage. In my case it was 4.71. This made my sensor (LM335) quite a bit more accurate.
@ Simon and Rudolph – my readings are … 307 Celsius, 584 fahrenheit, 307 Max, 100 Min, even after I tried Grant’s fix. I am using a Duemilanove atmega328. my usb voltage is 5.09
Also. if i put my fingers over the sensor, the temperature goes down, which is kinda good because, a fever of 300 C would be bad.
I have a question I’m using a teensy which uses a USB instead of a serial how could I modify the program?
Thanks in advance
@Diego, sorry, didn’t get what you are saying. Are you brazilian, if so. Fala em português mesmo. 😛
Danie, muito bom seu post!
Parabéns principalmente pela explicação da fórmula. Confesso que eu entendia mais ou menos essa parte. Agora ficou claro pra mim.
Abraço.
@Marcos , não esqueça de visitar o meu blog em português -> http://blog.danielandrade.net
Valeu
This works well via USB, but is all over the place when powered via the mains! (I’m reading the results via Ethernet).
Has anyone else experienced this?
Here shows what I mean (sample taken every minute)
http://tweetphoto.com/8634960
Ta
Ross
@Ross Amazing! Good job 🙂
If you want to have a decimal value (ie 22.6), you can do this:
for ( i = 0; i maxi) {maxi = tempc;} // set max temperature
if(tempc
Not sure what happened to my comment.
If you want to show 22.6 for temp, multiply your constants by 10 and then you can get them out when you report the data.
for ( i = 0; i
Hi there,
anyone used a 1N4148 diode for temperature sensor? I’m trying to get results but I don’t know how to convert the given voltage.
When you change Vref, the first reading isn’t correct so I added a void reading soon after analogReference():
void setup {
/* … */
analogReference(INTERNAL);
analogRead( analogPin );
/* … */
Good post. I put you in RSS now so I can see more from you sometime again.
For anyone who wants to plug an LM35 directly into the Arduino board here is a version that uses analog inputs only to power
the LM35 sensor.
/*
Reads from a LM35DZ connected directly to an Arduino
Also prints the temperature to the serial monitor.
The circuit:
* LM35 Vcc connected analog input pin 0
* LM35 Vout connected to analog input pin 1
* LM35 Gnd connected to analog input pin 2
created 13th March 2010
by Paul Hopkinson [Modified from an original Tom Igoe sketch]
*/
// These constants won’t change. They’re used to give names
// to the pins used:
const int analogInPin = 1; // Analog input pin that Vout of the LM35 is connected to
int sensorValue = 0; // value read from the LM35DZ
int TempInCelcius = 0; // Calculated temperature in Celcius
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop() {
// Setup analog port 0 as Vcc
pinMode(14, OUTPUT);
digitalWrite(14, HIGH);
// Setup analog port 2 as 0v
pinMode(16, OUTPUT);
digitalWrite(16, LOW);
// read the analog in value:
sensorValue = analogRead(analogInPin);
// Calculate Temperature in Celcius
TempInCelcius = ( 5.0 * analogRead(analogInPin) * 100.0) / 1024.0;
// print the results to the serial monitor:
Serial.print(“\n Temperature = ” );
Serial.print(TempInCelcius);
Serial.print(” Degrees c”);
// wait 1 second before the next temperature reading
delay(1000);
}
hw can i interfacw the lm 358 with lm 35 to achive maximum gain??/??/ just plz.. rpl.. as soon aa possible…….thank you…….
Hi everyone!
This code is great and simple for people like me just beginning with Arduino..
Could anyone tell me how to get also decimal values of temperature?
If I want to get 26.7 degrees or even better 26.78 degrees which part of the code do I have to modify? and how?..
Thanks!!!
Flavio,
That is not possible with this IC as it doesn’t have the required precision. You will be able to out put values to 2 decimal places but they will be incorrect you require a more accurate sensor.
If you find one that is fairly cheap please let me know as I am also interested.
Hi Hughesy!
Actually I’m using a LM35CAZ that is quite precise but I paid one sensor 10 euro. That’s ok for me ’cause I’m using it in a research project so I’ve a bit of money to spend on it..
But could someone help me and tell where and how to modify the code so that in my screen I’ll get a 27.7°C or better a 27.78°C instead of a no-decimal value like 27°C?…
Please!
Hi
You will need to change the variables that temperature values from int datatypes to double
i.e:
‘double samples[8];’ instead of ‘int samples[8];’
(int datatype only stores whole numbers)
Ben.
Simon – your positive and negative are backwards…
please tell me the coding for program, if lm35 detect 150 degree Celcius, fan will on, and if below it will turn off..please help me ?..thank
Opa, sei que você é brasileiro né ? Então, eu estou trabalhando em um projeto que tem 1 sensor, um dallas 18B20. eu tentei usar esse código que vc utilizou e ele me retorna uma leitura 0°C,32F,0K … o que está totalmente equivocado.Tem alguma noção do pq ele não está lendo corretamente ?
Da uma olhada no datasheet do sensor, e ajusta os cálculos que deve funcionar!
Hello.
What is the maximum distance between the temperature sensor and arduino can be?
Dear sir
Can You tell me How can i keep milk at 35 degree centegrade in a electrical cooker
For all the day
thank u
shiji
Hi can this temperature sensor work on ATmega328?
Hi, thanks for doing this – very neat!
just minor note: the for loop in the code at the moment has a space that needs to be removed ‘i< =7' should be '1<=7'
🙂
oops sorry that should read: ‘i< =7' should be 'i<=7'
@Jason yes it will!!
@Ben thanks, I’ll fix that! ^
I am a beginner at using the Arduino Uno, and I hope you can help me with something that I am having trouble with. I used some of your code for a LM335 temperature sensor that I am using. I have made a buffer circuit to convert the 10mV/K into a degrees celsius circuit. The circuit outputs for 0 degrees and 100 degrees is 2.73V and 3.73V respectively; but I am having problems getting the arduino to display the temperature. Could you look at my code at tell me if I did something wrong? Where should my voltage from my circuit go into the Arduino (A0 pin?) Can you help me?
int pin = 0; //analog pin
int tempc = 0;
void setup()
{
Serial.begin(9600); //start serial communication
}
void loop()
{
tempc = (5 * analogRead(pin)*100)/1024;
delay(1000);
Serial.print(tempc, DEC);
Serial.print(” Celsius”);
delay(1000);
}
hello , i have built it and work greate
but any body develop software to read from ardino direact
thank you
Hi i m having a ardunio Uno board n i uploaded the code but i m getting strange output
287 Celsius, 548 fahrenheit -> 288 Max, 100 Min
287 Celsius, 548 fahrenheit -> 288 Max, 100 Min
i have tried other options + i have changed lm35 and tested it again but its the same.
plz help
I got the same problem as yours, have you figure out the solution? could you please share it with me? Thanks.
hello,
i was wondering if i could use this type of sensor to measure a water temperature, because i am using an arduino to control the water flood of a jaccuzi.
thxxx and greetings from Jens
heya..can anyone plz tell me dat can i use GH 311 ultrasonic tranciever module for temperature measurement?? earlier i used TS 601 and it worked quite well.
can anyone tell me the coding..!!!
Hi. Please forgive my ignorance.
OK. In the ADC section of page 263 of the instruction manual of the ATmega 328P it speaks of a Temperature sensor. Do they mean internal temperature sensor? Or is it a special channel reserved to connect a Temperature sensor?
I am building a Temperature data logger using an LM35DZ sensor. Is there a need to connect the temperature sensor to a dual op-amp LM358, to amplify the signal and detect very small temperature variations? Or is it that the Freeduino v 1.22 with the ATmega 328P will be able to detect the very small variations in Temperature? If so, how? Is it because of a fast sampling rate of the microcontroller ADC that the small variations will be able to be picked up? I see you have connected the sensor directly to the Freeduino.
What range of input DC voltage can I connect to the Freeduino v1.22? Because I can’t afford to fry my Freeduino.
Thanks
Hello,
I reviewed your code that you have posted on your site (http://www.danielandrade.net/2008/07/05/temperature-sensor-arduino/). I am generating a code that is similar to yours. My only question is, how would I go about storing data every 5 minutes, for 12 hours? I will appreciate it if you can get back to me at your earliest convenience.
Thank you,
Harparas Kaur
@Harparas Well, you can do in many different ways, one which I think is the easy one, is to connect the arduino to the computer and with an processing program. http://electronics.stackexchange.com/questions/54/saving-arduino-sensor-data-to-a-text-file
You want to store 144, you can save it on a array. But then it will be stored in the RAM, and deleted every time you reset the µC
You can also use an EEPROM, that will save the information on ROM, that will not be deleted when restarting. Here you get more infos: http://arduino.cc/playground/Code/EEPROMLoadAndSaveSettings
Hope I have helped!
Daniel
Thank you! i will try it.
Just a heads up – if you cut and paste code from the comments here to the Arduino V1.0 IDE, and it was posted with a non-US-English keyboard, and you are using a US-English keyboard, you will get strange errors when you try to compile. Errors like ” stray ‘\’ in program” or “expected `)’ before ‘u00d701′”. These seem to be caused by differences in the code pages. Some of these are caused by the ” character specifically in Serial.print(“something”); lines. Delete the ” and retype it. I suspect some ( or ) were causing problems but couldn’t verify. Can’t speak for any other keyboard combinations.
Just something to watch for if you’re getting strange compile errors.
PCK
Hi there.
I am thinking about using this setup, however I have a question that I am not able to easily find the answer to:
I am already using the Arduino (Uno) to pilot [4] servos, is it possible to upload your sketch on the same device and have both servo controls (via USB) and temperature being fed back to the computer for treatment at the same time?
Many thanks if you’re able to answer.
P.S. the servo control comes from this URL:
http://principialabs.com/arduino-python-4-axis-servo-control/
Gilbert
Hello Gilbert, what you could do is first make the program read the temperature, then try to join them together, doing this way I think you will be able to make it with no problem.
I was taking a look at the code, maybe you could also add a CASE that reads the temperature and sends to the computer.
🙂
Hi Guys,
Please what exactly does this line do?:
samples[i] = ( 5.0 * analogRead(pin) * 100.0) / 1024.0;
Thank you
On SI the word “Centigrade” doesn’t exists !
The correct name in SI is CELSIUS…
“Centigrade” is the 100th part of a degree,
and means nothing on this temperature’s
measurements.
When they use the correct terminology ?
( I say it to TEXAS and NATIONAL, too… )
Regards,
PP5VX (Bone)
PP5VX de KF7PCL
I feel the same way. I really do not understand why people call it centigrade.
Celsius is the correct term.
As far as the original post goes, I wonder if it is possible to use floating point to get more precise measurements? With a 10 bit ADC, it should be accurate to atleast 0.5*C.
73 KF7PCL / John
thanks works very fine, i want to use it on a diy project (Heat recovery system)
sir what kind of arduino did you use?
Hi!
I’m making a project with an sht15-sensor. Do you know how to program it if i want an alarm for example if temperature is over 20oC (68 F)? I have tried but can’t get the function correct. Please help.
i want program of temperature sensor pt100 with arduino freeduino atmega 328..
pt100
Hey @john,
That line takes a sample reading(given in ohms(we are reading from a thermistor)) and converts it to a temperature, then adds it to an array called samples to be averaged in the next step.
We’re a group of volunteers and opening a new scheme in our community.
Your web site offered us with valuable information to work on. You have done an impressive job and our entire community will be grateful to you.
Hello ! I don’t know if somebody will answer me but I try !
Do you think it is possible to use an Arduino Nano for this system ?
Thank you very much !
Yes yon can! You can use any arduino or microcontroller with an ADC port.
Please help me in program to ATmega328 connected with LCD 16*2 dispaly and LM35 sensor.
I want a code like this but for water level controller… helpe me please
Hello sir nice and quick project, but I am the beginner for arduino the same code which i have uploded in my Richduino Board
I am getting this error
expected primary-expression before ‘=’ token
sketch_mar26a.ino: In function ‘void loop()’:
sketch_mar26a:16: error: expected primary-expression before ‘=’ token
for the line
for(i = 0;i< =7;i++){ // gets 8 samples of temperature
please help me
thank you very much