DS3231 RTC Time-Controlled Relay Module: Hardware Design and Application Guide

GYJ-0116 DS3231-Based Time-Controlled Relay Module: Architecture, Configuration, and Industrial Deployment

Overview and System-Level Positioning

The GYJ-0116 is a compact, self-contained time-controlled relay module designed for precise, autonomous timing operations in industrial, agricultural, and infrastructure applications. Unlike generic timer relays relying on low-accuracy RC oscillators or uncalibrated microcontroller internal clocks, the GYJ-0116 integrates a temperature-compensated real-time clock (RTC) — the Maxim Integrated DS3231 — as its primary timekeeping reference. This architectural choice delivers exceptional long-term stability, with an annual drift of only ±2 ppm under standard operating conditions (0–50 °C). Coupled with an STC15W204S 8051-based microcontroller, robust power regulation, galvanic isolation, and a high-capacity mechanical relay, the module functions as a standalone programmable timing controller without requiring external microprocessors or continuous host supervision.

Its physical footprint — 79 mm × 50 mm × 22 mm — accommodates full functionality within a DIN-rail-mountable form factor. The device operates across a wide input voltage range (6–24 V DC), features reverse-polarity protection, and maintains RTC state during main power loss via a CR2032 coin cell battery. These characteristics make it suitable for deployment in environments where power stability cannot be guaranteed, yet deterministic timing behavior is mission-critical.

Hardware Architecture and Signal Flow Analysis

The GYJ-0116 implements a layered hardware architecture optimized for reliability, electrical safety, and functional autonomy. Its signal flow follows a strict separation between power conditioning, timekeeping, control logic, and actuation — each domain isolated to prevent fault propagation and ensure predictable operation.

Power Conditioning Subsystem

The module accepts 6–24 V DC through screw-terminal inputs equipped with reverse-polarity protection implemented using three 1N4007-class rectifier diodes. Input voltage is regulated to a stable 5 V DC supply using an LM317 linear regulator — not a switching converter — ensuring low electromagnetic interference (EMI) and consistent ripple performance critical for analog-sensitive components like the DS3231’s internal temperature sensor and oscillator circuitry. A 471K (470 V, 1 kA) varistor provides transient overvoltage suppression, protecting downstream logic from surge events common in industrial wiring environments.

Timekeeping and Control Core

The STC15W204S — an enhanced 8051-compatible microcontroller in SOP-8 package — serves as the central processing unit. It executes firmware responsible for I²C communication, time comparison logic, alarm state management, and relay drive sequencing. The DS3231 RTC connects directly to the MCU via dedicated I²C lines: SCL is mapped to P5.4 and SDA to P5.5. This hardware-level I²C interface enables sub-second time synchronization and allows the MCU to read current date/time, set alarms, and monitor oscillator health (e.g., battery backup status, oscillator stop flag). The DS3231’s integrated temperature-compensated crystal oscillator (TCXO) eliminates the need for external calibration or software compensation algorithms — its ±2 ppm annual drift is factory-trimmed and maintained across temperature variations.

RTC state persistence is guaranteed by a CR2032 3 V lithium coin cell connected to the DS3231’s VBAT pin. During main power loss, the DS3231 seamlessly switches to battery power, sustaining accurate timekeeping for up to five years (typical shelf life), while the STC15W204S enters a low-power sleep state. Upon re-powering, the MCU resumes operation with fully synchronized time data.

Isolated Output Stage

Relay actuation employs optocoupler-based galvanic isolation to decouple the 5 V logic domain from the high-voltage AC/DC load circuit. An EL817-T optocoupler receives the MCU’s control signal on its LED side (driven by port P3.3). Its phototransistor output drives the base of an NPN transistor (SO-G3 type), which in turn energizes the coil of the HK3FF-DC5V-SHG relay. This two-stage driver ensures sufficient current gain (≥100) to reliably switch the relay’s 5 V, ~70 mA coil under worst-case supply conditions.

The relay itself — JQC-3F/T73 — provides SPDT (single-pole double-throw) contact configuration: Common (COM), Normally Open (NO), and Normally Closed (NC). Its rated switching capacity is 220 V AC / 10 A resistive or 30 V DC / 10 A, validated per IEC 61810-1 standards. Mechanical life exceeds 100,000 operations at full load. The COM/NO/NC terminals utilize robust screw-type connectors rated for 2.5 mm² wire, enabling secure field termination without soldering.

Configuration Workflow and Firmware Interaction

Configuration of the GYJ-0116 is performed exclusively via a Windows-based host application (“GYJ-0116 Configuration Software v20240726”) communicating over UART. No embedded web server, Bluetooth, or wireless interface is present — aligning with industrial requirements for deterministic, low-overhead, and cyber-secure commissioning.

Physical Connection and Driver Setup

