WHADDA WPI301 DS1302 Real-Time Clock Module User Manual

June 3, 2024
WHADDA

WHADDA WPI301 DS1302 Real-Time Clock Module logo

WHADDA WPI301 DS1302 Real-Time Clock Module

WHADDA WPI301 DS1302 Real-Time Clock Module product

Introduction

To all residents of the European Union
Important environmental information about this product
This symbol on the device or the package indicates that disposal of the device after its lifecycle could harm the environment. Do not dispose of the unit (or batteries) as unsorted municipal waste; it should be taken to a specialized company for recycling. This device should be returned to your distributor or to a local recycling service. Respect the local environmental rules.
If in doubt, contact your local waste disposal authorities.
Thank you for choosing Whadda! Please read the manual thoroughly before bringing this device into service. If the device was damaged in transit, do not install or use it and contact your dealer.

Safety Instructions

  • Read and understand this manual and all safety signs before using this appliance.
  • For indoor use only.
  • This device can be used by children aged from 8 years and above, and persons with reduced physical, sensory or mental capabilities or lack of experience and knowledge if they have been given supervision or instruction concerning the use of the device in a safe way and understand the hazards involved. Children shall not play with the device. Cleaning and user maintenance shall not be made by children without supervision.
General Guidelines
  •  Refer to the Velleman® Service and Quality Warranty on the last pages of this manual.
  •  All modifications of the device are forbidden for safety reasons. Damage caused by user modifications to the device is not covered by the warranty.
  •  Only use the device for its intended purpose. Using the device in an unauthorized way will void the warranty.
  •  Damage caused by disregard of certain guidelines in this manual is not covered by the warranty and the dealer will not accept responsibility for any ensuing defects or problems.
  •  Nor Velleman Group nv nor its dealers can be held responsible for any damage (extraordinary, incidental or indirect) – of any nature (financial, physical…) arising from the possession, use or failure of this product.
  •  Keep this manual for future reference.

What is Arduino®
Arduino® is an open-source prototyping platform based on easy-to-use hardware and software. Arduino® boards are able to read inputs – light-on sensor, a finger on a button or a Twitter message – and turn it into an output – activating of a motor, turning on an LED, publishing something online. You can tell your board what to do by sending a set of instructions to the microcontroller on the board. To do so, you use the Arduino programming language (based on Wiring) and the Arduino® software IDE (based on Processing). Additional shields/modules/components are required for reading a twitter message or publishing online. Surf to www.arduino.cc for more information.

Product Overview

The DS1302 trickle-charge timekeeping chip contains a real-time clock/calendar and 31 bytes of static RAM. It communicates with a microprocessor via a simple serial interface. The real-time clock/calendar provides seconds, minutes, hours, day, date, month, and year information. The end of the month date is automatically adjusted for months with fewer than 31 days, including corrections for leap year. The clock operates in either the 24-hour or 12-hour format with an AM/PM indicator.

Specifications

  •  power supply: 1 x CR2032 (included)
  • TTL compatible: VCC = 5 V
  •  temperature range: 0 °C to +70 °C
Features
  •  manages all timekeeping functions: real-time clock counts seconds, minutes, hours, date of the month, month, day of the week, and year with leap year
  • 31 x 8 battery-backed general-purpose RAM
  • simple serial port interfaces to most microcontrollers: simple 3-wire interface
  •  single-byte or multiple-byte (burst mode) data transfer for read or write of clock or RAM data
  •  low power operation extends battery backup run time: 2.0 V to 5.5 V full operation
  •  uses less than 300 µA @ 2.0 V
Connection

WHADDA WPI301 DS1302 Real-Time Clock Module 01

Arduino®

D5
D6
D7
5 V
GND
WPI301

CE
I/O
SCLK
VCC
GND

Pin LayoutWHADDA WPI301 DS1302 Real-Time Clock Module
02

