Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP32-Based IoT Temperature and Humidity Controller with OLED Display and Wi-Fi Connectivity

View and Edit Project In Cirkit DesignerImage of ESP32-Based IoT Temperature and Humidity Controller with OLED Display and Wi-Fi Connectivity

Circuit Documentation

Summary

This document provides a detailed overview of a circuit designed using an ESP32 Devkit V1 microcontroller. The circuit includes various sensors, relays, and display modules to create an IoT-based temperature and humidity controller. The system uses Blynk for remote monitoring and control, and it includes components such as pushbuttons, a DHT11 temperature-humidity sensor, an OLED display, a relay module, a turbidity sensor, a current sensor, an AC supply, and an LCD screen.

Component List

  1. ESP32 Devkit V1

    • Description: Microcontroller with WiFi and Bluetooth capabilities.
    • Pins: 3V3, GND, D15, D2, D4, RX2, TX2, D5, D18, D19, D21, RX0, TX0, D22, D23, EN, VP, VN, D34, D35, D32, D33, D25, D26, D27, D14, D12, D13, VIN
  2. Pushbutton

    • Description: Simple pushbutton switch.
    • Pins: Pin 3 (out), Pin 4 (out), Pin 1 (in), Pin 2 (in)
  3. KY-015 DHT11 Temperature-Humidity Sensor Module

    • Description: Sensor module for measuring temperature and humidity.
    • Pins: VCC, GND, DOUT
  4. 0.96" OLED

    • Description: Small OLED display for visual output.
    • Pins: GND, VDD, SCK, SDA
  5. 2 Channel Relay Module

    • Description: Relay module for controlling high-power devices.
    • Pins: N.O. 2, COM 2, N.C. 2, N.O. 1, COM 1, N.C. 1, pin 7, pin 8, pin 9, pin 10, pin 11, pin 12, VCC+, VCC- (GND), IN 1, IN 2
  6. Turbidity Sensor

    • Description: Sensor for measuring water turbidity.
    • Pins: OUT, VCC, GND
  7. BULB

    • Description: Simple light bulb.
    • Pins: +, -
  8. ACS712 Current Sensor 5A 20A 30A

    • Description: Current sensor for measuring AC or DC current.
    • Pins: 1, 2, GND, OUT, VCC
  9. AC Supply

    • Description: AC power supply.
    • Pins: +ve, -ve
  10. LCD Screen 16x2 I2C

    • Description: 16x2 character LCD with I2C interface.
    • Pins: SCL, SDA, VCC, GND
  11. ZMPT101B

    • Description: Voltage sensor module.
    • Pins: OUT, GND, VCC, NEUTRO, FASE

Wiring Details

ESP32 Devkit V1

Pushbutton

KY-015 DHT11 Temperature-Humidity Sensor Module

0.96" OLED

2 Channel Relay Module

Turbidity Sensor

BULB

ACS712 Current Sensor 5A 20A 30A

AC Supply

LCD Screen 16x2 I2C

ZMPT101B

Documented Code

/* Fill-in your Template ID (only if using Blynk.Cloud) */
#define BLYNK_TEMPLATE_ID "1908-0050-0123"
#define BLYNK_DEVICE_NAME "xxxx-xxxx-xxxx"
#define BLYNK_AUTH_TOKEN "xxxx-xxxx-xxxx"

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "xxxx-xxxx-xxxx";
char pass[] = "1234-4567-8900";

#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
#include <DHT.h>
#include <Preferences.h>
#include <AceButton.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

using namespace ace_button;
Preferences pref;

#define DHTPIN            23 //D23  pin connected with DHT
// Uncomment whatever type you're using!
#define DHTTYPE DHT11     // DHT 11
//#define DHTTYPE DHT22   // DHT 22, AM2302, AM2321
//#define DHTTYPE DHT21   // DHT 21, AM2301

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

// Setpoint and setHumi values (in degrees Celsius)
float setTemp = 0;
float setHumi = 0;
float currentTemp = 0;
float currentHumi = 0;

// define the GPIO connected with Relays and Buttons
#define RelayPin1 18  //D18
#define RelayPin2 19  //D