After testing the thermistor temperature sensor, the measurement is not very accurate and what we want. After discuss with my supervisor and asking other lecturer for help, they suggest to try another type of temperature sensor to see if there is another temperature sensor that more accurate. The temperature suggested are LM35 and DHT 22. So, after that, i search about the LM35 and DHT 22. So, here the features for those temperature sensor.
LM35
The LM35 series are precision integrated-circuit temperature devices with an output voltage linearly-proportional to the Centigrade temperature. The LM35 device has an advantage over linear temperature sensors calibrated in Kelvin, as the user is not required to subtract a large constant voltage from the output to obtain convenient Centigrade scaling. The LM35 device does not require any external calibration or trimming to provide typical accuracies of ±¼°C at room temperature and ±¾°C over a full −55°C to 150°C temperature range. Lower cost is assured by trimming and calibration at the wafer level
DHT 22
The DHT sensors are made of two parts, a capacitive humidity sensor and a thermistor There is also a very basic chip inside that does some analog to digital conversion and spits out a digital signal with the temperature and humidity. The digital signal is fairly easy to read using any microcontroller.
- Low cost
- 3 to 5V power and I/O
- 2.5mA max current use during conversion (while requesting data)
- Good for 0-100% humidity readings with 2-5% accuracy
- Good for -40 to 80°C temperature readings ±0.5°C accuracy
- No more than 0.5 Hz sampling rate (once every 2 seconds)
- Body size 15.1mm x 25mm x 7.7mm
- 4 pins with 0.1" spacing
Activity: Test the another type of temperature sensor
This week is actually a briefing week, but the briefing was extend as the FYP committee has a unavoidable problems. So this week i test the another temperature sensor which is LM35 and DHT22.
After bought the LM35 and DHT22 i do a research about the circuit and the coding. Different type of temperature sensor has a different circuit diagram and coding.
So, when i test, the temperature changes are slow than thermistor. The LM35 has a very low accuracy for for detection of the temperature changes. While for the DHT22, the detection not so fast than the NTC thermistor. So, after try testing with my supervisor, it approve that the DHT are slower than NTC. The final choose is the use back the NTC thermistor for the temperature sensor.
#include<LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int sensor=A1; // Assigning analog pin A1 to variable 'sensor'
float tempc; //variable to store temperature in degree Celsius
float tempf; //variable to store temperature in Fahreinheit
float vout; //temporary variable to hold sensor reading
void setup()
{
pinMode(sensor,INPUT); // Configuring pin A1 as input
Serial.begin(9600);
lcd.begin(16,2);
delay(500);
}
void loop()
{
vout=analogRead(sensor);
vout=(vout*500)/1023;
tempc=vout; // Storing value in Degree Celsius
tempf=(vout*1.8)+32; // Converting to Fahrenheit
lcd.setCursor(0,0);
lcd.print("in DegreeC= ");
lcd.print(tempc);
lcd.setCursor(0,1);
lcd.print("in Fahrenheit=");
lcd.print(tempf);
delay(1000); //Delay of 1 second for ease of viewing in serial monitor
}
#define DHT11_PIN 4 // ADC0 Define the ANALOG Pin connected to DHT11 Sensor
int temp1[3]; //Temp1, temp2, hum1 & hum2 are the final integer values that you are going to use in your program.
int temp2[3]; // They update every 2 seconds.
int hum1[3];
int hum2[3];
byte read_dht11_dat()
{
byte i = 0;
byte result=0;
for(i=0; i< 8; i++){
while(!(PINC & _BV(DHT11_PIN))); // wait for 50us
delayMicroseconds(30);
if(PINC & _BV(DHT11_PIN))
result |=(1<<(7-i));
while((PINC & _BV(DHT11_PIN))); // wait '1' finish
}
return result;
}
long dht11delay_previousMillis = 0; // will store last time LED was updated
long dht11delay_interval = 1000; // dht11delay_interval at which to blink (milliseconds)
void setup()
{
DDRC |= _BV(DHT11_PIN);
PORTC |= _BV(DHT11_PIN);
Serial.begin(9600);
Serial.println("DHT11 without delay");
Serial.println("Example code by: Nick Athanasoulas");
Serial.println("Ready");
delay(1000);
}
void loop()
{
unsigned long dht11delay_currentMillis = millis();
if(dht11delay_currentMillis - dht11delay_previousMillis > dht11delay_interval) {
// save the last time you blinked the LED
dht11delay_previousMillis = dht11delay_currentMillis;
byte dht11_dat[5];
byte dht11_in;
byte i;
// start condition
// 1. pull-down i/o pin from 18ms
PORTC &= ~_BV(DHT11_PIN);
delay(18);
PORTC |= _BV(DHT11_PIN);
delayMicroseconds(40);
DDRC &= ~_BV(DHT11_PIN);
delayMicroseconds(40);
dht11_in = PINC & _BV(DHT11_PIN);
if(dht11_in){
Serial.println("dht11 start condition 1 not met");
return;
}
delayMicroseconds(80);
dht11_in = PINC & _BV(DHT11_PIN);
if(!dht11_in){
Serial.println("dht11 start condition 2 not met");
return;
}
delayMicroseconds(80);
// now ready for data reception
for (i=0; i<5; i++)
dht11_dat[i] = read_dht11_dat();
DDRC |= _BV(DHT11_PIN);
PORTC |= _BV(DHT11_PIN);
byte dht11_check_sum = dht11_dat[0]+dht11_dat[1]+dht11_dat[2]+dht11_dat[3];
// check check_sum
if(dht11_dat[4]!= dht11_check_sum)
{
Serial.println("DHT11 checksum error");
}
temp1[0]=dht11_dat[2];
temp2[0]=dht11_dat[3];
Serial.print("Temperature: ");
Serial.print(temp1[0]);
Serial.print(".");
Serial.print(temp2[0]);
Serial.print(" C");
Serial.print(" ");
hum1[0]=dht11_dat[0];
hum2[0]=dht11_dat[1];
Serial.print("Humidity: ");
Serial.print(hum1[0]);
Serial.print(".");
Serial.print(hum2[0]);
Serial.println("%");
}
}
This week is actually a briefing week, but the briefing was extend as the FYP committee has a unavoidable problems. So this week i test the another temperature sensor which is LM35 and DHT22.
After bought the LM35 and DHT22 i do a research about the circuit and the coding. Different type of temperature sensor has a different circuit diagram and coding.
So, when i test, the temperature changes are slow than thermistor. The LM35 has a very low accuracy for for detection of the temperature changes. While for the DHT22, the detection not so fast than the NTC thermistor. So, after try testing with my supervisor, it approve that the DHT are slower than NTC. The final choose is the use back the NTC thermistor for the temperature sensor.
Circuit for LM35
Burn in a Arduino Software
#include<LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int sensor=A1; // Assigning analog pin A1 to variable 'sensor'
float tempc; //variable to store temperature in degree Celsius
float tempf; //variable to store temperature in Fahreinheit
float vout; //temporary variable to hold sensor reading
void setup()
{
pinMode(sensor,INPUT); // Configuring pin A1 as input
Serial.begin(9600);
lcd.begin(16,2);
delay(500);
}
void loop()
{
vout=analogRead(sensor);
vout=(vout*500)/1023;
tempc=vout; // Storing value in Degree Celsius
tempf=(vout*1.8)+32; // Converting to Fahrenheit
lcd.setCursor(0,0);
lcd.print("in DegreeC= ");
lcd.print(tempc);
lcd.setCursor(0,1);
lcd.print("in Fahrenheit=");
lcd.print(tempf);
delay(1000); //Delay of 1 second for ease of viewing in serial monitor
}
The connection for DHT22 with Arduino
Burn in a Arduino Software
#define DHT11_PIN 4 // ADC0 Define the ANALOG Pin connected to DHT11 Sensor
int temp1[3]; //Temp1, temp2, hum1 & hum2 are the final integer values that you are going to use in your program.
int temp2[3]; // They update every 2 seconds.
int hum1[3];
int hum2[3];
byte read_dht11_dat()
{
byte i = 0;
byte result=0;
for(i=0; i< 8; i++){
while(!(PINC & _BV(DHT11_PIN))); // wait for 50us
delayMicroseconds(30);
if(PINC & _BV(DHT11_PIN))
result |=(1<<(7-i));
while((PINC & _BV(DHT11_PIN))); // wait '1' finish
}
return result;
}
long dht11delay_previousMillis = 0; // will store last time LED was updated
long dht11delay_interval = 1000; // dht11delay_interval at which to blink (milliseconds)
void setup()
{
DDRC |= _BV(DHT11_PIN);
PORTC |= _BV(DHT11_PIN);
Serial.begin(9600);
Serial.println("DHT11 without delay");
Serial.println("Example code by: Nick Athanasoulas");
Serial.println("Ready");
delay(1000);
}
void loop()
{
unsigned long dht11delay_currentMillis = millis();
if(dht11delay_currentMillis - dht11delay_previousMillis > dht11delay_interval) {
// save the last time you blinked the LED
dht11delay_previousMillis = dht11delay_currentMillis;
byte dht11_dat[5];
byte dht11_in;
byte i;
// start condition
// 1. pull-down i/o pin from 18ms
PORTC &= ~_BV(DHT11_PIN);
delay(18);
PORTC |= _BV(DHT11_PIN);
delayMicroseconds(40);
DDRC &= ~_BV(DHT11_PIN);
delayMicroseconds(40);
dht11_in = PINC & _BV(DHT11_PIN);
if(dht11_in){
Serial.println("dht11 start condition 1 not met");
return;
}
delayMicroseconds(80);
dht11_in = PINC & _BV(DHT11_PIN);
if(!dht11_in){
Serial.println("dht11 start condition 2 not met");
return;
}
delayMicroseconds(80);
// now ready for data reception
for (i=0; i<5; i++)
dht11_dat[i] = read_dht11_dat();
DDRC |= _BV(DHT11_PIN);
PORTC |= _BV(DHT11_PIN);
byte dht11_check_sum = dht11_dat[0]+dht11_dat[1]+dht11_dat[2]+dht11_dat[3];
// check check_sum
if(dht11_dat[4]!= dht11_check_sum)
{
Serial.println("DHT11 checksum error");
}
temp1[0]=dht11_dat[2];
temp2[0]=dht11_dat[3];
Serial.print("Temperature: ");
Serial.print(temp1[0]);
Serial.print(".");
Serial.print(temp2[0]);
Serial.print(" C");
Serial.print(" ");
hum1[0]=dht11_dat[0];
hum2[0]=dht11_dat[1];
Serial.print("Humidity: ");
Serial.print(hum1[0]);
Serial.print(".");
Serial.print(hum2[0]);
Serial.println("%");
}
}
No comments:
Post a Comment