Cov txheej txheem:

DS1307 Lub Sijhawm Tiag RTC Nrog Arduino: 4 Cov Kauj Ruam
DS1307 Lub Sijhawm Tiag RTC Nrog Arduino: 4 Cov Kauj Ruam

Video: DS1307 Lub Sijhawm Tiag RTC Nrog Arduino: 4 Cov Kauj Ruam

Video: DS1307 Lub Sijhawm Tiag RTC Nrog Arduino: 4 Cov Kauj Ruam
Video: Arduino alarm clock prototype 2024, Kaum ib hlis
Anonim
DS1307 Sijhawm Sijhawm RTC Nrog Arduino
DS1307 Sijhawm Sijhawm RTC Nrog Arduino

Hauv phau ntawv qhia no, peb yuav kawm txog Lub Sijhawm Tiag (RTC) thiab yuav ua li cas Arduino & Lub Sijhawm Tiag IC DS1307 tau muab tso ua ke ua lub sijhawm ntsuas.

Lub Sijhawm Tiag (RTC) yog siv rau kev saib xyuas lub sijhawm thiab tswj hwm daim ntawv qhia hnub. Txhawm rau siv RTC, peb yuav tsum xub ua haujlwm nws nrog hnub thiab sijhawm tam sim no. Thaum qhov no ua tiav, RTC cov npe tuaj yeem nyeem txhua lub sijhawm kom paub lub sijhawm thiab hnub tim. DS1307 yog RTC uas ua haujlwm ntawm I2C raws tu qauv. Cov ntaub ntawv los ntawm ntau lub npe tuaj yeem nyeem los ntawm kev nkag mus rau lawv qhov chaw nyob rau kev nyeem ntawv siv I2C kev sib txuas lus.

Kauj Ruam 1: Yam Koj Xav Tau

Yam Koj Xav Tau
Yam Koj Xav Tau
Yam Koj Xav Tau
Yam Koj Xav Tau
Yam Koj Xav Tau
Yam Koj Xav Tau

Nov yog cov hauv qab no koj xav tau rau cov lus qhia no:

Arduino ib

Ds1307 rtc module

Jumper xov hlau

3.7v npib cell

Kauj ruam 2: Kev sib txuas

Kev sib txuas
Kev sib txuas
Kev sib txuas
Kev sib txuas

Thov ua raws qhov txuas schmatics hauv ntu duab thiab txuas txhua yam Raws li schmatics.

Kauj Ruam 3: Coding Tshooj

Coding Tshooj
Coding Tshooj

Programming Arduino los pub RTC nrog hnub thiab sijhawm tam sim no; thiab nyeem hnub thiab sijhawm los ntawm RTC.

Ntawm no, peb yuav siv DS1307 lub tsev qiv ntawv los ntawm Watterott los ntawm GitHub.

Rub lub tsev qiv ntawv los ntawm no.:

Extract lub tsev qiv ntawv thiab ntxiv cov npe hu ua DS1307 rau lub tsev qiv ntawv cov ntawv tais ceev tseg ntawm Arduino IDE.

Thaum lub tsev qiv ntawv tau ntxiv rau Arduino IDE, qhib IDE thiab qhib qhov piv txwv kos npe piv txwv los ntawm DS1307 lub tsev qiv ntawv ntxiv.

Lo Lus Ceeb Toom: Hauv qhov piv txwv piv txwv, hauv teeb lub voj, rtc.set () ua haujlwm tau siv. Dhau hnub tam sim no thiab sijhawm sib cav raws li tau hais rau txoj haujlwm no. Hauv qhov piv txwv kos duab, nqe lus no yuav muab los tham. Uncomment nws thiab upload daim duab. Thaum cov duab kos tau rub tawm, tsis pom zoo cov lus hais ntxiv thiab rub cov duab kos. Yog tias qhov no tsis ua tiav, txhua lub sijhawm Arduino UNO pawg thawj coj saib rov pib dua lossis tau qhib lub zog tom qab tua hluav taws, hnub thiab sijhawm uas koj tau teeb tsa yuav raug teeb tsa ntau zaus thiab koj yuav tsis tuaj yeem nyeem lub sijhawm tam sim no thiab hnub tim.

/* DS1307 RTC (Sijhawm Sijhawm-Sijhawm) Piv txwv

Uno A4 (SDA), A5 (SCL) Mega 20 (SDA), 21 (SCL) Leonardo 2 (SDA), 3 (SCL) */

#suav nrog "Wire.h"

#suav nrog "DS1307.h"

DS1307 rtc;

void teeb () { /*init Serial chaw nres nkoj* / Serial.begin (9600); thaum (! Serial); /*tos rau qhov chaw nres nkoj txuas mus txuas - xav tau rau Leonardo nkaus xwb*/

/*init RTC*/ Serial.println ("Init RTC …");

/*tsuas yog teem hnub+sijhawm ib zaug*/ rtc.set (0, 0, 8, 24, 12, 2014); /*08: 00: 00 24.12.2014 // sec, min, teev, hnub, hli, xyoo*/

/*nres/ncua RTC*/// rtc.stop ();

/*pib RTC*/ rtc.start (); }

void loop () {uint8_t sec, min, teev, hnub, hli; uint16_t xyoo;

/*tau sijhawm los ntawm RTC*/ rtc.get (& sec, & min, & teev, & hnub, & hli, & xyoo);

/*serial output*/ Serial.print ("\ nTime:"); Serial.print (teev, DEC); Serial.print (":"); Serial.print (min, DEC); Serial.print (":"); Serial.print (sec, DEC);

Serial.print ("\ n Hnub tim:"); Serial.print (hnub, DEC); Serial.print ("."); Serial.print (hli, DEC); Serial.print ("."); Serial.print (xyoo, DEC);

/*tos ib pliag*/ ncua (1000); }

Luam cov cai saum toj no & xa nws mus rau koj li Arduino Board

Kauj Ruam 4: Tau Sijhawm

Tau Sijhawm
Tau Sijhawm
Tau Sijhawm
Tau Sijhawm

Tom qab txuas txhua yam ua ke thiab xa cov cai mus rau koj lub rooj tsav xwm arduino, qhib qhov saib hauv ntu hauv koj lub tswv yim arduino thiab tom qab ntawd koj yuav tuaj yeem tau txais hnub tim & sijhawm raws li kuv hauv koj li kev saib xyuas raws li koj tuaj yeem pom kuv tuaj yeem pom kuv Lub Sijhawm & hnub tim hauv kuv qhov kev saib xyuas, rau qhov tso tawm qhov tseeb thov xa cov duab saum toj no thiab muaj kev lom zem ntxiv RTC moos rau koj qhov project.

Pom zoo: