Welcome to Blog #2 of Winter Driving Safety
I have been working on the GPS speedometer, carbon monoxide detector and the mini-weather station all at once. This wasn’t a good idea since I get sidetracked very easily and get nowhere. So, I started to focus on one thing at a time, starting with the weather station. This weekend I got the temperature and humidity sensor working with the TFT screen. My first issue I ran into was I didn’t have a TFT screen in amongst all my collection, or so I thought. I found a Microduino TFT and modified the wiring to work. This solved the “Not having a colour screen issue”.
Below is the code and pictures of how it works so far.
Microduino TFT
Arduino Connection:
Code:
#include <Adafruit_GFX.h> // Core graphics library #include <Adafruit_ST7735.h> // Hardware-specific library for ST7735 #include <Adafruit_ST7789.h> // Hardware-specific library for ST7789 #include <SPI.h> #include <dht.h> #define DHT11_PIN 5 #define TFT_CS 10 #define TFT_RST 9 #define TFT_DC 8 #define TFT_MOSI 11 // Data out #define TFT_SCLK 13 // Clock out Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST); dht DHT; void setup(void) { Serial.begin(9600); Serial.print("Just Encase Design Challenge"); tft.initR(INITR_BLACKTAB); // Init ST7735S chip, black tab // Screen size 128x160 // Start-up Screen tft.fillScreen(ST77XX_BLACK); tft.setCursor(30,40); tft.setTextColor(ST77XX_RED); tft.setTextSize(1); tft.println("Just"); delay(1000); tft.setCursor(30,60); tft.println("Encase"); delay(1000); tft.setCursor(30,80); tft.println("Design"); delay(1000); tft.setCursor(30,100); tft.println("Challenge !!"); delay(2000); tft.fillScreen(ST77XX_BLACK); tft.setCursor(30,40); tft.println("Winter"); delay(1000); tft.setCursor(30,60); tft.println("Driving"); delay(1000); tft.setCursor(30,80); tft.println("Safety!! "); delay(2500); tft.fillScreen(ST77XX_BLACK); } void loop() { int chk = DHT.read11(DHT11_PIN); // Reads DHT11 Sensor switch (chk) tft.setTextWrap(false); tft.setCursor(0, 1); // Temperature Screen Location tft.setTextColor(ST77XX_RED); tft.setTextSize(1); tft.println("Temperature: "); tft.setCursor(80,1); tft.println(DHT.temperature, 1); tft.setCursor(0, 40); // Humidity Screen Location tft.println("Humidity: "); tft.setCursor(80,40); tft.println(DHT.humidity, 1); delay(2000); tft.setTextColor(ST77XX_BLACK); //Erases current readings tft.setCursor(80, 1); tft.println(DHT.temperature, 1); tft.setCursor(80,40); tft.println(DHT.humidity, 1); }
Working photos:
I would have had more to report but my daughter contracted COVID and is really sick right now. More updates to come shortly!!
I am also adding in basic winter survival into my project. This is important in case you get stuck somewhere and help won't come for a while. I'll explain how to stay warm, what to prepare for and how long to prepare to wait.
Dale Winhold