Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
en:iot-open:practical:hardware:taltech:arduino:scenarios:thermistor [2025/06/25 08:57] – created raivo.sellen:iot-open:practical:hardware:taltech:arduino:scenarios:thermistor [2025/09/02 11:38] (current) raivo.sell
Line 1: Line 1:
-====== Thermistor ======+<pagebreak> 
 +====== Temperature Measurement Using Thermistor ====== 
 + 
 +This scenario demonstrates how to measure temperature using a thermistor (temperature-sensitive resistor) connected to an Arduino Uno. The temperature is calculated using the Steinhart-Hart equation. 
 + 
 +===== Prerequisites ===== 
 +  * Familiarize yourself with the Arduino hardware reference. 
 +  * Basic understanding of analog sensor readings and voltage dividers. 
 +  * Install LiquidCrystal library for LCD display. 
 + 
 +===== Hardware Connections ===== 
 +^ Component   ^ Arduino Pin                         ^ 
 +| Thermistor  | A5 (Analog)                         | 
 +| LCD         | RS=8, EN=9, D4=4, D5=5, D6=6, D7=7  | 
 + 
 + 
 +===== Task ===== 
 +Measure temperature using a thermistor and display the results (ADC reading, voltage, resistance, and temperature in Celsius) on the LCD. 
 + 
 +===== Steps ===== 
 + 
 +=== Step 1: Include Libraries === 
 +<code c> 
 +#include <math.h> 
 +#include <LiquidCrystal.h> 
 +</code> 
 + 
 +=== Step 2: Initialize LCD === 
 +Declare LCD pins and initialize: 
 +<code c> 
 +LiquidCrystal lcd(8, 9, 4, 5, 6, 7); 
 +const int sensorPin = A5; 
 +</code> 
 + 
 +=== Step 3: Setup === 
 +Set LCD dimensions and initial message: 
 +<code c> 
 +void setup() { 
 +  lcd.begin(16, 2); 
 +  lcd.print("Temperature"); 
 +  delay(1000); 
 +
 +</code> 
 + 
 +=== Step 4: Main Loop === 
 +Read sensor value, calculate temperature, and display on LCD: 
 +<code c> 
 +void loop() { 
 +  readThermistor(analogRead(sensorPin)); 
 +  delay(1000); 
 +  lcd.clear(); 
 +
 + 
 +void readThermistor(int RawADC) { 
 +  double Temp; 
 +  long Resistance; 
 + 
 +  // Calculate resistance 
 +  Resistance = ((10240000 / RawADC) - 10000); 
 + 
 +  // Display ADC and voltage 
 +  lcd.setCursor(0, 0); 
 +  lcd.print("AD="); 
 +  lcd.print(RawADC); 
 +  lcd.setCursor(8, 0); 
 +  lcd.print("U="); 
 +  lcd.print(((RawADC * 5.0) / 1024.0), 3); 
 + 
 +  // Display resistance 
 +  lcd.setCursor(0, 1); 
 +  lcd.print("R="); 
 +  lcd.print(Resistance); 
 + 
 +  // Calculate temperature (Steinhart-Hart) 
 +  Temp = log(Resistance); 
 +  Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp)) * Temp); 
 +  Temp = Temp - 273.15; // Convert Kelvin to Celsius 
 + 
 +  // Display temperature 
 +  lcd.setCursor(8, 1); 
 +  lcd.print("T="); 
 +  lcd.print(Temp); 
 +
 +</code> 
 + 
 +===== Validation ===== 
 +LCD displays accurate ADC values, voltage readings, resistance, and temperature in Celsius. Typical room temperature should range between 19-24 °C. 
 + 
 +===== Troubleshooting ===== 
 +If temperature readings are incorrect or unstable: 
 +  * Check wiring and verify analog input connection (A5). 
 +  * Verify the correct resistor value in the voltage divider. 
 +  * Ensure accurate Steinhart-Hart constants are used.
  
en/iot-open/practical/hardware/taltech/arduino/scenarios/thermistor.1750841857.txt.gz · Last modified: 2025/06/25 08:57 by raivo.sell
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0