CE| Input. The CE signal must be asserted high during a read or a write. This pin has an internal 40 kΩ (typ) pulldown resistor to ground. Note: Previous data sheet revisions referred to CE as RST. The functionality of the pin has not changed.
---|---
I/O| Input/push-pull output. The I/O pin is the bidirectional data pin for the 3-wire interface. This pin has an internal 40 kΩ (typ) pulldown resistor to ground.
SCLK| Input. SCLK is used to synchronize data movement on the serial interface. This pin has an internal 40 kΩ (typ) pulldown resistor to ground.
VCC| Primary power supply pin in dual supply configuration. VCC1 is connected to a backup source to maintain the time and date in the absence of primary power. The VMA301 operates from the larger of VCC1 or VCC2. When VCC2 is greater than VCC1 + 0.2 V, VCC2 powers the WPI301. When VCC2 is less than VCC1, VCC1 powers the WPI301.
---|---
GND| Ground.

Example
Before being able to use the sample program, an additional library needs to be installed. Go to Sketch > Include Library > Manage Libraries… WHADDA WPI301
DS1302 Real-Time Clock Module 03Put “DS1302” in the search bar and install the RTC library by Makuna (should be the first result). WHADDA WPI301 DS1302 Real-Time Clock Module
04 Whadda WPI301 DS1302 Real-time clock module example
This demo sets the time on the DS1302 RTC module to the compiled time of the sketch.
After this is configured the time returned by the DS1302 module is periodically printed on the serial monitor
Check whadda.com for more information including a wiring diagram for this demo.
// CONNECTIONS:
// DS1302 CLK/SCLK –> 7
// DS1302 DAT/IO –> 6
// DS1302 RST/CE –> 5
// DS1302 VCC –> 3.3v – 5v
// DS1302 GND –> GND
*/

include

include <RtcDS1302.h>

ThreeWire myWire(6,7,5); // IO, SCLK, CE
RtcDS1302 Rtc(myWire);
void setup ()
{
Serial.begin(57600);
Serial.print(“compiled: “);
Serial.print(DATE);
Serial.println(TIME);
Rtc.Begin();
RtcDateTime compiled = RtcDateTime(DATE, TIME); printDateTime(compiled);
Serial.println();
//Rtc.SetDateTime(compiled);
if (!Rtc.IsDateTimeValid())
{
// Common Causes:
//

  1. first time you ran and the device wasn’t running yet //
  2. the battery on the device is low or even missing

Serial.println(“RTC lost confidence in the Date Time!”); Rtc.SetDateTime(compiled);
}
if (Rtc.GetIs Write Protected())
{
Serial.println(“RTC was write protected, enabling writing now”);
Rtc. Set Is Write Protected(false);
}
if (!Rtc. Get Is Running())
{
Serial.println(“RTC was not actively running, starting now”); Rtc. Set Is Running(true);
}
RtcDateTime now = Rtc. Get Date Time(); if (now < compiled)
{
Serial.println(“RTC is older than compile time! (Updating Date Time)”); Rtc.SetDateTime(compiled);
}
else if (now > compiled)
{
Serial.println(“RTC is newer than compile time. (this is expected)”); }
else if (now == compiled)
{
Serial.println(“RTC is the same as compile time! (not expected but all is fine)”);
}
void loop ()
{
RtcDateTime now = Rtc. Get Date Time();
printDateTime(now);
Serial.println();
if (!now.IsValid())
{
// Common Causes:
//

  1. the battery on the device is low or even missing and the power line was disconnected

Serial.println(“RTC lost confidence in the Date Time!”);
}
delay(10000); // ten seconds
}

define count of(a) (size of(a) / size of(a[0]))

void printDateTime(const RtcDateTime& dt)
{
char date string[20];
snprintf_P(datestring,
countof(datestring),
PSTR(“%02u/%02u/%04u %02u:%02u:%02u”),
dt.Month(),
dt.Day(),
dt.Year(),
dt.Hour(),
dt.Minute(),
dt.Second() );
Serial. print(date string);
}
whadda.com
Modifications and typographical errors reserved – © Velleman Group nv. WPI301_v01 Velleman Group nv, Legen Heirweg 33 – 9890 Gavere.

References

Read User Manual Online (PDF format)

Read User Manual Online (PDF format)  >>

Download This Manual (PDF format)

Download this manual  >>

Related Manuals