I am trying to connect to my Arduino Uno board two temperature sensors: DHT11 and DS18B20. The The problem is with the DHT11 sensor,: apparently there's an error with reading the temperature at every two measurements.
Here's what I get on the serial monitor (temperature 1 is from the DHT sensor):
As I am new to this, I was wondering what the problem may be. I have read about the one wire interface used by the DS18B20, but I noticed that the DHT is not using the same protocol.
If I use the DHT11 alone, it works perfectly fine.
Also, I am using 4k7 pull-up resistors for both sensors.
Here's the code:
#include <DallasTemperature.h>
#include <OneWire.h>
#include <dht.h>
dht DHT;
#define ONE_WIRE_BUS 8
#define DHT11_PIN 7
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
void setup(void)
{
Serial.begin(9600);
Serial.println("Dallas Temperature IC Control Library Demo");
sensors.begin();
}
void loop(void)
{
int chk = DHT.read11(DHT11_PIN);
sensors.requestTemperatures();
Serial.print("Temperature1: ");
Serial.print(DHT.temperature);
Serial.print(" Temperature 2 : ");
Serial.println(sensors.getTempCByIndex(0));
}

