Welcome to Blog #3 of the Winter Driving Safety project
This update covers preparing the Hammond Manufacturing Enclosure Cases for protecting the project and what I have accomplished so far.
Hammond Manufacturing Enclosure Cases:
I thought to much into cutting the holes for the cable glands. I cut the first hole with a rotary tool, I am use to the plastic being hard and breaking when drilled. I was wrong, after the first hole I decided to use a speed bore drill bit to cut the rest of the holes. The Poly Carbonate Enclosure's drilled perfectly, no cracking at all. These enclosures are the highest quality and best I ever used. For the first enclosure that will be at the back of the car I have 2 cable glands for wiring and 1 out for the sensors. The second enclosure with the clear cover will be up by the driver to display the information. This enclosure has 1 cable gland drilled in the side.
For the second half of my update:
I connected an accelerometer & GPS to the Arduino.
The accelerometer will be used to sense sudden movement of the vehicle. This will be used to sense if you were in an accident or lost control of the vehicle due to bad weather. I will be adding parameters to calculate different sudden movements.
The GPS will be used to detect the vehicles speed and let you know if you are driving to fast for the weather conditions.
I have 2 sensors to connect yet, the Carbon Monoxide Detector and the Barometer. The barometer will be used as a weather station.
Updated Code (So far):
#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> #include "ADXL335.h" #include <SoftwareSerial.h> #include <TinyGPS.h> #define DHT11_PIN 5 #define TFT_CS 10 #define TFT_RST 9 // Or set to -1 and connect to Arduino RESET pin #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); float lat,lon; // create variable for latitude and longitude object SoftwareSerial gpsSerial(3,4);//rx,tx TinyGPS gps; dht DHT; ADXL335 accelerometer; void setup(void) { Serial.begin(9600); gpsSerial.begin(9600); accelerometer.begin(); // Use this initializer if using a 1.8" TFT screen: tft.initR(INITR_BLACKTAB); // Init ST7735S chip, black tab // Screen size 128x160 // SPI speed defaults to SPI_DEFAULT_FREQ defined in the library, you can override it here // Note that speed allowable depends on chip and quality of wiring, if you go too fast, you // may end up with a black screen some times, or all the time. //tft.setSPISpeed(40000000); tft.fillScreen(ST77XX_BLACK); // large block of text tft.fillScreen(ST77XX_BLACK); tft.setCursor(30,40); tft.setTextColor(ST77XX_RED); tft.setTextSize(1); tft.println("Just"); delay(5000); tft.setCursor(30,60); tft.println("Encase"); delay(5000); tft.setCursor(30,80); tft.println("Design"); delay(5000); tft.setCursor(30,100); tft.println("Challenge !!"); delay(1500); tft.fillScreen(ST77XX_BLACK); tft.setCursor(30,40); tft.println("Winter"); delay(5000); tft.setCursor(30,60); tft.println("Driving"); delay(5000); tft.setCursor(30,80); tft.println("Safety!! "); delay(1500); tft.fillScreen(ST77XX_BLACK); } void loop() { // Start and display temperature and humidity int chk = DHT.read11(DHT11_PIN); switch (chk) tft.setTextWrap(false); tft.setCursor(0, 1); tft.setTextColor(ST77XX_RED); tft.setTextSize(1); tft.println("Temperature: "); tft.setCursor(80,1); tft.println(DHT.temperature, 1); tft.setCursor(0, 20); tft.println("Humidity: "); tft.setCursor(80,20); tft.println(DHT.humidity, 1); //Start and display Accelerometer information int x,y,z; accelerometer.getXYZ(&x,&y,&z); tft.setCursor(0, 40); tft.println("Value X/Y/Z: "); tft.setCursor(0,60); tft.println(x, 1); tft.setCursor(40,60); tft.println(y, 1); tft.setCursor(80,60); tft.println(z, 1); float ax,ay,az; accelerometer.getAcceleration(&ax,&ay,&az); tft.setCursor(0, 80); tft.println("Accel X/Y/Z: "); tft.setCursor(0,100); tft.println(ax, 1); tft.setCursor(40,100); tft.println(ay, 1); tft.setCursor(80,100); tft.println(az, 1); //Get GPS information while(gpsSerial.available()){ // check for gps data if(gps.encode(gpsSerial.read()))// encode gps data { gps.f_get_position(&lat,&lon); // get latitude and longitude } } String latitude = String(lat,6); String longitude = String(lon,6); //Display GPS location tft.setCursor(0,120); tft.println("Lat:"); tft.setCursor(40,120); tft.println(latitude); tft.setCursor(0,140); tft.println("Long:"); tft.setCursor(40,140); tft.println(longitude); delay(1000); //Clear displayed information tft.setTextColor(ST77XX_BLACK); tft.setCursor(80, 1); tft.println(DHT.temperature, 1); tft.setCursor(80,20); tft.println(DHT.humidity, 1); tft.setCursor(0,60); tft.println(x, 1); tft.setCursor(40,60); tft.println(y, 1); tft.setCursor(80,60); tft.println(z, 1); tft.setCursor(0,100); tft.println(ax, 1); tft.setCursor(40,100); tft.println(ay, 1); tft.setCursor(80,100); tft.println(az, 1); tft.setCursor(40,120); tft.println(lat,6); tft.setCursor(40,140); tft.println(lon,6); }
Updated TFT Display:
Project Layout:
Thank you for reading!!
Dale Winhold