Skip to content

Instantly share code, notes, and snippets.

@Robotonics Robotonics/GUI_2
Created Jul 12, 2014

Embed
What would you like to do?
Arduino sketch to display temp+humidty data from DHT11 sensor on ST7735 TFT LCD
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>
#include <dht.h> // dht temp humidity sensor library
#define cs 10
#define dc 9
#define rst 8
#define DHT11_PIN 3
dht DHT;
Adafruit_ST7735 tft = Adafruit_ST7735(cs, dc, rst);
void setup(void){
tft.initR(INITR_BLACKTAB);
tft.fillScreen(ST7735_BLACK);
tft.drawRoundRect(20,28,90,21,5,0x001f);
tft.setCursor(35,15); //x,y
tft.print("TEMPERATURE");
tft.drawRoundRect(20,66,90,21,5,0x001f);
tft.setCursor(40,55); //x,y
tft.print("HUMIDITY");
}
void loop (){
int chk=DHT.read11(DHT11_PIN);
tft.setCursor(40, 31);
tft.setTextSize(2);
tft.println((float)DHT.temperature,1);
tft.setCursor(40, 70);
tft.setTextSize(2);
tft.print(DHT.humidity,1);
delay(10000);
tft.fillRoundRect(21,29,88,19,5,0x0000);
tft.fillRoundRect(21,67,88,19,5,0x0000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.