Помогите со скетчем

popUP
Offline
Зарегистрирован: 09.10.2014

Разница с Вашим скетчем у меня только в библиотеке, что Вы используете

#include "DHT.h"     - у меня, автор Adafruit

#include "dht11.h"  - у Вас

Вот мой тренировочный скетч

#include "DHT.h"
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x3f,16,2);  // set the LCD address to 0x3f for a 16 chars and 2 line display

#define DHTPIN 2     // what pin we're connected to

// Uncomment whatever type you're using!
//#define DHTTYPE DHT11   // DHT 11 
#define DHTTYPE DHT22   // DHT 22  (AM2302)

DHT dht(DHTPIN, DHTTYPE, 6);

void setup() {
  Serial.begin(9600); 
  Serial.println("DHT22 test!");
 
 lcd.init();                      // initialize the lcd 
// Print a message to the LCD.
  lcd.backlight();
  lcd.print("DHT22 test!");
 
  dht.begin();
}

void loop() {
  // Wait a few seconds between measurements.
  delay(3000);
//lcd.clear();
  
 
  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();
  // Read temperature as Celsius
  float t = dht.readTemperature();
  // Read temperature as Fahrenheit
  float f = dht.readTemperature(true);
  
  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t) || isnan(f)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  // Compute heat index
  // Must send in temp in Fahrenheit!
  float hi = dht.computeHeatIndex(f, h);

  Serial.print("Humidity: "); 
  Serial.print(h);
  Serial.print(" %\t");
  Serial.print("Temperature: "); 
  Serial.print(t);
  Serial.print(" *C ");
  Serial.print(f);
  Serial.print(" *F\t");
  Serial.print("Heat index: ");
  Serial.print(hi);
  Serial.println(" *F");
  
  lcd.setCursor(0, 0);
  lcd.print("Humid: "); 
  lcd.print(h);
  lcd.print(" %");
  lcd.setCursor(0, 1);
  lcd.print("Temp: "); 
  lcd.print(t);
  lcd.print(" *C ");
//  lcd.print(f);
//  lcd.print(" *F\t");
//  lcd.print("Heat index: ");
 // lcd.print(hi);
//  lcd.println(" *F");
   

 

Mr.Privet
Mr.Privet аватар
Offline
Зарегистрирован: 17.11.2015

Alexii пишет:

Пишет вот что:

DHT11_proba:10: error: 'DHT' does not name a type
 

явно говорит о том что нет такого класса "DHT". другие ошибки из за этого. посмотрите пример из библиотеки как он там определяется. ну или поставьте другую библеотеку.

Alexii пишет:

pop UP и Mr.Privet сорри не врублюсь как написать кому ответил.

Все ручками, тут же программисты собрались как никак....