Giter Site home page Giter Site logo

rtcraspberrypi3bcentos7's Introduction

RTC DS 1302 on Raspberry Pi 3 Model B under CentOS 7

Real Time Clock (RTC) is a time-keeping module that keep time running when Pi not connected to power supply and internet. In this section, we will use RTC DS 1302 with lithium battery.

We use Raspberry Pi 3 Model B and CentOS Userland 7 Minimal. We need C compiler to compile the program.

Compiling and Installing

To compile and install RTC DS 1302 module, run commands below.


yum group install -y "Development Tools"

cd /var

mkdir development

cd /var/development

rm -rf rtc-pi.c

curl --location https://github.com/kamshory/RTCRaspberryPi3BCentOS7/blob/master/rtc-pi.c > rtc-pi.c

cd /var/development

cc rtc-pi.c -o rtc-pi 

rm -rf /usr/sbin/rtc-pi

cp rtc-pi /usr/sbin/

echo -e '[Unit]' > /usr/lib/systemd/system/rtc.service

echo -e 'Description=rtc' >> /usr/lib/systemd/system/rtc.service

echo -e '' >> /usr/lib/systemd/system/rtc.service

echo -e '[Service]' >> /usr/lib/systemd/system/rtc.service

echo -e 'ExecStart=/usr/sbin/rtc-pi' >> /usr/lib/systemd/system/rtc.service

echo -e '' >> /usr/lib/systemd/system/rtc.service

echo -e '[Install]' >> /usr/lib/systemd/system/rtc.service

echo -e 'WantedBy=multi-user.target' >> /usr/lib/systemd/system/rtc.service

/usr/sbin/rtc-pi `date +"%Y%m%d%H%M%S"`

systemctl start rtc.service

systemctl enable rtc.service

reboot

rtcraspberrypi3bcentos7's People

Contributors

kamshory avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

rtcraspberrypi3bcentos7's Issues

Unable to set time on DS1302

No matter what i do I'm unable to set date on ds1302. I connected ds1302 and rpi3 like this:
ds1302 rpi3 ()
vcc -----------3.3 (1)
gnd-----------gnd (6)
clk------------GPIO21 (40)
dat-----------GPIO18 (12)
rst------------GPIO17 (11)
When i run sudo ./rtc-pi 20190131092503 i get correct time
Set UNIX timestamp to RTC: 1548923103
But when i read from ds1302 sudo ./rtc-pi
Read UNIX timestamp from RTC: 943916400
I get this date
Tue Nov 30 00:00:10 CET 1999
What am i doing wrong? Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.