Skip to content

Instantly share code, notes, and snippets.

@Robotonics
Created July 12, 2014 21:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Robotonics/2e4c86d173941f46031f to your computer and use it in GitHub Desktop.
Save Robotonics/2e4c86d173941f46031f to your computer and use it in GitHub Desktop.
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