Answer the question
In order to leave comments, you need to log in
How to fix DHT access error?
#include "C:\Users\User\Documents\Arduino\DHT11.h"
DHT11 DHT(DHT11); // Указать датчик DHT11, DHT21 или DHT22. (несколько датчиков вписывать не нужно)
// Подключать можно только одинаковые датчики, то есть нельзя использовать одновременно DHT11 и DHT22
void setup()
{
Serial.begin(57600);
pinMode(2, INPUT);
digitalWrite(2, HIGH);
pinMode(3, INPUT);
digitalWrite(3, HIGH);
}
void loop()
{
int t = DHT.readTemperature(2); // чтение датчика на пине 2
int h = DHT.readHumidity(2); // чтение датчика на пине 2
delay(2000);
Serial.print("Hum: ");
Serial.print(h);
Serial.print(" %");
Serial.print("Temp: ");
Serial.print(t);
Serial.println(" C ");
Serial.print("Hum2: ");
Serial.print(h2);
Serial.print(" %");
Serial.print("Temp2: ");
Serial.print(t2);
Serial.println(" C ");
}
This Error
C:\Users\User\Documents\Arduino\dhT\dhT.ino: In function 'void loop()':
dhT:16:15: error: request for member 'readTemperature' in 'DHT', which is of non-class type 'DHT11(DHT11)'
int t = DHT.readTemperature(2); // read sensor on pin 2
^~~~~~~~~~~~~~~
dhT:17:15: error: request for member 'readHumidity' in 'DHT', which is of non-class type 'DHT11 (DHT11)'
int h = DHT.readHumidity(2); // read sensor on pin 2
^~~~~~~~~~~~
dhT:27:16: error: 'h2' was not declared in this scope
Serial.print(h2);
^~
C:\Users\User\Documents\Arduino\dhT\dhT.ino:27:16: note: suggested alternative: '
^~
h
dhT:30:16: error: 't2' was not declared in this scope
Serial.print(t2);
^~
C:\Users\User\Documents\Arduino\dhT\dhT.ino:30:16: note: suggested alternative: 't'
Serial.print(t2);
^~
t
exit status 1
request for member 'readTemperature' in 'DHT', which is of non-class type 'DHT11(DHT11)'
Answer the question
In order to leave comments, you need to log in
Try adding your library first
and then include your library from the library manager
Library Manager
Look carefully here:
DHT11 DHT(DHT11);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question