EP-0059: Difference between revisions

From 52Pi Wiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
=DS1307 RTC Module with BAT for Raspberry Pi=
=DS1307 RTC Module with BAT for Raspberry Pi=
[[File:Ds13072.png|thumb|right|200px]]
[[File:Ds13072.png|thumb|right|500px]]
==Description==
==Description==
The RTC module is specifically designed for Raspberry Pi. It communicated with Raspberry Pi through I2C bus. There is a Maxim DS1307 and CR1220 button cell on the board to keep the real time for a long time after the Raspberry Pi has it’s power off. In order to offering a convenient way to debug, there are five pin has been setup which are 5v, 3.3v, Rxd,Txd on board.
The RTC module is specifically designed for Raspberry Pi. It communicated with Raspberry Pi through I2C bus. There is a Maxim DS1307 and CR1220 button cell on the board to keep the real time for a long time after the Raspberry Pi has it’s power off. In order to offering a convenient way to debug, there are five pin has been setup which are 5v, 3.3v, Rxd,Txd on board.
Line 21: Line 21:
*Real-Time Clock Counts Seconds, Minutes, Hours, Day, Date, Month, and Year with Leap Year Compensation Valid Up to 2100
*Real-Time Clock Counts Seconds, Minutes, Hours, Day, Date, Month, and Year with Leap Year Compensation Valid Up to 2100
*Work temperature 0°C to +70°C
*Work temperature 0°C to +70°C
*Port:
*Ports:
**Raspberry Pi B module 2X13 connection port
**Raspberry Pi A+/B+/2 module 2X13 connection port
**Raspberry Pi A+/B+/2 module 2X13 connection port
**Raspberry Pi 3, Mode B, 1GB RAM 2x20 connection port
**Raspberry Pi 3, Mode B, 1GB RAM 2x20 connection port
Line 34: Line 33:
==Document==
==Document==
*Mechanical Drawing:
*Mechanical Drawing:
[[File:Ds1307.png|left|300px]]
[[File:Ds1307.png|left|500px]]
<br style="clear:both;" >
<br style="clear:both;" >
----
----
==How to Connect:==  
==How to Connect:==  
**1.Software Requirement:Base Raspbian Operating System
**1.Software Requirement:Base Raspbian Operating System
** [[File:Ds13073.png|thumb|left|200px]]
** [[File:Ds13073.png|thumb|left|500px]]
<br style="clear:both;" >
<br style="clear:both;" >
**2. Connection: Just insert the module into Raspberry Pi  
**2. Connection: Just insert the module into Raspberry Pi  
** [[File:Ds13074.png|thumb|left|200px]]
** [[File:Ds13074.png|thumb|left|500px]]
<br style="clear:both;" >
<br style="clear:both;" >
**3. USB-to-TTL cable wire connect to RTC
**3. USB-to-TTL cable wire connect to RTC
** [[File:Ds13075.png|thumb|left|200px]]
** [[File:Ds13075.png|thumb|left|500px]]
<br style="clear:both;" >
<br style="clear:both;" >
**4. Finally  
**4. Finally  
Line 56: Line 55:
Here we assume that you have already burned the Raspbian Image into TF card and connect to your PC and logged in.
Here we assume that you have already burned the Raspbian Image into TF card and connect to your PC and logged in.
Open a terminal and modify /boot/config.txt file using what you favorate editor such as vim.tiny or nano, add parameters as following picture:
Open a terminal and modify /boot/config.txt file using what you favorate editor such as vim.tiny or nano, add parameters as following picture:
[[File:Ds13076.png|thumb|left|200px]]
[[File:Ds13076.png|thumb|left|500px]]
<br style="clear:both;" >
<br style="clear:both;" >
'''You can read /boot/overlay/README and find this info to add support for ds1307 I2C Real Time Clock device.'''
'''You can read /boot/overlay/README and find this info to add support for ds1307 I2C Real Time Clock device.'''
Line 82: Line 81:
</pre>
</pre>
Finally  result like this: <br>
Finally  result like this: <br>
[[File:Raspberry pi hwclock-set.png|left|300px]]
[[File:Raspberry pi hwclock-set.png|left|500px]]
<br style="clear:both;">
<br style="clear:both;">
save and reboot your RPi.
save and reboot your RPi.
Line 91: Line 90:
'''<code>dmesg |grep rtc</code>'''
'''<code>dmesg |grep rtc</code>'''
if you can see this picture means that your RTC module is working properly.  
if you can see this picture means that your RTC module is working properly.  
[[File:Ds13077.png|thumb|left|300px]]
[[File:Ds13077.png|thumb|left|500px]]
<br style="clear:both;" >
<br style="clear:both;" >
and then you can adjust your system clock as following command:
and then you can adjust your system clock as following command:
[[File:Ds13078.png|thumb|left|300px]]
[[File:Ds13078.png|thumb|left|500px]]
<br style="clear:both;" >
<br style="clear:both;" >
'''<pre>
'''<pre>
Line 100: Line 99:
Last step, set the Hardware Clock to the current System Time.
Last step, set the Hardware Clock to the current System Time.
</pre>'''
</pre>'''
[[File:Ds13079.png|thumb|left|300px]]
[[File:Ds13079.png|thumb|left|500px]]
<br style="clear:both;" >
<br style="clear:both;" >
ok, finished. Have fun.
ok, finished. Have fun.

