> For the complete documentation index, see [llms.txt](https://wiki.openelab.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.openelab.io/aiot/openelab/hs-s30a.md).

# HS-S30A

{% embed url="<https://openelab.io/products/ds1307-rtc-module>" %}

### Introduction

The DS1307 clock module is a low-power, full-BCD clock-calendar real-time clock (RTC) chip with 56 bytes of non-volatile RAM. Addresses and data are transmitted via a two-wire bidirectional serial bus. The chip provides information such as seconds, minutes, and hours, and automatically adjusts for the number of days in each month. The AM/PM flag determines whether the clock operates in 24-hour or 12-hour mode. The chip features a built-in power-sensing circuit with power-down detection and battery-switching capabilities. The DS1307 clock module is a sensor with an integrated digital clock; users can write their own programs to turn it into an electronic clock.

### Schematic Diagram

<figure><img src="https://1292444914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtgOfPnscWebs1eh82EKq%2Fuploads%2FrDvn78mIgFgHmuDkF5H7%2Fd90cfb76c5ccd268fcd2eece703e1b0d.jpg?alt=media&amp;token=6bd3672a-5fec-4521-925e-e79adc9a4ca9" alt=""><figcaption></figcaption></figure>

### Module Parameters

| Pin Names | Description                                 |
| --------- | ------------------------------------------- |
| GND       | GND (negative terminal of the power supply) |
| VCC       | VCC (Positive Power Supply Input)           |
| SDA       | Serial Data Pins                            |
| SCL       | Serial Clock Pin                            |

Supply Voltage: 3.3V / 5V

Connection Type: 2.54mm pin header

Mounting Method: Screw-mounted

### PCB Dimensions

<figure><img src="https://1292444914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtgOfPnscWebs1eh82EKq%2Fuploads%2FYGjItEIlE0xng55l73RX%2F0f93d7d4fdf78622145b508449fe4fa4.jpg?alt=media&amp;token=b8bb1be8-a164-44c1-bbd3-46d8de502029" alt=""><figcaption></figcaption></figure>

### Add Arduino Library Files

First, locate the Arduino library folder:

<figure><img src="https://1292444914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtgOfPnscWebs1eh82EKq%2Fuploads%2FDijHZLJdx66mQxiGwOUj%2F%E5%B7%B2%E7%94%9F%E6%88%90%E5%9B%BE%E5%83%8F%201%20(9).png?alt=media&amp;token=b006b440-c76b-4862-8a91-16ce9aca1afe" alt=""><figcaption></figcaption></figure>

Simply copy the library files to the “libraries” folder within the Arduino IDE directory:

<figure><img src="https://1292444914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtgOfPnscWebs1eh82EKq%2Fuploads%2FJRK9SiuHnIETUmVFTAAY%2F%E5%B7%B2%E7%94%9F%E6%88%90%E5%9B%BE%E5%83%8F%201%20(6).png?alt=media&amp;token=e6251eae-377d-4866-ac02-9479935cbb51" alt=""><figcaption></figcaption></figure>

Library file:&#x20;

{% file src="/files/tcUDgrfJUZlrry2QJV73" %}

### Arduino IDE Sample Programs

Sample Program (UNO Development Board):

{% file src="/files/N9ASjZAjSy2JMgWczPOy" %}

```
#include <RtcDS1307.h>
#include <Wire.h>

RtcDS1307<TwoWire> Rtc(Wire);

void setup(){
  Serial.begin(9600);
  Rtc.Begin();
  Rtc.SetIsRunning(true);
  Rtc.SetDateTime(RtcDateTime(__DATE__, __TIME__));
}

void loop(){
  //DS1307 Connecting the Clock Module to the Development Boardllc（A4，A5）

  Serial.print(String(String("Date") + String("：")) + String(String(Rtc.GetDateTime().Year()) + String("-")) + String(String(Rtc.GetDateTime().Month()) + String("-")) + String(String(Rtc.GetDateTime().Day()) + String("-")));
  Serial.println(String(String("Time") + String("：")) + String(String(Rtc.GetDateTime().Hour()) + String("-")) + String(String(Rtc.GetDateTime().Minute()) + String("-")) + String(Rtc.GetDateTime().Second()));

}
```

### Mixly Sample Programs (Visual Programming Language)

Sample Program (UNO Development Board):

{% file src="/files/J8vMZ01i0uxqTXTZYhgX" %}

<figure><img src="https://1292444914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtgOfPnscWebs1eh82EKq%2Fuploads%2FnLEcr3fnbUJ3mmgIukpm%2F%E5%B7%B2%E7%94%9F%E6%88%90%E5%9B%BE%E5%83%8F%201%20(8).png?alt=media&amp;token=cf14acee-5a7c-40c2-b703-348d5fc51e77" alt=""><figcaption></figcaption></figure>

Sample Program (ESP32 Development Board):

{% file src="/files/GYY7zR75InybKK6jm7GS" %}

### Setting Up the Test Environment

Required Components:

HELLO STEM UNO R3 PRO Development Board \*1

USB Type-C Cable \*1

DS1307 Clock Module \*1

1P female-to-female DuPont wires \*4 or 4P female-to-female DuPont wire \*1

Circuit Wiring Diagram:

<figure><img src="https://1292444914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtgOfPnscWebs1eh82EKq%2Fuploads%2FeVaSe7FOspPx6f0eQSjf%2F%E5%B7%B2%E7%94%9F%E6%88%90%E5%9B%BE%E5%83%8F%201%20(4).png?alt=media&amp;token=e6192276-9704-4473-b0a6-844fae0cd55d" alt=""><figcaption></figcaption></figure>

### Test Conclusions

After connecting the wires to the components and uploading the above program to the Arduino UNO development board, open the Mxily Serial Monitor. The serial output will display the current date and time as read by the DS1307 clock module.

<figure><img src="https://1292444914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtgOfPnscWebs1eh82EKq%2Fuploads%2Fp8A56y6okQQIcgnpbAhK%2F%E5%B7%B2%E7%94%9F%E6%88%90%E5%9B%BE%E5%83%8F%201%20(7).png?alt=media&amp;token=ad5eacd9-70c6-4bc5-b0cc-821e19b69d87" alt=""><figcaption></figcaption></figure>
