#include <DHT.h>
#define DHTPIN 11 // Digital pin connected to the DHT sensor
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
DHT dht(DHTPIN, DHTTYPE);
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#define TFT_CS 17
#define TFT_DC 15
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
void setup() {
// put your setup code here, to run once:
tft.begin();
dht.begin();
}
void loop() {
// 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();
float t = dht.readTemperature();
tft.setCursor(0,0);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(2);
tft.print("Humidity: ");
tft.print(h);
tft.setCursor(0,40);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(2);
tft.print("Temperature: ");
tft.print(t);
delay(1000);
}