Hi all,
i'm Stefano from Italy.
Recently i want to add a classic humidity sensor to my barometer-termometer system.
I've add the library (DHT.h) but the following error appears: "error: 'DHT' does not name a type" at line 34.
Please, can someone explain to me where is the problem?
Really really thanks!
Here it is the code:
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP085_U.h>
#include <TFT.h>
#include <SPI.h>
#include <DHT.h>
// All libraries included
Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(10085);
//set the cs, dc and rst pin
#define cs 10
#define dc  9
#define rst 8
//define the type of the DHT
#define DHTTYPE DHT11
//define the button switch Arduino PIN
#define button 13
//the pin for the humidity sensor
#define DHTPIN 12
//define the tare
#define tare 15.5
//inizialize TFT display
TFT TFTscreen = TFT(cs, dc, rst);
// Initialize DHT sensor for normal 16mhz Arduino
DHT dht(DHTPIN, DHTTYPE);
// All peripherals initialized
void setup(void) {
 //set the button PIN as an input
 pinMode(button, INPUT);
 Serial.begin(9600);
Â
 // initialize the display
 TFTscreen.begin();
 // clear the screen with black background
 TFTscreen.background(0, 0, 0);
 // initialise the sensor
 if(!bmp.begin())
 {
  /* There was a problem detecting the BMP085 ... check your connections */
  Serial.print("Ooops, no BMP085 detected ... Check your wiring or I2C ADDR!");
  while(1);
 }
}
void loop(void) {
 //if the button isn't pressed, display barometric value
 if (digitalRead(button) == LOW) {
  /* Get a new sensor event */
  sensors_event_t event;
  bmp.getEvent(&event);
Â
  /* Display the results (barometric pressure is measure in hPa) */
  if (event.pressure){
   //write a yellow horizontal line
   TFTscreen.stroke(255, 242, 0);
   TFTscreen.line(0, 76, 159, 76);
   //set the font size
   TFTscreen.setTextSize(2);
   //write the CYAN text
   TFTscreen.stroke(0, 255, 255);
   TFTscreen.text("Barometro", 0, 0);
  Â
   //wite the RED text
   TFTscreen.stroke(255, 0, 0);
   TFTscreen.text("Termometro", 0, 85);
  Â
   //wite the WHITE unit text
   TFTscreen.stroke(255, 255, 255);
   TFTscreen.text("hPa", 100, 25);
   TFTscreen.text("mmHg", 100, 50);
   TFTscreen.text("C", 108, 110);
  Â
   //write the WHITE dot temperature unit
   TFTscreen.setTextSize(1);
   TFTscreen.text("o",100 , 108);
   //set the font size for the sensor value
   TFTscreen.setTextSize(2);
  Â
   //write the WHITE pressure value text (hPa)
   char buf[10];
   String(event.pressure + tare).toCharArray(buf, 10);
   TFTscreen.stroke(255, 255, 255);
   TFTscreen.text(buf ,0, 25);
   //write the WHITE pressure value text (mmHg)
   String((event.pressure + tare) / 1.333223680).toCharArray(buf, 10);
   TFTscreen.stroke(255, 255, 255);
   TFTscreen.text(buf, 0, 50);
   //write the WHITE temperature value text (°C)
   float temperature;
   bmp.getTemperature(&temperature);
   String(temperature).toCharArray(buf, 10);
   TFTscreen.stroke(255, 255, 255);
   TFTscreen.text(buf, 0, 110);
   //standby for 2 seconds
   delay(2000);    Â
  Â
   //delete the previous pressure value (hPa)
   TFTscreen.fill(0, 0, 0);
   TFTscreen.noStroke();
   TFTscreen.rect(0, 25, 90, 15);
   //delete the previous pressure value (mmHg)
   TFTscreen.fill(0, 0, 0);
   TFTscreen.noStroke();
   TFTscreen.rect(0, 50, 90, 15);
  Â
   //delete the previous temperature value (°C)
   TFTscreen.fill(0, 0, 0);
   TFTscreen.noStroke();
   TFTscreen.rect(0, 110, 90, 15);
 Â
  }
  else {
   Serial.println("Sensor error");
  }
 Â
 }
 //if the button is pressed, display humidity value
 else {
 Â
  //write the analog value of the humidity sensor
   TFTscreen.background(0,0,0);
 }
}
/*switch (switch_var) {
  case 1:
   //do something when var equals 1
   break;
  case 2:
   //do something when var equals 2
   break;
  default:
   //write an introduction screen
   TFTscreen.stroke(255, 255, 255);
   TFTscreen.setTextSize(3);
   TFTscreen.text("CIAO!", 0, 0);
  }
  */