Arduino-Based Temperature Sensor Introduction This report presents the implementation of a temperature measurement system that incorporates the Arduino UNO microcontroller, simply referred to here as the Arduino. The first part of this project presented in this report was implemented using a temperature sensor and made use of two 74HC595 shift register integrated chips paired with LED’s to display the temperature. To accomplish this, the temperature sensor provided an analog input to the Arduino to then be processed by the pair of shift registers outputting to the LED’s. Arduino. Shift Registers, and LED’s The hardware for the temperature measurement system included a temperature sensor that attached to an analog output of the Arduino. The temperature sensor used with the Arduino is the LM35CZ temperature sensor. The circuit was wired as seen in Figure 1 below. Figure 1. Arduino + Temp Sensor Configuration The console output displayed in Figure 2 below shows that the temperature sensor itself worked accurately, reading the current temperature in the office. Figure 2. Console Display of Temperature Reading Using LC35CZ Figure 3 below shows the actual circuit with the temperature sensor wired correctly with the resistor. Adding the resistor kept the temperature sensor from overheating.
26
Embed
Arduino-Based Temperature Sensor · Arduino-Based Temperature Sensor Introduction This report presents the implementation of a temperature measurement system that incorporates the
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Arduino-Based Temperature Sensor
Introduction This report presents the implementation of a temperature measurement system that
incorporates the Arduino UNO microcontroller, simply referred to here as the Arduino. The first part of this project presented in this report was implemented using a
temperature sensor and made use of two 74HC595 shift register integrated chips paired with LED’s to display the temperature. To accomplish this, the temperature sensor provided an analog input to the Arduino to then be processed by the pair of shift registers outputting to the LED’s.
Arduino. Shift Registers, and LED’s
The hardware for the temperature measurement system included a temperature sensor that attached to an analog output of the Arduino. The temperature sensor used with the Arduino is the LM35CZ temperature sensor. The circuit was wired as seen in Figure 1 below.
Figure 1. Arduino + Temp Sensor Configuration
The console output displayed in Figure 2 below shows that the temperature sensor itself worked accurately, reading the current temperature in the office.
Figure 2. Console Display of Temperature Reading Using LC35CZ
Figure 3 below shows the actual circuit with the temperature sensor wired correctly
with the resistor. Adding the resistor kept the temperature sensor from overheating.
Figure 3. Actual Circuit + Temp Sensor + 10kΩ Resistor
Adding Shift Registers Leads to Troubleshooting
The next step was to add the two shift registers to the temperature sensor, Arduino, and wire the setup for the LED display. The article used was from Mahesh Venkitachalam’s blog titled Nuts About Electronics. Mahesh’s blog provided another link to an Arduino tutorial that described in detail how to wire and code the 74HC595 shift registers as well as describing how they function. Because a total of fourteen bits were needed to display the digits correctly on the LED’s, the shift registers could be used while only using up three output pins on the Arduino.
Once the shift registers and LED’s were wired according to the Arduino ShiftOut examples, the code provided in Mahesh’s blog with the code from Daniel Andrade’s blog were merged together to convert the code at an attempt to display the temperature reading in both the console and the LED’s for troubleshooting. Mahesh’s code would have to be modified slightly. Upon uploading the code to the Arduino circuit, the seven digits on the LED’s would light up. This is seen in Figure 4 below. All the digits turned on and they were functional.
Figure 4. Arduino wired to Shift Registers and LED’s
Yλοποίηση από Ανδρέα Τσιγκόπουλο Χρησιμοποίησα 2xdigit 7-segment display κοινής καθόδου το οποίο ταιριάζει απόλυτα με τον κώδικα που δίνει ο συγγραφέας παρακάτω. Το manual 2xdigit 7-segment display (MAN6940 δίνεται στο αρχείο: 7-SEGMENT DISPLAYS MAN6940.pdf). Οι 2 shift registers που χρησιμοποιούνται είναι οι 74HC595 και το manual τους δίνεται στο αρχείο: 74HC_HCT595-1.pdf. Η αντιστοιχία των Pins για τον πρώτο (αριστερό) shift-register που συνδέεται στο αριστερό digit είναι: Q0 → DP (4) Q1 → a (16) Q2 → b (15) Q3 → c (3) Q4 → d (2) Q5 → e (1) Q6 → f (18) Q7 → g (17) Η αντιστοιχία των pins για τον δεύτερο (δεξιό) shift-register που συνδέεται στο δεξιό digit είναι: Q0 → DP (9) Q1 → a (11) Q2 → b (10) Q3 → c (8) Q4 → d (6) Q5 → e (5) Q6 → f (12) Q7 → g (7) Τα pins 13 και 14 του 2xdigit 7-segment display MAN6940 συνδέονται στη γη. Η έξοδος (pin 9) serial data output του πρώτου (αριστερού) shift register 74HC595 συνδέεται με την είσοδο (pin 14) serial data input του δεύτερου (δεξιού) shift register 74HC595. To pin 8 των 74HC595 στη γη. To pin 16 των 74HC595 στα 5V. To pin 13 των 74HC595 στη γη. To pin 10 των 74HC595 στα 5V. To pin 14 του αριστερού 74HC595 στο digital pin 11 του Arduino. To pin 11 του αριστερού 74HC595 στο digital pin 12 του Arduino και στο pin 11 του δεξιού 74HC595. To pin 12 του αριστερού 74HC595 στο digital pin 8 του Arduino και στο pin 12 του δεξιού 74HC595. Το pin 9 του δεξιού 74HC595 και τα pins 15 και των δύο 74HC595 είναι στον αέρα.
Παράλληλα με τους ακροδέκτες γης και τροφοδοσίας του αισθητήρα θερμοκρασίας LM35DZ συνέδεσα αντίσταση 10 kΩ, για να μην υπερθερμανθεί και καεί. Aυτά είναι τα links που χρησιμοποίησα: http://www.arduino.cc/en/Tutorial/ShiftOut http://www.danielandrade.net/2008/07/05/temperature-sensor-arduino/ http://electro-nut.blogspot.gr/2009/07/arduino-based-temperature-display.html Στην επόμενη σελίδα είναι ο κώδικας που τελικά δούλεψε. Υπάρχουν 8 διαφορετικές περιπτώσεις, τις οποίες εξέτασα και δίνουν τα εξής αποτελέσματα:
1) Κωδικοποίηση Michelle, ΜSBFIRST, dig[1] – dig[0] : δείχνει upsightdown, και σωστά το αποτέλεσμα.
2) Κωδικοποίηση Michelle, ΜSBFIRST, dig[0] – dig[1] : δείχνει upsightdown, και ανάποδα τη σειρά των ψηφίων, δηλαδή πρώτα το LSB και μετά το MSB.
Άρα, οι μόνες σωστές υλοποιήσεις είναι οι: (1) και (6).
/* * TempDisplay * by MV - http://electro-nut.blogspot.com/ * * Displaying ambient temeprature on a 2 x Common Cathode 7-Segment Displays * Using 74HC595 shift register and the shiftOut() built in function * Using LM35 to sense temperature. * * REFERENCES * * http://www.arduino.cc/en/Tutorial/ShiftOut * */ // set this to 1 to run 99-0 countdown #define TEST_MODE 0 int val = 0; // variable to store the value coming from the sensor int lm35Pin = 0; int DEBUG = 1; //Pin connected to ST_CP of 74HC595 int latchPin = 8; //Pin connected to SH_CP of 74HC595 int clockPin = 12; ////Pin connected to DS of 74HC595 int dataPin = 11; // 7-segment digits 0-9 // 74HC595-->7-Segment pin Mapping: // Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7 --> DP, a, b, c, d, e, f, g //Κωδικοποίηση σύμφωνα με Michelle Rivera //byte digits[ ] = //B01111110, B01100000, B10110110, B11110010, B11101000, B11011010, //B11011110, B01110000, B11111110, B11111010; //Κωδικοποίηση σύμφωνα με Mahesh Venkitachalam byte digits[] = B01111110, B00110000, B01101101, B01111001, B00110011, B01011011, B01011111, B01110000, B01111111, B01111011; // set up void setup() if(DEBUG) Serial.begin(9600); //set pins to output because they are addressed in the main loop
pinMode(latchPin, OUTPUT); pinMode(clockPin, OUTPUT); pinMode(dataPin, OUTPUT); // Main loop void loop() #ifdef _TEST_MODE countDown(); #else // read the value from LM35. // read 10 values for averaging. val = 0; for(int i = 0; i < 10; i++) val += analogRead(lm35Pin); delay(500); // convert to temp: // temp value is in 0-1023 range // LM35 outputs 10mV/degree C. ie, 1 Volt => 100 degrees C // So Temp = (avg_val/1023)*5 Volts * 100 degrees/Volt float temp = val*50.0/1023.0; int tempInt = (int)temp; //float tempf = (temp * 9)/ 5 + 32;//converts to fahrenheit //int tempInt = (int)tempf; displayNum(tempInt); // serial output for debugging if(DEBUG) Serial.println(temp); #endif // Display 2 digit number void displayNum(int num) // get digit 0 int dig0 = num % 10; // get digit 1 int dig1 = (num/10) % 10; // shift out digits digitalWrite(latchPin, LOW); shiftOut(dataPin, clockPin, LSBFIRST, digits[dig0]);
shiftOut(dataPin, clockPin, LSBFIRST, digits[dig1]); digitalWrite(latchPin, HIGH); // test function to count down from 99 to 0 void countDown() // display numbers for(int i = 0; i < 100; i++) displayNum(100-i); delay(500);
http://www.arduino.cc/en/Tutorial/ShiftOut
Serial to Parallel Shifting-Out with a 74HC595 Started by Carlyn Maw and Tom Igoe Nov, 06
Shifting Out & the 595 chip
At sometime or another you may run out of pins on your Arduino board and need to extend it with shift registers. This example is
based on the 74HC595. The datasheet refers to the 74HC595 as an "8-bit serial-in, serial or parallel-out shift register with output
latches; 3-state." In other words, you can use it to control 8 outputs at a time while only taking up a few pins on your
microcontroller. You can link multiple registers together to extend your output even more. (Users may also wish to search for
other driver chips with "595" or "596" in their part numbers, there are many. The STP16C596 for example will drive 16 LED's and
eliminates the series resistors with built-in constant current sources.)
How this all works is through something called "synchronous serial communication," i.e. you can pulse one pin up and down
thereby communicating a data byte to the register bit by bit. It's by pulsing second pin, the clock pin, that you delineate between
bits. This is in contrast to using the "asynchronous serial communication" of the Serial.begin() function which relies on the sender
and the receiver to be set independently to an agreed upon specified data rate. Once the whole byte is transmitted to the register
the HIGH or LOW messages held in each bit get parceled out to each of the individual output pins. This is the "parallel output"
part, having all the pins do what you want them to do all at once.
The "serial output" part of this component comes from its extra pin which can pass the serial information received from the
microcontroller out again unchanged. This means you can transmit 16 bits in a row (2 bytes) and the first 8 will flow through the
first register into the second register and be expressed there. You can learn to do that from the second example.
"3 states" refers to the fact that you can set the output pins as either high, low or "high impedance." Unlike the HIGH and LOW
states, you can"t set pins to their high impedance state individually. You can only set the whole chip together. This is a pretty
specialized thing to do -- Think of an LED array that might need to be controlled by completely different microcontrollers
depending on a specific mode setting built into your project. Neither example takes advantage of this feature and you won"t
usually need to worry about getting a chip that has it.
Here is a table explaining the pin-outs adapted from the Phillip's datasheet.
Namaste and Welcome to the "Nuts About Electronics" Blog. I am an electronics hobbyist based in India. Recently, I rediscovered my childhood passion in tinkering with electronic circuits. I created this blog to share some of my projects, as well as provide some useful information to other hobbyists in India, where many electronic components are hard to find. Please note that the projects as well as code in this blog are provided "as is", with no guarantees. Working with electricity, electronic components, soldering irons, etc. requires safety precautions - please use your common sense. Good luck with your projects, and above all, have FUN! MV
T H U R S D A Y , J U L Y 9 , 2 0 0 9
Arduino based Temperature Display
This project is part of a bigger project of mine, and it displays the ambient temperature on a set of 2 Common Cathode 7-Segment LED
displays. The temperature sensor is the LM35 IC, which outputs voltage calibrated to degrees centigrade.
The LM35 is connected to the analog input of the Arduino board. The code running on Arduino then averages 10 temperature readings to
reduce jitter, and then outputs the 2 digit integer temperature value to the 7-Segment display. To achieve the latter, it uses a set of 2 shift
registers (IC 74HC595). This is a technique that minimizes the number of output pins required by Arduino to drive the display. You can
read about it in detail here:
http://www.arduino.cc/en/Tutorial/ShiftOut
Code
The following code shows how to read the analog input from the LM35 and use shiftOut() to send data to IC 74HC595. There is also an
optional countDown() method here which runs down from 99 to 0, for testing.
/*
* TempDisplay
* by MV - http://electro-nut.blogspot.com/
*
* Displaying ambient temeprature on a 2 x Common Cathode 7-Segment Displays
* Using 74HC595 shift register and the shiftOut() built in function
* Using LM35 to sense temperature.
*
* REFERENCES
*
* http://www.arduino.cc/en/Tutorial/ShiftOut
*
*/
// set this to 1 to run 99-0 countdown
#define TEST_MODE 0
int val = 0; // variable to store the value coming from the sensor
int lm35Pin = 0;
int DEBUG = 1;
//Pin connected to ST_CP of 74HC595
int latchPin = 8;
//Pin connected to SH_CP of 74HC595
int clockPin = 12;
////Pin connected to DS of 74HC595
int dataPin = 11;
// 7-segment digits 0-9
// 74HC595-->7-Segment pin Mapping:
// Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7 --> DP, a, b, c, d, e, f, g
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 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 theDATA 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.
/*
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 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()
Serial.begin(9600); // start serial communication
void loop()
for(i = 0;i< =7;i++) // gets 8 samples of temperature