Cov txheej txheem:
Video: Teeb DS3231 RTC (Lub Sijhawm Sijhawm) Kom raug, Ceev thiab Tsis Siv Neeg Siv Java (+-1s): 3 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:26
Cov Lus Qhia no yuav qhia koj yuav teev sijhawm li cas hauv DS3231 Lub Sijhawm Tiag Siv Arduino thiab daim ntawv thov Java me me uas siv txuas txuas ntawm Arduino.
Lub hauv paus tseem ceeb ntawm txoj haujlwm no:
1. Arduino xa cov ntawv thov.
2. Java program zoo li cas hnub/hli/… arduino thov thiab xa cov ntaub ntawv rov qab los.
3. Tom qab txhua cov ntaub ntawv xav tau sib sau ua ke arduino khaws cov ntaub ntawv hauv DS3231.
DS3231 RTC Module
DS3231 RTC Module yog tus qauv RTC uas pheej yig nrog qhov tseeb. (ob peb feeb hauv ib xyoos)
Muaj ntau yam sib txawv uas nws txoj haujlwm yooj yim zoo ib yam nrog qhov sib txawv me me xwb.
Kev sib piv ntxaws ntxaws tuaj yeem pom ntawm no: DS323x Sib Piv | maximintegrated.com
Yuav DS3231: DS3231 | ebay.com ib
Cov Ntawv Teev Npe: DS3231 Cov Ntawv Sau | maximintegrated.com
Datasheet: DS1307 Cov Ntaub Ntawv | maximintegrated.com
Qhov Yuav Tsum Tau
1x Arduino (Nano, Uno, MEGA, thiab lwm yam)
4x Jumper Xov
1x DS3231 Module (DS1307 Module)
Kauj ruam 1: Kev thaiv kab
Hlau DS3231 raws li qhia hauv daim duab saum toj no. Tau kawg koj tuaj yeem ua nws yam tsis siv lub khob cij, tab sis nws yuav ua rau me ntsis ntxiv. Kuv tau siv Arduino Nano los ua qauv qhia tab sis Uno lossis MEGA yuav tsum ua haujlwm ib yam nkaus. (Lwm tus kuj yuav ua haujlwm tab sis kuv yuav tub nkeeg kom paub meej)
- Arduino -> DS3231
- A4 -> SCL
- A5 -> SDA
- 5V -> VCC
- GND -> GND
Kauj ruam 2: Arduino Code
Rub tawm.ino cov ntaub ntawv los ntawm hauv qab no thiab rub nws mus rau koj Arduino (hauv kuv li Nano).
Daim duab xav tau cov tsev qiv ntawv hauv qab no txhawm rau ua haujlwm kom raug:
github.com/PaulStoffregen/Time
github.com/JChristensen/DS3232RTC
Cov lus qhia yuav ua li cas upload cov cai rau koj arduino tuaj yeem pom ntawm no (arduino.cc).
Hauv Arduino IDE txheeb xyuas qhov chaws tau xa raug. (Ua tiav uploading)
Koj Arduino tam sim no npaj tau txais cov ntaub ntawv sijhawm
Rub tus lej ntawm no: DS3231TimeSync.zip (mediafire.com)
Rub lub hauv paus ntawm no: DS3231TimeSyncSRC.zip (mediafire.com)
GitHub chaw cia khoom: DS3213 RTC Sijhawm Sync (github.com)
Bitbucket chaw cia khoom: DS3231 RTC Sijhawm Sync (bitbucket.com)
Kauj ruam 3: Java Application
1. Khiav "DS3231Sync.jar" rub tawm ua ntej los ntawm ob npaug nias nws
2. Ib qho kev sib tham me me yuav qhib nug koj txog qhov chaw nres nkoj ntawm koj cov arduino
Koj yuav tsum tsis meej txog qhov chaw nres nkoj siv los ntawm koj cov arduino ua tib zoo saib hauv Arduino IDE ntawm sab xis hauv qab.
(Saib cov duab saum toj no)
3. Lwm qhov kev sib tham yuav qhib thiab nug koj txog thaj tsam sijhawm
Qhov offset yog txheeb ze rau lub sijhawm hauv koj lub computer. Txhawm rau teeb tsa RTC rau koj lub sijhawm hauv cheeb tsam tsuas yog nkag rau +00: 00.
Nws yog qhov tseem ceeb heev uas koj nkag mus rau lub sijhawm txwv nyob rau hauv ib hom tshwj xeeb!
Hom ntawv dav yog +hh: mm lossis -hh: mm. Ib txwm suav nrog ua tus zeros!
(Piv txwv li: -03: 00; -06: 00; +09: 00; +02: 30)
4. Qhov Java Application yuav pib lub qhov rai me me nrog cov khoom tso tawm
Khaws qhov muag rau cov lus pom zoo xws li: "Sijhawm teem tseg"
Thaum lub sijhawm txheej txheem ua tiav cov cai yuav luam tawm lub sijhawm tam sim no ntawm DS3231 txhua 5 vib nas this. Koj tuaj yeem lees paub tias lub sijhawm tau teeb tsa raug.
Koj yuav tsum tsis tau txais cov txiaj ntsig tom qab ~ 20s thawb lub pob pib dua ntawm koj tus arduino thiab tos dua.
Yog tias nws tseem tsis ua haujlwm txheeb xyuas qhov kos duab ntawm Arduino thiab/lossis xa nws dua. (Tseem ceeb: Kaw Chaw Nres Nkoj hauv Java daim ntawv thov ua ntej xa mus rau Arduino; Txwv tsis pub nws yuav thaiv qhov chaw nres nkoj txuas!) Tom qab ntawd rov pib dua qhov kev sib txuas hauv Java program.
(Txoj haujlwm Java siv LocalDateTime kom tau txais hnub tam sim no.)
Tam sim no lub sijhawm tau teeb tsa. Muaj kev lom zem
Shoud koj muaj teeb meem daws tsis tau teeb lub sijhawm thov tawm tswv yim hauv qab no thiab qhia koj lub log.txt (hauv tib daim nplaub tshev zoo li lub thawv) nrog kuv. Ua tsaug ntau!