LM35 is a temperature sensor from National Semiconductor that have a high accuracy. The output of analog voltage and has a measurement range of -55 º C to +150 º C with an accuracy of ± 0.5 º C. Output voltage is 10mV / º C. Output ports can be directly connected to Arduino, because Arduino has 6 ADC ports (analog input).
Analog inputs on the Arduino has a 10-bit resolution, which can provide output 2 ^ 10 = 1024 discrete values. When used 5V supply, the resulting resolution is 5000mV/1024 = 4.8mV. Because the LM35 has a resolution output of 10mV / º C, then the resolution of the thermometer are made with Arduino is 10mV/4.8mV ~ 0.5 º C.
So, let make a simple temperature sensor with Arduino and LM35. After we connect the LM35 with the Arduino as in the picture above, we can start write the program.
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 | // variable declare float tempC; int tempPin = 0; void setup() { Serial.begin(9600); // Open serial port, set baud rate 9600 bps } void loop() { tempC = analogRead(tempPin); // Read data from sensor tempC = (5.0 * tempC * 100.0)/1024.0; // convert from analog to temperature Serial.println(( int )tempC,DEC); // send data via serial delay(1000); // delay } |
This program will read temperature data from LM35 and conversion the analog data to digital and write it to PC in celcius through Serial port.
No comments:
Post a Comment