Humidity and Temperature Sensor
——
——
——
——
——
——
RHT03 – Humidity and Temperature Sensor
The RHT03 is a low cost humidity and temperature sensor with a single wire digital interface. The sensor is calibrated and doesn’t require extra components so you can get right to measuring relative humidity and temperature.
DonLuc1909Mk01
1 x Adafruit HUZZAH32 ESP32 Feather
1 x Adafruit SHARP Memory Display
1 x Adafruit DS3231 Precision RTC FeatherWing
1 x CR1220 12mm Lithium Battery
1 x RHT03 Humidity and Temperature Sensor
1 x LED Green
1 x 100 Ohm
14 x Jumper Wires 3″ M/M
2 x Jumper Wires 6″ M/M
1 x Full-Size Breadboard
1 x SparkFun Cerberus USB Cable
Adafruit HUZZAH32 ESP32 Feather
LG1 – Digital 21
RHT – Digital 17
SCK – Digital 13
MOS – Digital 12
SSD – Digital 27
SDA – Digital 23
SCL – Digital 22
GND – GND
VIN – +3.3V
DL1909Mk01.ino
// ***** Don Luc Electronics *****
// Software Version Information
// Project #11: HUZZAH32 ESP32 Feather - Mk04
// 09-01
// DonLuc1909Mk01p.ino 11-04
// Adafruit HUZZAH32 ESP32 Feather Board
// SHARP Display
// LED Green
// DS3231 Precision RTC
// EEPROM
// RHT03 Humidity and Temperature Sensor
// include Library Code
#include <Adafruit_SharpMem.h>
#include <Adafruit_GFX.h>
#include <RTClib.h>
#include <Wire.h>
#include "EEPROM.h"
#include <SparkFun_RHT03.h>
// SHARP Memory Display
// any pins can be used
#define SHARP_SCK 13
#define SHARP_MOSI 12
#define SHARP_SS 27
// Set the size of the display here, e.g. 144x168!
Adafruit_SharpMem display(SHARP_SCK, SHARP_MOSI, SHARP_SS, 144, 168);
// The currently-available SHARP Memory Display (144x168 pixels)
// requires > 4K of microcontroller RAM; it WILL NOT WORK on Arduino Uno
// or other <4K "classic" devices!
#define BLACK 0
#define WHITE 1
int minorHalfSize; // 1/2 of lesser of display width or height
// LED Green
int iLEDGreen = 21; // LED Green
// DS3231 Precision RTC
RTC_DS3231 RTC;
String sDate;
String sTime;
// The current address in the EEPROM (i.e. which byte
// we're going to read to next)
#define EEPROM_SIZE 64
String sver = "9-1.p";
// Unit ID information
String uid = "";
// RHT Humidity and Temperature Sensor
const int RHT03_DATA_PIN = 17; // RHT03 data pin Digital 17
RHT03 rht; // This creates a RTH03 object, which we'll use to interact with the sensor
float latestHumidity;
float latestTempC;
float latestTempF;
void loop() {
// iLEDGreen
digitalWrite(iLEDGreen, HIGH );
// DS3231 Precision RTC
timeRTC();
// RHT03 Humidity and Temperature Sensor
isRHT03();
// SHARP Memory Display On
isDisplayOn();
// iLEDGreen
digitalWrite(iLEDGreen, LOW );
// Delay 1
delay( 1000 );
}
getDisplay.ino
// SHARP Memory Display On
void isDisplayOn() {
// Clear Display
display.clearDisplay();
// text display date, time, LED on
display.setRotation(4);
display.setTextSize(2);
display.setTextColor(BLACK);
display.setCursor(0,10);
display.println( sDate );
display.setCursor(0,30);
display.println( sTime );
display.setTextSize(2);
display.setCursor(0,55);
display.print("Hum: ");
display.print( latestHumidity );
display.println("%");
display.setCursor(0,75);
display.print("Cel: ");
display.print( latestTempC );
display.println("*C");
display.setCursor(0,95);
display.print("Fah: ");
display.print( latestTempF );
display.println("*F");
display.refresh();
}
// SHARP Memory Display - UID
void isDisplayUID() {
// text display EEPROM
display.setRotation(4);
display.setTextSize(3);
display.setTextColor(BLACK);
display.setCursor(0,20);
display.println( sver );
// display.setTextSize();
display.setTextColor(BLACK);
display.setCursor(0,65);
display.println( uid );
display.refresh();
delay( 100 );
}
getEEPROM.ino
// EEPROM
void GetUID()
{
// Get unit ID
uid = "";
for (int x = 0; x < 5; x++)
{
uid = uid + char(EEPROM.read(x));
}
}
getRHT.ino
// RHT03 Humidity and Temperature Sensor
void isRHT03(){
// Call rht.update() to get new humidity and temperature values from the sensor.
int updateRet = rht.update();
// The humidity(), tempC(), and tempF() functions can be called -- after
// a successful update() -- to get the last humidity and temperature value
latestHumidity = rht.humidity();
latestTempC = rht.tempC();
latestTempF = rht.tempF();
}
getRTCDS3231.ino
// DS3231 Precision RTC
void setupRTC() {
// DS3231 Precision RTC
RTC.begin();
if (! RTC.begin()) {
while (1);
}
DateTime now = RTC.now();
if (RTC.lostPower()) {
// Following line sets the RTC to the date & time this sketch was compiled
RTC.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
}
// timeRTC
void timeRTC() {
// DS3231 Precision RTC
sDate = "";
sTime = "";
DateTime now = RTC.now();
// sData
sDate += String(now.year(), DEC);
sDate += "/";
sDate += String(now.month(), DEC);
sDate += "/";
sDate += String(now.day(), DEC);
// sTime
sTime += String(now.hour(), DEC);
sTime += ":";
sTime += String(now.minute(), DEC);
sTime += ":";
sTime += String(now.second(), DEC);
}
setup.ino
// Setup
void setup() {
// EEPROM with unique ID
EEPROM.begin(EEPROM_SIZE);
// Get Unit ID
GetUID();
// SHARP Display start & clear the display
display.begin();
display.clearDisplay();
isDisplayUID();
delay( 5000 );
// Initialize the LED Green
pinMode(iLEDGreen, OUTPUT);
// DS3231 Precision RTC
setupRTC();
// DS3231 Precision RTC
timeRTC();
// RHT03 Humidity and Temperature Sensor
// Call rht.begin() to initialize the sensor and our data pin
rht.begin(RHT03_DATA_PIN);
}
Follow Us
Web: https://www.donluc.com/
Web: http://neosteamlabs.com/
Web: http://www.jlpconsultants.com/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Facebook: https://www.facebook.com/neosteam.labs.9/
Instagram: https://www.instagram.com/neosteamlabs/
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Twitter: https://twitter.com/labs_steam
Etsy: https://www.etsy.com/shop/NeoSteamLabs
Don Luc



