Я пытаюсь использовать датчик температуры и влажности dht11 для измерения температуры и влажности.
Я использую библиотеку adafruit dht11 и пример кода, но когда я пытаюсь увидеть контрольную сумму, я получаю эту ошибку:
Arduino: 1.8.9 (Windows 8.1), Board: "Arduino/Genuino Uno
C:\Users\K52J\Documents\Arduino\DHTtester\DHTtester.ino: In function 'void loop()':
DHTtester:44:19: error: request for member 'read' in '11', which is of non-class type 'int'
int chk = DHT11.read(DHTPIN);
^
exit status 1
request for member 'read' in '11', which is of non-class type 'int'
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Я новичок в этом деле и не могу решить проблему.
// Example testing sketch for various DHT humidity/temperature sensors
// Written by ladyada, public domain
// REQUIRES the following Arduino libraries:
// - DHT Sensor Library: https://github.com/adafruit/DHT-sensor-library
// - Adafruit Unified Sensor Lib: https://github.com/adafruit/Adafruit_Sensor
#include "DHT.h"
#include <Adafruit_Sensor.h>
#define DHTPIN 2 // Digital pin connected to the DHT sensor
// Uncomment whatever type you're using!
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
// Initialize DHT sensor.
// Note that older versions of this library took an optional third parameter to
// tweak the timings for faster processors. This parameter is no longer needed
// as the current DHT reading algorithm adjusts itself to work on faster procs.
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
Serial.println(F("DHTxx test!"));
dht.begin();
}
void loop() {
// Wait a few seconds between measurements.
delay(1000);
int chk = DHT11.read(DHTPIN);
Serial.println(chk);
... }