🇺🇦 Stand with Ukraine 🇺🇦

Blog

This is a private homepage... ;)

Arduino LM35 temperature sensor with LCD Display

Arduino Temp. Sensor & LCD

I added my LM35 Temperature Sensor to my Arduino again and added a display to show how hot it is... ;)

I have used the LM35 already some month ago; It is a very easy to setup device.

Here is my Code (UPADTE 2015.08.21; This is my final code.):

// Written 2015 by Johannes Findeisen <you@hanez.org>  #include <LiquidCrystal.h>  // Initialize the LCD code. Take care of the pins I use. The first two pins // are 12 and 11 in most examples around the web. I use pin 7 and 6 because of // nicer wiring on my breadboard. // Read this for more information: // https://www.arduino.cc/en/Tutorial/LiquidCrystal LiquidCrystal lcd(7, 6, 5, 4, 3, 2);  // Define how many samples should be collected every $collectDelay miliseconds. // After sample collection the temperature is beeing calculated and then // send to the LCD. int samples = 16;  // Collect delay between each sample. int collectDelay = 2000;  // The pin where the status LED is connected to. int ledPin = 13;  // The analog input pin where the LM35 is connected to. int tempPin = 0;  // Just some variable initializations. float tempC = 0; float tempClast = 0; float tempF = 0;  void setup() {   pinMode(ledPin, OUTPUT);   lcd.begin(16, 2);   // Get data for the first time.   // Read this to understand the temperature calculation:   // http://www.danielandrade.net/2008/07/05/temperature-sensor-arduino/   tempC = (5.0 * analogRead(tempPin) * 100.0) / 1024.0;   tempClast = tempC;   // Celsius to Fahrenheit conversion   tempF = (tempC * 9) / 5 + 32;   // Refresh the LCD output   lcd_refresh(); }  void loop() {   int i;   tempC = 0;   for(i = 0; i <= (samples - 1); i++) {     tempC = tempC + ((5.0 * analogRead(tempPin) * 100.0) / 1024.0);     digitalWrite(ledPin, HIGH);     delay((collectDelay / 2));    digitalWrite(ledPin, LOW);     delay((collectDelay / 2));   }   // Calculate temperature   tempC = tempC / (float)samples;   // Celsius to Fahrenheit conversion.   tempF = (tempC * 9) / 5 + 32;   // Print results to the display.   lcd_refresh();   // Remember current temperature for next run.   tempClast = tempC; }  // Prints results to the display void lcd_refresh() {   lcd.setCursor(0, 0);   lcd.print("Temperature");   lcd.print((char)40); // ASCII code 40 = "("   if(tempClast > tempC) {     lcd.print((char)60); // ASCII code 60 = "<"   } else if(tempClast < tempC) {     lcd.print((char)62); // ASCII code 62 = ">"   } else {     lcd.print((char)61); // ASCII code 61 = "="   }   lcd.print((char)41); // ASCII code 41 = ")"   lcd.print((char)58); // ASCII code 58 = ":"   lcd.setCursor(0, 1);   lcd.print(tempC);   lcd.print((char)223); // ASCII code 223 = "°"   lcd.print("C/");   lcd.print(tempF);   lcd.print((char)223); // ASCII code 223 = "°"   lcd.print("F"); }

Some other sources:

Have fun with it... ;)

My AVR Development Board

My AVR Development Board

I build a new dev board for my AVR and Arduino development. My old one really was too small... Since I am daily are working on the evaluation of all the nice and tiny IC's in my electronics box I needed this. Maybe it will become too small in some time but currently it helps me a lot.

It consists of two large breadboards and a wooden panel underneath with four rubber foots. I will work on optimizing this in the future and maybe I will write a document, describing how to build it like mine... ;)

Attiny13 Blink example

Image of Attiny13 MCUJust to keep and share the code... Here is the code for making a LED blink using an Attiny13 MCU from Atmel.

I got a package with about 30 AVR MCU's from different kind yesterday and now I will give them all a try. The next step using the Attiny13, is to build a thermometer with an RGB LED as an indicator for the temperature. As temperature sensor I will use the LT1025 chip which I tried some days ago. I got many logic IC's too so it will be a hackish time this december. I will post the code and circuit here in some days when everything is working properly... ;)

#include <avr/io.h> #include <util/delay.h>  #define LED_PIN PB4  int main(void) {    // Configure LED_PIN (PB4) as output   DDRB |= (1 << LED_PIN);    while (1) {     PORTB |= (1 << LED_PIN);     _delay_ms(500);     PORTB &= ~(1 << LED_PIN);     _delay_ms(500);   }    return 0; }

Have fun... ;)

Evaluating LT1025

Today I found a chip named LT1025. It is a Thermocouple Cold Junction Compensator from Linear Technology which is very easy to use for building temperature sensors for measurement and control and can also be used to convert a heat gradient into electricity.

It took about 5 minutes to get it working in the Arduino environment.

Just order some samples from Linear, they will send you one or two without charge... ;)

Evaluating 74HC238

Image of 74hc238 icI am currently working me thru my box of microchips and other electronic stuff. I found some 74HC238 IC's today and gave them a try. It was no very spectacular event but it's nice to know what I have laying around when starting the next AVR project.

The 74HC238 is a high speed CMOS 3 to 8 line decoder which makes it possible to control 8 outputs with only 3 input lines. You will find more information and the datasheet at Sparkfun.

I used it to control 8 LED's with my Arduino using just 3 output pins. Nothing worth to show you a photo... ;)

Pages

1 2 3 4 5 6 7 8 9 10 11 12 13 14

Page generated at: Sep 9, 2025 (CEST) using Jekyll & xw3 on GNU/Linux
NULL
Powered by: NULL