#include <ArduinoJson.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include "DHT.h"
#define DHTPIN 22 // Digital pin connected to the DHT sensor
// Feather HUZZAH ESP8266 note: use pins 3, 4, 5, 12, 13 or 14 --
// Pin 15 can work but DHT must be disconnected during program upload.
// Uncomment whatever type you're using!
//#define DHTTYPE DHT11 // DHT 11
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
// Connect pin 1 (on the left) of the sensor to +5V
// NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1
// to 3.3V instead of 5V!
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor
// 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);
#define TFT_DC 2
#define TFT_CS 15
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
const ledPin1=4;
const ledPin2=4;
const ledPin3=4;
void setup() {
tft.begin();
dht.begin();
tft.setRotation(1);
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
}
void loop() {
float h = dht.readHumidity();
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
// Read temperature as Fahrenheit (isFahrenheit = true)
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(F("Failed to read from DHT sensor!"));
return;
}
// Compute heat index in Fahrenheit (the default)
float hif = dht.computeHeatIndex(f, h);
// Compute heat index in Celsius (isFahreheit = false)
float hic = dht.computeHeatIndex(t, h, false);
// read temperature
tft.fillScreen(ILI9341_WHITE);
tft.setCursor(0,0);
tft.setTextSize(2);
tft.setTextColor(ILI9341_RED);
tft.println("");
tft.println("");
tft.println("Kuppam Engineering College");
// tft.setCursor(5, 1);
tft.setTextColor(ILI9341_BLUE);
tft.println("");
tft.println("");
//tft.println("");
//tft.println("");
//tft.println("");
tft.println(" SPI LCD");
// tft.setCursor(8, 0);
tft.setTextColor(ILI9341_GREEN);
tft.println("");
//tft.println("");
//tft.println("");
//tft.println("");
tft.println("");
tft.println(" dht11");
tft.println("");
//tft.println("");
tft.print(" temp");
tft.print(t);
tft.println("");
tft.println("");
//tft.println("");
tft.print(" hum");
tft.print(h);
// //tft.setCursor(10, 0);
delay(5000);
}