Microcontrollers
Project #11: ESP32 Feather – RHT03 – Mk04
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
Project #11: ESP32 Feather – DS3231 Precision RTC – Mk03
Adafruit HUZZAH32 ESP32 Feather
——
——
——
——
——
——
Adafruit DS3231 Precision RTC FeatherWing
A Feather board without ambition is a Feather board without FeatherWings! This is the DS3231 Precision RTC FeatherWing: it adds an extremely accurate I2C-integrated Real Time Clock (RTC) with a Temperature Compensated Crystal Oscillator to any Feather main board. This RTC is the most precise you can get in a small, low power package. Most RTCs use an external 32kHz timing crystal that is used to keep time with low current draw.
With a CR1220 12mm lithium battery plugged into the top of the FeatherWing, you can get years of precision timekeeping, even when main power is lost. Great for datalogging and clocks, or anything where you need to really know the time.
DonLuc1908Mk03
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 LED Green
1 x Push Button
1 x 100 Ohm
1 x 10K 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
PB1 – Digital 17
SCK – Digital 13
MOS – Digital 12
SSD – Digital 27
SDA – Digital 23
SCL – Digital 22
GND – GND
VIN – +3.3V
DL1908Mk03p.ino
// ***** Don Luc Electronics ***** // Software Version Information // Project #11: HUZZAH32 ESP32 Feather - DS3231 Precision RTC - Mk03 // 08-03 // DonLuc1908Mk03p.ino 08-03 // Adafruit HUZZAH32 ESP32 Feather Board // SHARP Display // LED Green // Push Button // DS3231 Precision RTC // include Library Code #include <Adafruit_SharpMem.h> #include <Adafruit_GFX.h> #include <RTClib.h> #include <Wire.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 int stateLEDGreen = LOW; // stateLEDGreen // Button int iBut1 = 17; // Button 1 int ButState1; // Variable for reading the button status int previous = LOW; // previous long lTime = 0; // lTime long debounce = 500; // debounce // DS3231 Precision RTC RTC_DS3231 RTC; String sDate; String sTime; void loop() { // Read the state of the button value ButState1 = digitalRead(iBut1); // Check if the button is pressed if (ButState1 == HIGH && previous == LOW && millis() - lTime > debounce) { if(stateLEDGreen == HIGH) { // stateLEDGreen = LOW stateLEDGreen = LOW; // DS3231 Precision RTC timeRTC(); // SHARP Memory Display Off isDisplayOff(); } else { // stateLEDGreen = HIGH stateLEDGreen = HIGH; // DS3231 Precision RTC timeRTC(); // SHARP Memory Display On isDisplayOn(); } lTime = millis(); } // iLEDGreen digitalWrite(iLEDGreen, stateLEDGreen); previous == ButState1; }
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(10,10); display.println( sDate ); display.setCursor(10,30); display.println( sTime ); display.setTextSize(3); display.setCursor(10,55); display.println("LED On"); display.refresh(); } // SHARP Memory Display Off void isDisplayOff() { // Clear Display display.clearDisplay(); // text display date, time, LED off display.setRotation(4); display.setTextSize(2); display.setTextColor(BLACK); display.setCursor(10,10); display.println( sDate ); display.setCursor(10,30); display.println( sTime ); display.setTextSize(3); display.setCursor(10,55); display.println("LED Off"); display.refresh(); }
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() { // SHARP Display start & clear the display display.begin(); display.clearDisplay(); // Button 1 // Initialize the button as an input pinMode(iBut1, INPUT); // Initialize the LED Green pinMode(iLEDGreen, OUTPUT); // DS3231 Precision RTC setupRTC(); // stateLEDGreen = LOW stateLEDGreen = LOW; // DS3231 Precision RTC timeRTC(); // SHARP Memory Display Off isDisplayOff(); }
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
Project #1 – The AcceleroSynth – Mk1
Apr 3, 2012 @ 15:03
We are finally ready for our first electronics project, The AcceleroSynth. It is an microcontroller-based (Arduino) music synth that is controller by a 3 axis analog accelerometer. It will be both a hardware and a software synth. This is the announcement for the project and in the coming days I will post the BOM (Bill of Material), schematics and Arduino code with the first assembly video. The project will first be assembled on a protoboard, then a soldered version will be built either on a perfboard or on an Arduino ProtoShield. If there is enough demand either a PCB or an Arduino Shield will be built for the project and sold here. More on that later. The first installment on the building of the project should be up on a few days.
Don Luc
A Video Introduction to Microcontrollers
Tomorrow’s Video – An Introduction to Microcontrollers
Mar 28, 2012 @ 22:12
I’m hard at work… Actually make that “I think” that tomorrow’s video post will be an introduction to microcontrollers. I will dig some stuff out of the drawers tomorrow and as usual make it up as I go and it will probably be about microcontrollers.
Sleep tight…
Don Luc