Revision as of 16:28, 16 November 2016

DS1307 RTC Module with BAT for Raspberry Pi

Ds13072.png

Description

The RTC module is specifically designed for Raspberry Pi. It communicated with Raspberry Pi through I2C bus. There is a Maxim DS1307 and CR1220 button cell on the board to keep the real time for a long time after the Raspberry Pi has it’s power off. In order to offering a convenient way to debug, there are five pin has been setup which are 5v, 3.3v, Rxd,Txd on board.


Feature

  • Use Maxim DS1307 chip
  • Extends CR1220 button cell backup
  • Can be operated with shell command
  • Include a serial port connector
  • Programmable square-wave output signal
  • Consumes Less than 500nA in Battery-Backup Mode
  • Automatic Power-Fail Detect and Switch Circuitry
  • Programmable Square-Wave Output Signal

Parameters:

  • Accuracy ±20ppm from 0°C to +40°C
  • Work voltage 5V
  • Battery Backup Input for Continuous Time keeping
  • Real-Time Clock Counts Seconds, Minutes, Hours, Day, Date, Month, and Year with Leap Year Compensation Valid Up to 2100
  • Work temperature 0°C to +70°C
  • Ports:
    • Raspberry Pi A+/B+/2 module 2X13 connection port
    • Raspberry Pi 3, Mode B, 1GB RAM 2x20 connection port
    • 2*5pin 2.54mm connector

Packages

  • 1 x RTC Module
  • 1x CR1220 Battery

Document

  • Mechanical Drawing:
Ds1307.png



How to Connect:

    • 1.Software Requirement:Base Raspbian Operating System
    • Ds13073.png


    • 2. Connection: Just insert the module into Raspberry Pi
    • Ds13074.png


    • 3. USB-to-TTL cable wire connect to RTC
    • Ds13075.png


    • 4. Finally
Note: RTC 5v pin connect to USB-to-TTL Red wire(5v)
RTC GND pin connect to USB-to-TTL black wire(GND)
RTC TX pin connect to USB-to-TTL Green wire(TX)
RTC RX pin connect to USB-to-TTL white wire(RX)

How to configure in terminal

Here we assume that you have already burned the Raspbian Image into TF card and connect to your PC and logged in. Open a terminal and modify /boot/config.txt file using what you favorate editor such as vim.tiny or nano, add parameters as following picture:

Ds13076.png


You can read /boot/overlay/README and find this info to add support for ds1307 I2C Real Time Clock device.

Name:   i2c-rtc
Info:   Adds support for a number of I2C Real Time Clock devices
Load:   dtoverlay=i2c-rtc,<param>=<val>
Params: ds1307                  Select the DS1307 device

please ensure that /boot/config.txt file include those three paramaters:

device_tree=bcm2710-rpi-3-b.dtb
dtoverlay=i2c-rtc,ds1307
dtparam=i2c_arm=on

After that, please make sure you have disabled the "fake hwclock" which interferes with the 'real' hwclock

sudo apt-get -y remove fake-hwclock
sudo update-rc.d -f fake-hwclock remove

Now with the fake-hw clock off, you can start the original 'hardware clock' script.
Edit the script file /lib/udev/hwclock-set with nano or vim editor and comment out these three lines:

if [ -e /run/systemd/system ] ; then
 exit 0
fi

Finally result like this:

Raspberry pi hwclock-set.png


save and reboot your RPi.


How to Check it

After reboot and log in, open a terminal and typing this command to check if RTC module is functional. dmesg |grep rtc if you can see this picture means that your RTC module is working properly.

Ds13077.png


and then you can adjust your system clock as following command:

Ds13078.png


Note: 051014302016.20  is equal to mmDDHHMMYYYY.ss, more information please using  ‘man date’ command.
Last step, set the Hardware Clock to the current System Time.
Ds13079.png


ok, finished. Have fun.

FAQ

  • Question: Why does my RTC module running a wrong time when i reboot my Pi ?
    • Answer: Please do remember to disable the "fake hwclock" which interferes with the 'real' hwclock as following commands:
sudo apt-get -y remove fake-hwclock
sudo update-rc.d -f fake-hwclock remove