我正在使用我朋友的代码建立一个气象站。但是,他是 Arduino 的旧版本,我无法弄清楚原因。我是编程新手,所以我不知道“'dht'没有命名类型”是什么意思?我正在使用 Arduino 1.04,我的朋友在 Arudino 0022 上编写了他的气象站。我的问题是,为什么我的验证无法编译?我做错了什么?
这是我的代码:
#include <dht.h>
dht DHT;
#define DHT22_PIN 2
#include <Wire.h>
#define BMP085_ADDRESS 0x77 // I2C address of BMP085
const unsigned char OSS = 3; // Oversampling Setting
// Calibration values
int ac1;
int ac2;
int ac3;
unsigned int ac4;
unsigned int ac5;
unsigned int ac6;
int b1;
int b2;
int mb;
int mc;
int md;
// b5 is calculated in bmp085GetTemperature(...), this variable is also used in bmp085GetPressure(...)
// so ...Temperature(...) must be called before ...Pressure(...).
long b5;
short temperature;
long pressure;
void setup()
{
pinMode(2, INPUT);
Wire.begin();
bmp085Calibration();
Serial.begin(115200);
analogReference(INTERNAL);
}
void loop() {
// READ DATA
float bat_read=analogRead(6);
//bat_read = analogRead(BAT_voltage);
float chk = DHT.read22(DHT22_PIN);
// DISPLAY DATA
Serial.print(bat_read, DEC);
Serial.print(", ");
Serial.print(DHT.humidity, 2);
Serial.print(", ");
temperature = bmp085GetTemperature(bmp085ReadUT());
pressure = bmp085GetPressure(bmp085ReadUP());
Serial.print(temperature, DEC);
Serial.print(", ");
Serial.println(pressure, DEC);
delay(1000);
}
错误是:
error: 'dht' does not name a type
sketch_jul05a.ino: In function 'void loop()': error: 'DHT' was not declared in this scope