

This circuit is designed around the ESP32 microcontroller, which is a versatile and powerful chip with a wide range of I/O capabilities. The circuit includes a 7805 voltage regulator to provide a stable 5V supply, a real-time clock (RTC) module (DS3231) for timekeeping, a 4-channel 5V relay module for controlling external devices, and a buzzer for audible alerts. Additionally, the circuit features an LCD screen with I2C interface for display purposes, a step-down power converter to convert 12V to 5V, and various resistors for current limiting and pull-up/pull-down purposes. An AC supply is used to provide power to the circuit, and a pushbutton and rocker switch are included for user input. The HC-05 Bluetooth module allows for wireless communication. The circuit is designed to be interfaced with a phone, although the phone's specific role is not detailed in the provided information.
GND connected to the ground net.Vin connected to the 5V net.D22 (SCL) connected to the I2C bus for communication with the LCD and RTC.D21 (SDA) connected to the I2C bus for communication with the LCD and RTC.D18 connected to the relay module's IN2.TX2 connected to the HC-05 Bluetooth module's TXD.RX2 connected to the HC-05 Bluetooth module's RXD.D4 connected to the relay module's IN4.Vin connected to the input voltage net from the rocker switch.Gnd connected to the ground net.Vout connected to the 5V net.GND connected to the ground net.VCC connected to the 5V net.SCL connected to the I2C bus.SDA connected to the I2C bus.GND connected to the ground net.VCC connected to the 5V net.IN2 controlled by ESP32 pin D18.IN4 controlled by ESP32 pin D4.NO2 and COM2 connected to the buzzer.COM4 and NO4 connected to the pushbutton.COM2 of the relay and ground.COM4 of the relay and the pushbutton.VIN- connected to the ground net.5v OUTPUT connected to the 5V net.VIN+ connected to the rocker switch.GND connected to the ground net.VCC connected to the 5V net.SCL connected to the I2C bus.SDA connected to the I2C bus.+ve connected to the rocker switch.-ve connected to the ground net.COM4 of the relay.Vin and the step-down converter VIN+.GND connected to the ground net.VCC connected to the 5V net.TXD connected to TX2 of the ESP32.RXD connected to RX2 of the ESP32.from machine import Pin, SoftI2C
from lcd_api import LcdApi
from i2c_lcd import I2cLcd
from DS3231 import DS3231
import time
I2C_LCD_ADDR = 0x27
totalRows = 2
totalColumns = 16
i2c = SoftI2C(scl=Pin(22), sda=Pin(21), freq=10000) # initializing the I2C method for ESP32
lcd = I2cLcd(i2c, I2C_LCD_ADDR, totalRows, totalColumns)
ds = DS3231(i2c)
ds.alarm1(match=ds.AL1_EVERY_S)
buzzer = Pin(4, Pin.OUT)
def get_time():
time_now = ds.datetime()
hour = time_now[4]
minute = time_now[5]
sec = time_now[6]
tim = ""
if hour < 10:
tim = tim + "0"
tim = tim + str(hour) + ":"
if minute < 10:
tim = tim + "0"
tim = tim + str(minute) + ":"
if sec < 10:
tim = tim + "0"
tim = tim + str(sec)
return tim
def set_time(hour, minute):
datetime = (2000, 1, 1, hour, minute, 0, 0)
ds.datetime(datetime)
set_time(23, 1)
ds.alarm2((2, 23, 2), match=ds.AL2_MATCH_HM)
while True:
if ds.check_alarm(1) == 1:
time_now = get_time()
print(time_now)
lcd.clear()
lcd.putstr(time_now)
if ds.check_alarm(2) == 1:
print("alarm")
while True:
buzzer.value(1)
time.sleep(1)
buzzer.value(0)
time.sleep(1)
This code initializes the I2C interface for the ESP32 and sets up the LCD and RTC modules. It defines functions to get and set the time and continuously checks for alarms. When an alarm is triggered, it displays the time on the LCD and activates the buzzer.
This file provides an API for interfacing with an HD44780 compatible character LCD. It defines the command set and functions for controlling the LCD, such as clearing the display, moving the cursor, and writing characters or strings to the display.
This file implements the LCD API for an HD44780 character LCD connected via a PCF8574 I2C expander. It includes functions for initializing the LCD, writing commands and data, and controlling the backlight.
This file contains the driver for the DS3231 RTC module. It provides functions for setting and getting the date and time, configuring alarms, enabling or disabling the square wave output, and checking the oscillator stop flag for time validity.
(Note: The code files are provided as Python scripts but are named with .cpp and .ino extensions, which are typically associated with C++ and Arduino code. The actual code content is written in Python, which suggests that the file extensions may be incorrect or that the code is intended for use with MicroPython or a similar Python interpreter for microcontrollers.)