The module exposes a 4-pin programming header: 5 V, TXD, RXD, and GND. Connection requires an STC-specific USB-to-TTL converter (typically CH340-based) configured for 9600 bps, 8-N-1 framing, and no hardware flow control. Windows drivers for the CH340 chipset must be installed prior to use. Once connected, the COM port appears in Device Manager; users select the correct port (e.g., COM5) within the configuration software GUI.

Time Initialization and Alarm Programming Sequence

The configuration workflow follows a strict sequential order:

  1. Serial Port Activation: User clicks “Open Serial Port” to establish bidirectional communication.
  2. Time Verification: “Query Module Time” retrieves current RTC values (year, month, day, hour, minute, second, weekday). This step validates DS3231 functionality and initial synchronization.
  3. RTC Calibration: If time deviates, user inputs corrected values via the “Set Module Time” dialog and confirms transmission. The MCU writes these directly to DS3231 registers over I²C.
  4. Alarm Definition: User specifies one absolute alarm time (HH:MM:SS). The MCU stores this in non-volatile memory (internal flash of STC15W204S) and initiates periodic comparison against the RTC’s time-of-day register.

Critically, alarm triggering is a latching event: upon reaching the programmed time, the relay transitions to its activated state (e.g., COM→NO closure) and remains latched until manually reset via reprogramming. Power cycling does not clear the alarm state — the relay retains its last commanded position, and the MCU resumes monitoring from the stored alarm value. This behavior supports fail-safe shutdown protocols where unintended reset could compromise system integrity.

Electrical Specifications and Performance Metrics

All operational parameters are derived from the official BOM and datasheets referenced in the source material. The following table consolidates key electrical and environmental specifications for engineering evaluation and system integration planning.

Parameter Specification Notes
Input Voltage Range 6–24 V DC Includes reverse-polarity protection
Regulated Logic Supply 5 V DC @ ≥250 mA Provided by LM317 linear regulator
RTC Accuracy ±2 ppm annual drift DS3231 TCXO, 0–50 °C
Relay Contact Rating 220 V AC / 10 A
30 V DC / 10 A
Resistive load; JQC-3F/T73
Operating Temperature 0–50 °C Non-condensing environment
Storage Humidity <80 % RH Non-condensing
Physical Dimensions 79 mm × 50 mm × 22 mm PCB-mounted enclosure

Typical Industrial Applications and Integration Guidance

The GYJ-0116’s combination of precision timing, electrical isolation, and ruggedized packaging makes it applicable across diverse domains where scheduled automation is required without network dependency or complex PLC infrastructure.

Infrastructure and Municipal Systems

In street lighting control, the module replaces electromechanical timers prone to seasonal drift. By setting sunrise/sunset offsets relative to fixed local time, municipalities achieve consistent daily on/off cycles year-round. Similarly, public advertising displays and digital signage benefit from automated daily power cycling — reducing energy waste and extending LED driver lifespan.

Agricultural Automation

For drip irrigation systems, the GYJ-0116 triggers solenoid valves at pre-programmed intervals, independent of cellular coverage or cloud connectivity. In poultry or aquaculture facilities, it schedules feed dispensers and aerator pumps — ensuring precise nutrient delivery and dissolved oxygen management even during grid instability. Its wide input voltage range simplifies integration with solar-charged battery banks (12 V nominal).

Industrial Maintenance and Safety

Equipment manufacturers embed the module into machinery for preventive maintenance alerts: e.g., activating a buzzer or HMI indicator after 1,000 operational hours. In hazardous environments, it enforces automatic shutdown sequences — cutting power to motors or heaters after a defined runtime to prevent thermal runaway. Its latching alarm behavior ensures that critical safety actions persist through brief outages, eliminating reliance on volatile RAM states.

Laboratory and Research Instrumentation

Researchers use the GYJ-0116 to automate sample collection intervals in environmental monitoring stations or initiate calibration routines in analytical instruments at fixed times. The DS3231’s traceable accuracy satisfies ISO/IEC 17025 requirements for time-stamped measurement logging when paired with appropriate data acquisition hardware.

Design Considerations and Limitations

While highly capable for its class, engineers must observe several constraints during system design:

  • The STC15W204S lacks native USB or Ethernet peripherals; remote reconfiguration requires physical access or integration with a supervisory microcontroller.
  • Only a single absolute-time alarm is supported — recurring weekly/daily patterns require external scheduling logic or periodic reprogramming.
  • LM317-based regulation generates heat under high input-output differentials (e.g., 24 V → 5 V at full load); derating is advised above 18 V input in enclosed enclosures.
  • EL817 optocoupler CTR degrades over time; lifetime testing confirms >100,000 switching cycles before CTR falls below 50% — acceptable for infrequent alarm events but unsuitable for PWM-driven loads.

For applications demanding multi-alarm scheduling, network connectivity, or data logging, the GYJ-0116 serves best as a hardened, time-synchronized actuator node within a larger IoT architecture — receiving commands from a central gateway while maintaining local timing autonomy.

Leave a Reply

Your email address will not be published. Required fields are marked *