UPM

The UPM API is a high level sensor library for IoT devices using MRAA. See examples here. Back to index page.
SparkFun sensor images provided under CC BY-NC-SA-3.0.

DS1307 Class

Module: ds1307

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.
ds1307.jpg

Methods

DS1307

(
  • bus
)
Number

DS1307 constructor

Parameters:

  • bus Number

    I2C bus to use

Returns:

Number:

loadTime

() Boolean

Loads all the time values

Returns:

Boolean:

True if time data loaded successfully

setTime

() Boolean

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

Returns:

Boolean:

True if time is set successfully

enableClock

() Mraa::Result

Enables an oscillator on the clock.

Returns:

Mraa::Result:

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

disableClock

() Mraa::Result

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

Returns:

Mraa::Result:

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

writeBytes

(
  • reg
  • buffer
  • len
)
Mraa::Result

Writes value(s) into registers

Parameters:

  • reg Number

    Register location to start writing into

  • buffer Uint8_t *

    Buffer for data storage

  • len Number

    Number of bytes to write

Returns:

Mraa::Result:

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

readBytes

(
  • reg
  • buffer
  • len
)
Number

Reads value(s) from registers

Parameters:

  • reg Number

    Register location to start reading from

  • buffer Uint8_t *

    Buffer for data storage

  • len Number

    Number of bytes to read

Returns:

Number:

Number of bytes read

bcdToDec

(
  • val
)
Number

Converts a BCD value into decimal

Parameters:

  • val Number

    BCD value to convert

Returns:

Number:

Converted decimal value

decToBcd

(
  • val
)
Number

Converts a decimal value into BCD

Parameters:

  • val Number

    Decimal value to convert

Returns:

Number:

Converted BCD value

Properties

seconds

Number

Holds seconds

minutes

Number

Holds minutes

hours

Number

Holds hours; 1-12 in the am/pm format, 0-23 otherwise

dayOfWeek

Number

Holds a day of the week; 1-7, where 1 is Sunday

dayOfMonth

Number

Holds a day of the month, 1-31

month

Number

Holds a month, 1-12

year

Number

Holds a year, 0-99

amPmMode

Boolean

True if the am/pm format is used, false otherwise

pm

Boolean

For the am/pm format, it is true if it's pm, false otherwise