Things used in this project

Hardware components:
Esp32 module
Everything ESP ESP32S
×1
Pmod oled  17060.1456867080.1280.1280
Digilent Pmod OLED
×1
DHT22 Humidity and Temperature digital sensor
×1
09939 01
Rotary potentiometer (generic)
×1

Schematics

Code

Code snippet #4Plain text
void loop() 
{
  getDHT();
  displayData();
  delay(2000);
}
Code snippet #5Plain text
/***************************************************
* Display Data
****************************************************/
void displayData() 
{
  display.clear();   // clear the display

  display.drawString(0, 0,  "temp: ");
  display.drawString(40, 0,  String(localTemp));
  display.drawString(90, 0,  "oC");
  display.drawString(0, 32, "hum:  ");
  display.drawString(40, 32,  String(localHum));
  display.drawString(90, 32,  "%");

  display.display();   // write the buffer to the display
  delay(10);
}
Code snippet #9Plain text
/***************************************************
* Get display
****************************************************/
int getDisplay()
{
  int displayNum = 0;
  int analog_value = analogRead(ANALOG_PIN_0);
  if      (analog_value <= 999)                         displayNum = 0;
  else if (analog_value > 1000 && analog_value <= 1999) displayNum = 1;
  else if (analog_value > 2000 && analog_value <= 2999) displayNum = 2;
  else if (analog_value > 3000 && analog_value <= 3999) displayNum = 3;
  else if (analog_value > 4000 )                        displayNum = 4;
 
  return displayNum;
}
Code snippet #10Plain text
/***************************************************
* Display Data
****************************************************/
void displayData(int displayNum) 
{
  String formattedTime = timeClient.getFormattedTime();
  display.clear();   // clear the display
  switch (displayNum) 
  {
    case 0:
      display.clear();
      break;
    case 1:
      display.setFont(ArialMT_Plain_24);
      display.drawString(20, 31,  String(formattedTime));
      break;
    case 2:
      display.setFont(ArialMT_Plain_24);
      display.drawString(0, 31,  "T:");
      display.drawString(30, 31,  String(localTemp));
      display.drawString(100, 31,  "oC");
      break;
    case 3:
      display.setFont(ArialMT_Plain_24);
      display.drawString(0, 31,  "H:");
      display.drawString(30, 31,  String(localHum));
      display.drawString(100, 31,  "%");
      break;
    case 4:
      display.setFont(Open_Sans_Condensed_Light_20);
      display.drawString(0, 0,  "t:");
      display.drawString(10, 0,  String(localTemp));
      display.drawString(47, 0,  "oC");
      display.drawString(75, 0, "h:");
      display.drawString(85, 0,  String(localHum));
      display.drawString(120, 0 ,  "%");
      display.setFont(ArialMT_Plain_24);
      display.drawString(20, 31,  String(formattedTime));
      break;
    default: 
      display.clear();
      break;
  }
  display.display();   // write the buffer to the display
  delay(10);
}
Code snippet #11Plain text
void loop() 
{
  getDHT();
  timeClient.update();
  displayData(getDisplay());
  delay(2000);
}
Github
https://github.com/espressif/arduino-esp32
Github
https://github.com/Mjrovai/ESP32/tree/master/Playing%20with%20ESP32%20and%20Arduino%20IDE/ESP32_Blink
Github
https://github.com/adafruit/DHT-sensor-library

Credits

Mjrobot hiresicon 512 512 j57u7diljd
MJRoBot

Engineer, writer and forever student. Passionate to share knowledge of electronics with focus on IoT and robotics.

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Add projectSign up / Login