Go Down

Topic: use dht22 and NTC based temperature sensor both at a time (Read 169 times) previous topic - next topic

agile1

Hello,
I have tried connecting DHT22 temperature-humidity sensor and other NTC based temperature sensor but I could not get perfect result. Any one have any idea regarding that how to use multiple but different temperature sensor with one arduino board. 

pylon

This is usually no problem. You should describe what problems you experience and post your code and a wiring diagram. Also post a link to the DHT library you're using as the have major differences. Specify which type of Arduino you use for this project. Provide a link to the board you use to connect the NTC sensor to the Arduino.

agile1

basically I am using CC3200 lauchpad, these arduino sensors can connect with cc3200 lauchpad, CC3200 have 4 adc pin, that pins we can connect sensors like arduino and using energia, can upload code into cc3200, so I used this code as below...

#include <dht.h>
#include <math.h>

#define dhtpin 24
#define ntcpin 6

float Thermistor(float RawADC) {
 float Temp;
 Temp = log(10000.0*((4096.0/RawADC-1)));
 Temp = 1 / (0.0011235 + (0.000235 + (0.000000084538 * Temp * Temp ))* Temp );
 Temp = Temp - 273.15;         
   
 return Temp;
}

void setup()
{
  Serial.begin(115200);
  pinMode(dhtpin,INPUT);
  pinMode(ntcpin,INPUT);
}

void loop()
{
  float temperature, humidity;
   float temperature2, humidity2;
 
  if (dht::readFloatData(dhtpin, &temperature, &humidity, true) == 0)
  {
    Serial.print("\nDHT Temperature: ");
    Serial.print(temperature);
   
  } 


 
 
 
  int16_t rawtemperature, rawhumidity;
  if (dht::readRawData(dhtpin, &rawtemperature, &rawhumidity, true) == 0)
  {
    Serial.print("(raw) T: ");
    Serial.print(rawtemperature);
    Serial.print(" H: ");
    Serial.print(rawhumidity);   
    temperature = dht::convertTemperature(rawtemperature);
    humidity = dht::convertTemperature(rawhumidity);   
    Serial.print(">> T: ");
    Serial.print(temperature);
    Serial.print(" H: ");
    Serial.println(humidity);       
  }

  float val;               
  float temp;           
  val=analogRead(ntcpin);     
  Serial.println(val);
  temp=Thermistor(val);   
  Serial.print("\t NTC Temperature : ");
  Serial.print(temp);   
  Serial.println(" C");

delay(1000);   
}

agile1

from this link I have taken demo code of ntc based temp sensor
https://tkkrlab.nl/wiki/Arduino_KY-013_Temperature_sensor_module

pylon

Did I get that correctly, you're not using an Arduino but a TI evaluation board? In this case I would expect the Thermistor to work if connected correctly but the DHT code is very timing critical and most DHT libraries work only with ATmega processors. As you didn't provide a link to the library you're using I guess that the DHT doesn't return correct values. Am I right?

agile1

ya,right it did not give correct temperature value and Yes I am using TI CC3200 launchpad.

agile1

I used library as below....

Library for DHT11 and DHT22/RHT03/AM2302
  https://github.com/MORA99/Stokerbot/tree/master/Libraries/dht
  Released into the public domain - http://unlicense.org

pylon

The DHT library you're using is not very adaptive in timing issues and I would expect many read failures even on a stock Arduino UNO with it. With all that serial output I guess that the delayMicroseconds() calls are interrupted quite often and timing shifts so the library returns errors. Print out the return values you get this may give you a hint how bad the situation is. I don't know the TI processor, so I don't predict any result but you cannot expect every Arduino library to run on it.

agile1

ok....Thanks for your reply and suggestions... I will try as you told.

Go Up