Luc Paquin
Published © CC BY

Project #15: Environment - Temperature and Humidity - Mk31

Project #15: Environment - Temperature and Humidity - Mk31

BeginnerFull instructions provided1 hour83
Project #15: Environment - Temperature and Humidity - Mk31

Things used in this project

Hardware components

Elecrow 3.5” 320x480 ESP32 LCD Touch Display
×1
Elecrow Crowtail - Temperature and Humidity Sensor 2.0
×1
USB Battery Pack
×1
DFRobot USB 3.1 Cable A to C
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Fritzing

Code

DL2506Mk02p.ino

Arduino
/****** Don Luc Electronics © ******
Software Version Information
Project #15: Environment - Temperature and Humidity - Mk31
DL2506Mk02p.ino
DL2506Mk02
1 x 3.5” 320x480 ESP32 LCD Touch Display
1 x Crowtail - Temperature and Humidity Sensor 2.0
1 x USB Battery Pack
1 x USB 3.1 Cable A to C
*/

// Include the Library Code
// EEPROM library to read and write EEPROM with unique ID for unit
#include "EEPROM.h"
// TFT Display
#include <TFT_eSPI.h>
// SPI
#include <SPI.h>
// Temperature and Humidity
#include "DHT.h"

// TFT Display
// Invoke custom library with default width and height
// (320x480)
TFT_eSPI tft = TFT_eSPI();
int xpos =  0;
int ypos = 40;

// Temperature and Humidity
// DHT 11 
#define DHTTYPE DHT11
#define DHTPIN 25
DHT dht(DHTPIN, DHTTYPE);
// Temperature
float t;
// Humidity
float h;

// EEPROM Unique ID Information
#define EEPROM_SIZE 64
String uid = "";

// Software Version Information
String sver = "15-31";

void loop() {

  
  // Temperature and Humidity
  // isDHT
  isDHT();

  // Display Temperature and Humidity
  isDisplayDHT();

  // Delay
  delay( 1000 );

}

getDHT.ino

Arduino
// Temperature and Humidity
// DHT
// isDHT
void isDHT(){

  // Temperature and Humidity
  // Temperature
  t = dht.readTemperature();
  // Humidity
  h = dht.readHumidity();
  
}

getDisplay.ino

Arduino
// getDisplay
// 3.5” 320x480 ESP32 LCD Touch Display
// Display UID
void isDisplayUID(){

  // x and y Coordinate 
  xpos =  0;
  ypos = 40;
  
  // TFT Display
  // Clear screen to navy background
  tft.fillScreen(TFT_NAVY);
  
  // Don Luc Electronics
  // TextSize
  tft.setTextSize(1);
  // Text Color
  tft.setTextColor(TFT_YELLOW, TFT_BLUE);
  // Fill Rectangle
  tft.fillRect(0, 0, 350, 30, TFT_BLUE);
  // Font datum
  tft.setTextDatum(TC_DATUM);
  // Draw String
  tft.drawString("Don Luc Electronics", 160, 2, 4);

  // Text Color
  tft.setTextColor(TFT_YELLOW, TFT_BLACK);
  // Set cursor near top left corner of screen
  tft.setCursor(xpos, ypos);

  // TFT Display
  // TextSize
  tft.setTextSize(2);
  // Move cursor down a line
  tft.println();
  
  // Software Version Information
  tft.print("Version: ");
  tft.println( sver );
  // Move cursor down a line
  tft.println();
  tft.println();

  // EEPROM
  tft.print("EEPROM: ");
  tft.println( uid );

}
// Display Temperature and Humidity
void isDisplayDHT(){

  // x and y Coordinate 
  xpos =  0;
  ypos = 40;
  
  // TFT Display
  // Clear screen to navy background
  tft.fillScreen(TFT_NAVY);
  
  // Don Luc Electronics
  // TextSize
  tft.setTextSize(1);
  // Text Color
  tft.setTextColor(TFT_YELLOW, TFT_BLUE);
  // Fill Rectangle
  tft.fillRect(0, 0, 350, 30, TFT_BLUE);
  // Font datum
  tft.setTextDatum(TC_DATUM);
  // Draw String
  tft.drawString("Don Luc Electronics", 160, 2, 4);

  // Text Color
  tft.setTextColor(TFT_YELLOW, TFT_BLACK);
  // Set cursor near top left corner of screen
  tft.setCursor(xpos, ypos);

  // TFT Display
  // TextSize
  tft.setTextSize(2);
  // Move cursor down a line
  tft.println();

  // Temperature
  tft.print("Temperature: ");
  tft.print( t );
  tft.println( " C" );
  tft.println();

  // Humidity
  tft.print("Humidity: ");
  tft.print( h );
  tft.println( " %" );
  
}

getEEPROM.ino

Arduino
// EEPROM
// isUID EEPROM Unique ID
void isUID() {
  
  // Is Unit ID
  uid = "";
  for (int x = 0; x < 7; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

setup.ino

Arduino
// Setup
void setup()
{
 
  // Delay
  delay(100);

  // EEPROM Size
  EEPROM.begin(EEPROM_SIZE);
  
  // isUID EEPROM Unique ID
  isUID();
  
  // Delay
  delay(100);

  // TFT Display
  tft.begin();
  // Rotation
  tft.setRotation(2);

  // Delay
  delay(100);

  // Temperature and Humidity
  dht.begin();

  // Delay
  delay( 100 );

  // Display UID
  isDisplayUID();
  
  // Delay 10 Second
  delay( 10000 );

}

Credits

Luc Paquin
39 projects • 4 followers
Teacher, Instructor, E-Mentor, R&D and Consulting -Programming Language -Microcontrollers -IoT -Robotics -Machine Learning -AI -Sensors

Comments