pyupm_ds1307 module

class pyupm_ds1307.DS1307(bus)[source]

Bases: object

API for the DS1307 Real-Time CLock.

ID: ds1307

Name: Real Time Clock (RTC) Module

Other Names: DS1307 RTC

Category: time

Manufacturer: seeed

Connection: i2c

Link:https://www.maximintegrated.com/en/products/digital/real-time- clocks/DS1307.html UPM module for the DS1307-based real-time clock. The clock can provide information about seconds, minutes, hours, day of the week, day of the month, month, and year. It can operate in either a 24-hour or a 12-hour format. This device can also output a square wave at 1Khz, 4Khz, 8Khz, and 32Khz. However, this capability is not implemented in this module.

C++ includes: ds1307.hpp

amPmMode
bcdToDec(val)[source]

unsigned int bcdToDec(uint8_t val)

Converts a BCD value into decimal

val: BCD value to convert

Converted decimal value

dayOfMonth
dayOfWeek
decToBcd(val)[source]

uint8_t decToBcd(unsigned int val)

Converts a decimal value into BCD

val: Decimal value to convert

Converted BCD value

disableClock()[source]

mraa::Result disableClock()

Disables the oscillator on the clock. This prevents the clock from updating any time/date values

0 (mraa::SUCCESS) if successful; non-zero otherwise

enableClock()[source]

mraa::Result enableClock()

Enables an oscillator on the clock.

0 (mraa::SUCCESS) if successful; non-zero otherwise

hours
loadTime()[source]

bool loadTime()

Loads all the time values

True if time data loaded successfully

minutes
month
pm
readBytes(reg, buffer, len)[source]

int readBytes(uint8_t reg, uint8_t *buffer, int len)

Reads value(s) from registers

reg: Register location to start reading from

buffer: Buffer for data storage

len: Number of bytes to read

Number of bytes read

seconds
setTime()[source]

bool setTime()

Sets the time. You should call loadTime() beforehand to maintain consistency

True if time is set successfully

writeBytes(reg, buffer, len)[source]

mraa::Result writeBytes(uint8_t reg, uint8_t *buffer, int len)

Writes value(s) into registers

reg: Register location to start writing into

buffer: Buffer for data storage

len: Number of bytes to write

0 (mraa::SUCCESS) if successful; non-zero otherwise

year