Cov txheej txheem:

Arduino Hnub/Sijhawm Plotting/Logging Siv Millis () thiab PfodApp: 11 Cov Kauj Ruam
Arduino Hnub/Sijhawm Plotting/Logging Siv Millis () thiab PfodApp: 11 Cov Kauj Ruam

Video: Arduino Hnub/Sijhawm Plotting/Logging Siv Millis () thiab PfodApp: 11 Cov Kauj Ruam

Video: Arduino Hnub/Sijhawm Plotting/Logging Siv Millis () thiab PfodApp: 11 Cov Kauj Ruam
Video: Amazing arduino project 2024, Hlis ntuj nqeg
Anonim
Arduino Hnub/Sijhawm Plotting/Logging Siv Millis () thiab PfodApp
Arduino Hnub/Sijhawm Plotting/Logging Siv Millis () thiab PfodApp

Tsis muaj Arduino lossis Android programming xav tau. RTC thiab GPS cov qauv kuj tau txhawb nqa. Kev kho kom raug rau lub sijhawm, RTC drift thiab GPS ploj mus li vib nas this

Taw qhia

Cov ntawv qhia no qhia koj yuav siv koj li Arduino millis () lub sijhawm timestamps los npaj cov ntaub ntawv tawm tsam hnub tim thiab sijhawm ntawm koj lub xov tooj ntawm tes siv pfodApp.

Tsis xav tau Arduino lossis Android programming xav tau. pfodApp tseem teev cov ntaub ntawv txaus kom tom qab koj tuaj yeem tsim cov hnub/sijhawm cov phiaj hauv daim ntawv nthuav tawm.

Tsis xav tau RTC lossis GPS module, txawm li cas los xij yog tias koj txoj haujlwm Arduino muaj RTC (Lub Sijhawm Tiag) lossis GPS module lawv kuj tuaj yeem siv tau. Hauv cov xwm txheej no pfodApp cov phiaj yuav ua kom raug qhov tseeb rau lub sijhawm, RTC drift thiab GPS ploj ib pliag vib nas this. Tsis tas yuav muaj tus lej tshwj xeeb Arduino rau qhov kev kho no. Raws li ib txwm nrog pfodApp, cov ntaub ntawv tau txais tau nkag mus raws nraim qhov yog, tsis raug kho, txawm li cas los xij cov ntaub ntawv teev cia tseem muaj cov ntaub ntawv txaus los tso cai rau koj siv cov kev kho no koj tus kheej thaum koj rub lub cav rau hauv koj lub computer. Saib hauv qab no rau cov piv txwv ntawm qhov ua tiav tom qab.

Ntau yam sijhawm thiab hnub tim X-axis kev ua qauv raug txhawb, txhua yam uas tau ua tiav kev tswj hwm los ntawm cov kab ntawv luv hauv koj daim duab Arduino. Tsis xav tau Android programming.

pfodApp yuav txuas ntawm WiFi, Bluetooth Classic, BLE thiab SMS. Pub dawb pfodDesigner tsim kom tiav Arduino sketches rau hnub/sijhawm phiaj xwm/txiav cav los txuas rau ntau yam ntawm cov laug cam. Tsis xav tau Arduino programming yuav tsum tau.

Cov lus qhia no yuav siv Adafruit Feather52 ua piv txwv Arduino board, uas txuas ntawm BLE.

Cov lus qhia no suav nrog peb qhov xwm txheej:- 1) Koj lub phiaj xwm microprocessor tsuas muaj lub sijhawm xaum moos- millis () 2) Koj txoj haujlwm microprocessor muaj Lub Sijhawm Tiag (RTC)- pfodApp tau txais kev kho kom raug. 3) Koj qhov project microprocessor muaj GPS module - pfodApp tau txais kev kho rau lub vib nas this dhia raws li lawv tshwm sim (tam sim no 18 vib nas this zoo li xyoo 2018).

Kauj Ruam 1: Siv Arduino Millisecond Timestamps, Millis ()

Muaj ob ntu siv milliseconds rau hnub thiab sijhawm. Ib qho yog rau phiaj xwm cov ntaub ntawv tawm tsam lub sijhawm dhau los lossis hnub/sijhawm thiab lwm qhov yog rov tsim hnub thiab sijhawm los ntawm cov ntaub ntawv teev npe rawdata millisecond timestamps. pfodApp tsis hloov kho cov ntaub ntawv raw tau txais los ntawm pfodDevice (Arduino micro). Nws tsuas yog teev raws nraim bytes tau txais.

Ua ntej siv pfodDesigner dawb los tsim Arduino kos duab rau koj lub micro uas yuav xa cov milliseconds thiab ntsuas cov ntaub ntawv mus rau pfodApp rau kev npaj/txiav cav. Qhov piv txwv no tsim cov ntawv qhia zaub mov rau Adafruit Feather 52 BLE board uas nyeem A0. Kev qhia ntawm Adafruit Feather nRF52 LE - Kev tswj hwm tus kheej nrog pfodApp mus los ntawm pfodDesigner cov kauj ruam los tsim cov ntawv qhia zaub mov rau Feather nRF52 uas suav nrog khawm Chart, yog li txheeb xyuas nws kom paub meej ntxiv. Hauv qhov kev qhia no peb yuav ntxiv tsuas yog khawm kab ntawv thiab siv tus qauv X-axis tshiab los xaiv cov phiaj xwm A0 nyeem tawm tsam lub sijhawm dhau los thiab hnub/sijhawm.

Thawj ntu ntawm qhov kev qhia no yuav dhau los ntawm kev siv pfodDesigner dawb los tsim cov qauv hnub tim/sijhawm hauv koj lub xov tooj ntawm tes. Thaum koj txaus siab rau cov zaub koj tuaj yeem tsim Arduino kos duab uas yuav rov tsim dua thaum thaum koj txuas nrog pfodApp. Tsis muaj Android Programming xav tau thiab txij li pfodDesigner tsim kom tiav Arduino sketches rau ntau yam ntawm Arduino boards, tsis muaj Arduino programming yuav tsum yog.

Kauj Ruam 2: Ntxiv Daim Duab rau Cov Ntawv Qhia

Ntxiv Daim Ntawv Qhia rau Cov Ntawv Qhia
Ntxiv Daim Ntawv Qhia rau Cov Ntawv Qhia
Ntxiv Daim Ntawv Qhia rau Cov Ntawv Qhia
Ntxiv Daim Ntawv Qhia rau Cov Ntawv Qhia
Ntxiv Daim Ntawv Qhia rau Cov Ntawv Qhia
Ntxiv Daim Ntawv Qhia rau Cov Ntawv Qhia
Ntxiv Daim Ntawv Qhia rau Cov Ntawv Qhia
Ntxiv Daim Ntawv Qhia rau Cov Ntawv Qhia

Rub tawm pfodDesigner app los ntawm Google Ua Si, qhib nws thiab nyem rau "Pib Cov Ntawv Qhia Tshiab"

Nyem rau ntawm "Hom Phiaj Xwm" thiab tom qab ntawd ntawm "Bluetooth Low Energy" khawm kom pom cov npe ntawm qee 11 BLE cov laug cam (nqes mus kom pom lwm txoj kev xaiv). Xaiv ntawm Adafruit Bluefruit Feather52.

Rov qab mus rau Editing menu thiab nyem rau "Edit Prompt" thiab teeb tsa qhov tsim nyog rau cov ntawv qhia zaub mov no, piv txwv. "Feather52" thiab cov ntawv loj thiab loj +7. Cov keeb kwm yav dhau xim tau sab laug raws li 'default' White

Rov qab mus thiab nyem rau ntawm "Ntxiv Cov Ntawv Qhia Khoom", nqes mus thiab xaiv "Chart Button" uas qhib daim phiaj khawm hloov kho lub vijtsam. Koj tuaj yeem hloov pauv qhov khawm lub ntsej muag ntawm no. Hauv qhov xwm txheej no khawm cov ntawv tau hloov mus rau "Hnub/Sijhawm cov phiaj xwm ntawm A0" thiab lwm qhov tsis raug tau raug tso tseg ib yam.

Qhov no ua rau koj khawm ntawm cov ntawv qhia zaub mov uas yuav qhib lub vijtsam duab.

Kauj Ruam 3: Hloov Kho Cov Phiaj Xwm thiab Cov Lables

Hloov kho Cov Phiaj Xwm thiab Lables
Hloov kho Cov Phiaj Xwm thiab Lables
Hloov kho Cov Phiaj Xwm thiab Lables
Hloov kho Cov Phiaj Xwm thiab Lables
Hloov kho Cov Phiaj Xwm thiab Lables
Hloov kho Cov Phiaj Xwm thiab Lables
Hloov kho Cov Phiaj Xwm thiab Lables
Hloov kho Cov Phiaj Xwm thiab Lables

Nyem rau ntawm “Hnub/Sijhawm cov phiaj xwm ntawm A0” kom qhib Kev Hloov Kho Cov Phiaj Xwm screen, qhov uas koj tuaj yeem nkag mus rau daim ntawv cim npe, X-axis hom, phiaj xwm cov ntaub ntawv ncua thiab (los ntawm kev nqes mus) cov phiaj xwm lawv tus kheej. Kho Cov Ntawv Cim Daim Ntawv rau qee yam uas tsim nyog, xws li "A0 Volts" yog.

Scroll cia thiab rau Cov Phiaj Xwm 2 thiab 3 qhib Kho Cov Phiaj Xwm thiab nyem Hide Plot kom tshem lawv tawm ntawm daim duab qhia chaw.

Tom qab ntawv nyem rau "Kho Cov Phiaj Xwm 1" thiab teeb tsa daim phiaj phiaj xwm (piv txwv li A0), yAxis units (piv txwv li Volts), tso zis siab tshaj 3.6V thiab txuas rau I/O pin A0.

Scroll rov qab thiab nyem rau "Chart Preview" mus rau qhov tsis ntev los no 0 piv txwv cov ntaub ntawv cov ntsiab lus, ntawm 1sec sib nrug, npaj rau lub sijhawm dhau los hauv feeb: secs.

Rau txhua lub sijhawm dhau los cov phiaj xwm ua rau xoom chav nyob tsis tau tshwm sim yog li hauv cov phiaj xwm no tsuas yog cov sijhawm> 1min muaj feeb ua ntej qhia.

Kauj Ruam 4: Xaiv Hnub Tim/Sijhawm

Xaiv Hnub Tim/Sijhawm
Xaiv Hnub Tim/Sijhawm
Xaiv Hnub Tim/Sijhawm
Xaiv Hnub Tim/Sijhawm
Xaiv Hnub Tim/Sijhawm
Xaiv Hnub Tim/Sijhawm

Rau lub sijhawm dhau los cov phiaj xwm hauv chav ua haujlwm tsuas yog nce ntxiv raws li lub sijhawm mus. Txhawm rau pom ib qho piv txwv ntawm qhov no rov qab mus rau "Kho Cov Phiaj Xwm" tshuaj ntsuam thiab nce Cov Plot Cov Ntaub Ntawv ncua mus rau 15 feeb (hauv qab ntawm lub vijtsam no)

Tom qab ntawv nyem rau kab ntawv saib ua ntej kom pom tib cov ntaub ntawv piv txwv tab sis tam sim no nrog 15 feeb sib nrug ntawm cov qauv. Raws li koj tuaj yeem pom cov feeb ib feeb ntawm mm: ss tsuas yog nce zuj zus.

Tam sim no rov qab thiab nyem rau ntawm X-axis khawm los qhia qhov xaiv me me ntawm txhua qhov ua tau X-axis cov ntaub ntawv/lub sijhawm (nqis mus rau ntau dua)

Saum toj no yog xaiv cov phiaj xwm saib ua ntej siv cov qauv X-axis sib txawv.

Cov phiaj xwm hnub/sijhawm qhia ntawm no yog nyob hauv lub sijhawm 'hauv zos'. Kuj tseem muaj cov kev xaiv hom phiaj rau hnub tim/sijhawm hauv UTC. Txog kev ua tiav cov txheej txheem xaiv hnub tim/sijhawm ua tau pom hauv pfodSpecification.pfd.

Kauj Ruam 5: Tsim thiab Xeem Arduino Sketch

Tsim thiab Xeem Arduino Sketch
Tsim thiab Xeem Arduino Sketch
Tsim thiab Xeem Arduino Sketch
Tsim thiab Xeem Arduino Sketch

Thaum koj zoo siab nrog koj daim ntawv teev cov hom ntawv thiab cov ntaub ntawv luv, koj tuaj yeem mus rau "Kho kom raug Menu_1" npo thiab nqes mus thiab "Tsim Code" rau koj xaiv pawg phiaj xwm. Nov yog cov qauv piv txwv rau Adafruit Feather52 siv 1sec cov ntaub ntawv sib nrug thiab mm: ss lub sijhawm dhau los, pfodFeather52_timeplot.ino

Saum toj no yog cov phiaj xwm A0 los ntawm Feather52

Hloov cov hom ntawv rau Weekday hr: feeb: sec (~ E HH: mm: ss) thiab rov tsim dua cov cai (pfodFeather52_dateplot.ino) muab cov phiaj xwm zoo li thib ob saum toj no.

Koj tuaj yeem hloov kho X-hom ntawv ncaj qha hauv koj daim duab Arduino, raws li tau piav qhia tom ntej.

Kauj Ruam 6: PfodApp Plot Hnub/Sijhawm Li Cas Los ntawm Millis ()?

Thaum pfodApp txuas, nws nco nws lub sijhawm 'hauv zos' thiab UTC lub sijhawm thiab thov pfodDevice's (Arduino board's) cov phiaj xwm tam sim no cov ntaub ntawv timestamps. Siv cov ntaub ntawv no pfodApp tuaj yeem npaj lub sijhawm millisecond timestamps raws li lub sijhawm dhau los piv txwv li hloov pauv milliseconds mus rau feeb feeb sec thiab lwm yam, lossis npaj hnub thiab sijhawm lub sijhawm millisecond timestamps sawv cev txheeb ze rau thaum kev sib txuas tau ua thiab pfodDevice lub sijhawm tam sim no tau thov.

Saib hauv Arduino tsim cov duab kos (piv txwv li pfodFeather52_dateplot.ino), muaj peb qho me me ntawm cov cai uas ua rau Arduino sab ntawm cov phiaj.

Lub voj () ntu ntu uas ua haujlwm pfodApp's {@} lub sijhawm thov tam sim no

// tuav {@} thov} lwm tus yog ('@' == cmd) {// pfodApp thov 'tam sim no' lub sijhawm plot_mSOffset = millis (); // ntes tam sim no millis raws li offset rawdata timestamps parser.print (F ("{@` 0} ")); // rov qab '0 raws li' tam sim no 'cov ntaub ntawv nyoos milliseconds

Koj tsuas tuaj yeem rov qab tus nqi tam sim no ntawm millis (), tab sis millis () qhwv ncig rov qab rau 0 txhua 49.7 hnub, uas yuav ua rau cov phiaj xwm dhia rov qab. Yog li hloov txoj cai nco txog qhov tam sim no millis () tus nqi thaum {@} tau thov, thiab rov qab {@`0} piv txwv li lub sijhawm tam sim no millisecond ntawm xoom. Tom qab ntawd thaum xa cov ntsiab lus rawdata cov duab kos siv

plot_1_var = analogRead (A0); // nyeem cov tswv yim rau cov phiaj // plot_2_var zaj lus zais Yog li tsis muaj cov ntaub ntawv muab rau ntawm no // plot_3_var zaj lus zais thaum tsis muaj cov ntaub ntawv muab rau ntawm no // xa cov ntaub ntawv phiaj xwm hauv CSV hom parser.print (millis ()-plot_mSOffset); // sijhawm hauv milliseconds ….

yog li lub millisecond timestamp xa nrog cov ntaub ntawv pib ntawm 0 thiab nce mus txog 49.7 hnub. Yog tias koj txuas txuas txuas ntxiv rau 49.7 hnub tom qab ntawd koj yuav pom cov phiaj xwm dhia rov qab los ntawm ~ 50 hnub. Kev sib txuas thiab rov txuas dua ib zaug txhua 49.7 hnub zam qhov no.

Ib feem peb ntawm cov phiaj xwm hnub/sijhawm yog cov phiaj xwm xov.

} lwm tus yog ('A' == cmd) {// tus neeg siv nias - 'Hnub/Sijhawm cov phiaj xwm ntawm A0' // hauv Cov Ntawv Qhia Tseem Ceeb ntawm Menu_1 // rov xa cov lus cog tseg. parser.print (F ("{= A0 Volts ~ E HH: mm: ss | date | A0 ~~~ Volts ||}"));

Thaum tus neeg siv nias "Hnub/Sijhawm cov phiaj xwm ntawm A0", pfodApp xa {A} cmd mus rau pfodDevice thiab pfodDevice teb nrog cov phiaj xwm lus, {= … {= A0 Volts ~ E HH: mm: ss | date | A0 ~~~ Volts ||} uas muaj X-axis hom E HH: mm: ss

Java SimpleDateFormat tawm tswv yim tau txais ntawm no. pfodApp Cov Ntaub Ntawv Teev Npe thiab Plotting thiab pfodSpecification.pdf muaj cov ncauj lus kom ntxaws ntawm kab lus.

Kauj Ruam 7: Luam tawm Hnub/Sijhawm Cov Phiaj Xwm hauv Koj Lub Computer

Luam dua Hnub/Sijhawm Cov Phiaj Xwm hauv Koj Lub Computer
Luam dua Hnub/Sijhawm Cov Phiaj Xwm hauv Koj Lub Computer
Luam dua Hnub/Sijhawm Cov Phiaj Xwm hauv Koj Lub Computer
Luam dua Hnub/Sijhawm Cov Phiaj Xwm hauv Koj Lub Computer
Luam dua Hnub/Sijhawm Cov Phiaj Xwm hauv Koj Lub Computer
Luam dua Hnub/Sijhawm Cov Phiaj Xwm hauv Koj Lub Computer

Los ntawm lub neej ntawd, pfodApp sau tag nrho cov ntaub ntawv rawdata tuaj rau hauv cov ntaub ntawv teev npe ntawm koj lub xov tooj, tshwj tsis yog koj tau xiam qhov kev txiav txim no hauv qhov kev hloov kho qhov screen, saib pfodAppForAndroidGettingStarted.pdf

Thaum koj kho pfodApp, cov lus luv luv qhia nrog qhov chaw nyob thiab lub npe ntawm cov ntaub ntawv teev cia, piv txwv li. /pfodAppRawData/pfod_bluefruit52.txt Cov ntaub ntawv ntawd nyob hauv CSV hom ntawv, tus lej cim tseg, thiab tom qab hloov nws mus rau koj lub khoos phis tawj (saib pfodAppForAndroidGettingStarted.pdf rau kev xaiv hloov chaw), koj tuaj yeem qhib nws hauv daim ntawv nthuav dav los npaj cov ntaub ntawv.

Nov yog thawj ob peb kab ntawm cov ntaub ntawv teev cia.

// pfodApp V3.0.360, sijhawm hauv nroog, UTC, mS ib hnub, pfod bluefruit52 lub sijhawm tam sim no (mS), pfod bluefruit52 lub sijhawm tam sim no, // txuas ntawm, 2019/04/20 11: 32: 50.238, 2019/04/20 01: 32: 50.238, 86400000, 0, 366, 0.25,, 1366, 0.29,, 2366, 0.31,, 3366, 0.33,, 4366, 0.33, Saum toj no koj tuaj yeem pom lub sijhawm 'hauv zos' thiab UTC sijhawm uas pfodApp txuas nrog rau Feather52 thiab lub sijhawm tam sim no hauv mS uas Feather52 tshaj tawm ntawm {@..} teb. Kab ntawv kawg yog khoob, vim tias tsis muaj RTC lossis GPS thiab yog li tsis muaj lub sijhawm tam sim no hauv yyyy/MM/dd lub sijhawm tau tshaj tawm los ntawm Feather52.

Txhawm rau npaj cov ntaub ntawv tiv thaiv lub sijhawm dhau los, rho tawm lub sijhawm tam sim no (mS) los ntawm lub sijhawm millisecond stamp thiab tom qab ntawd faib los ntawm mS ib hnub tus nqi. Nov yog daim ntawv nthuav qhia nrog cov mis ntxiv thiab cov txiaj ntsig tau npaj tseg. Daim ntawv nthuav qhia, hauv qab no, (pfod_bluefruit52.xls) yog OpenOffice spreadsheet tau khaws tseg hauv Excel hom ntawv.

Hauv OpenOffice, cov phiaj xwm yog cov phiaj sib faib thiab x-axis ntawm cov phiaj xwm tau teeb tsa hauv HH: MM: SS Nco tseg: daim ntawv nthuav tawm hnub/sijhawm tsis zoo ib yam li cov phiaj xwm siv los ntawm pfodApp. Piv txwv li hauv pfodApp, MM yog hli thiab hli yog feeb.

Txhawm rau tawm tsam hnub tim thiab sijhawm, koj tsuas yog xav tau ntxiv lub sijhawm txuas mus rau lub sijhawm daim ntawv thiab rov ua dua. (pfod_bluefruit52_date.xls)

Nco tseg: Lub sijhawm hauv nroog thiab UTC tau raug xa tawm raws li cov ntawv hauv kuv daim ntawv nthuav tawm yog li kuv xav tau tshem tus thawj coj 'ua ntej siv lawv hauv tus lej.

Kauj Ruam 8: Yuav Ua Li Cas Thiaj Li 49.7day Millis () Txwv thiab Vim Li Cas Koj Thiaj Li Tsis Ua

Raws li tau hais los saum no hauv pfodApp lub phiaj xwm Hnub/Sijhawm li cas los ntawm millis ()?, Yog tias koj tseem txuas nrog txuas ntxiv mus ntev dua 49.7 hnub lub sij hawm millisecond timestamps yuav qhwv rov qab rau xoom. Ob peb kab ntawm txoj cai tuaj yeem zam qhov no tab sis nws tsis pom zoo.

Thawj zaug yuav ua li cas zam kev qhwv ncig. Ntxiv lwm qhov tsis tau kos npe nkag sib txawv kom taug qab cov naj npawb ntawm cov sij hawm timestamps qhwv ib puag ncig thiab luam tawm cov txiaj ntsig ua ke hauv HEX.

uint_t mSwrapCount = 0; uint32_t lastTimeStamp = 0;

… Plot_1_var = analogRead (A0); // nyeem cov tswv yim rau cov phiaj // plot_2_var zaj lus zais Yog li tsis muaj cov ntaub ntawv muab rau ntawm no // plot_3_var zaj lus zais Yog li tsis muaj cov ntaub ntawv muab rau ntawm no // xa cov ntaub ntawv phiaj xwm hauv CSV hom uint32_t timeStamp = millis ()-plot_mSOffset; yog (timeStamp <lastTimeStamp) {// timeStamp qhwv rov qab rau 0 mSwrapCount ++; // ntxiv ib los suav} lastTimeStamp = lub sijhawm; parser.print ("0x"); parser.print (msWrapCount, HEX); parser.print (timeStamp, HEX); // sijhawm hauv milliseconds hauv HEX….

Thaum rov qab los {@.. teb meej mSwrapCount ib yam.

// tuav {@} thov} lwm tus yog ('@' == cmd) {// pfodApp thov 'tam sim no' lub sijhawm plot_mSOffset = millis (); // ntes tam sim no millis raws li offset rawdata timestamps mSwrapCount = 0; // clear suav suav. parser.print (F ("{@` 0} ")); // rov qab '0 raws li' tam sim no 'cov ntaub ntawv nyoos milliseconds

Cov ntawv teev sijhawm tam sim no yuav muab tus 'raug' tus nqi rau 40.7 hnub tom ntej * 65536 ~ = 7308 xyoo.

pfodApp yuav cia li hloov hex timestamps rau kev npaj thiab teev lawv raws nraim li tau txais, piv txwv li hauv hex. Hauv (OpenOffice) daim ntawv nthuav qhia koj siv cov qauv no los hloov cov hlua hex, hauv A2, rau mS (qhov twg A1 yog ib lub xov tooj uas tsis muaj dab tsi) = HEX2DEC (Hloov (A2; 1; 2; A1))

Vim li cas koj thiaj tsis xav ua qhov no

Raws li tau hais los saum no, nws yog qhov yooj yim los txuas sijhawm mS lub sijhawm ntev dua 50 hnub. Txawm li cas los xij koj yuav tsis xav ua qhov ntawd vim tias lawv dhau los ua qhov tseeb. Ib qho 16Mhz siv lead ua raug siv los tsim cov millis () cov txiaj ntsig hauv micro muaj qhov raug ntawm ~ 50ppm (ib feem ntawm ib lab). Qhov no txhais tau tias tom qab 49.7 hnub lub sij hawm millisecond tuaj yeem tawm los ntawm 3 ½ mins thiab qhov uas tsis quav ntsej qhov cuam tshuam ntawm qhov kub ntawm qhov siv lead ua raug.

Dhau lub sijhawm sib txuas luv, qhov raug qhov tseeb no tsis yog teeb meem li {@.. cov lus teb rov ua dua tshiab lub sij hawm millisecond rau lub xov tooj ntawm tes/hnub/sijhawm ntawm txhua qhov txuas dua. Txawm li cas los xij yog tias koj xav nyob twj ywm txuas nrog rau lub sijhawm ntev (hnub) thiab txuas ntxiv cov ntaub ntawv, tom qab ntawd koj yuav tsum siv qee yam uas raug ntau dua li qhov ua hauv millis (), xws li RTC lossis GPS module.

Kauj Ruam 9: Siv RTC (Lub Sijhawm Tiag)

Siv RTC (Lub Sijhawm Tiag)
Siv RTC (Lub Sijhawm Tiag)
Siv RTC (Lub Sijhawm Tiag)
Siv RTC (Lub Sijhawm Tiag)

Muaj ntau tus lej RTC muaj, ib qho uas raug dua yog DS3231 piv txwv. Adafruit's DS3231 tus qauv. Qhov tseeb tau teev tseg yog +/- 2ppm dhau 0 txog 40C. i.e. ~ +/- 5 sec/hli.

Yog tias koj xav npaj cov ntaub ntawv uas muaj hnub tim/sijhawm timestamps, piv txwv li 2019/04/19 20: 4: 34, tom qab ntawd koj yuav tsum hloov kho {@ cov lus teb kom xa hnub/sijhawm tam sim no, piv txwv li. {@`0 ~ 2019/4/19 3: 33: 5}. Nov yog qee qhov qauv piv txwv hloov pauv rau pfodDesigner tsim cov duab kos rau kev siv RTC module, piv txwv tias koj tab tom siv RTClib lub tsev qiv ntawv thiab tau ntxiv cov lej pib ua ntej RTC module.

// tuav {@} thov} lwm tus yog ('@' == cmd) {// pfodApp thov 'tam sim no' lub sijhawm plot_mSOffset = millis (); // ntes tam sim no millis raws li offset rawdata timestamps parser.print (F ("{@` 0 "}); // rov qab 0 raws li 'tam sim no' cov ntaub ntawv nyoos milliseconds parser.print ('~'); // pib hlua ntawm hnub tim/sijhawm DateTime tam sim no = rtc.now () sendDateTime (& tam sim no); // xa yyyy/M/d/H: m: s rau parser.print, dhau qhov chaw nyob & raws li arg. parser.print ('}'); // kawg ntawm {@ teb xws li {@ `0 ~ 2019/4/19 3: 33: 5}….

// xa hnub tim rau parser printvoid sendDateTime (DateTime* dt) {parser.print (dt-> xyoo (), DEC); parser.print ('/'); parser.print (dt-> hli (), DEC); parser.print ('/'); parser.print (dt-> hnub (), DEC); parser.print (''); parser.print (dt-> teev (), DEC); parser.print (':'); parser.print (dt-> feeb (), DEC); parser.print (':'); parser.print (dt-> thib ob (), DEC); }

void sendData () {yog (plotDataTimer.isFinished ()) {plotDataTimer.repeat (); // rov pib dua cov phiaj xwm cov ntaub ntawv timer, tsis muaj drift // muab qhov tseem ceeb rau cov phiaj hloov pauv los ntawm koj cov kev hloov pauv los yog nyeem ADC cov tswv yim plot_1_var = analogRead (A0); // nyeem cov tswv yim rau cov phiaj // plot_2_var zaj lus zais Yog li tsis muaj cov ntaub ntawv muab rau ntawm no // plot_3_var zaj lus zais Thaum tsis muaj cov ntaub ntawv muab rau ntawm no // xa cov ntaub ntawv phiaj xwm hauv CSV hom DateTime tam sim no = rtc.now (); sendDateTime (& tam sim no); // xa yyyy/M/d/H: m: s rau parser.print, dhau qhov chaw nyob & raws li arg. parser.print (','); parser.print (((ntab) (plot_1_var - plot_1_varMin)) * plot_1_scaling + plot_1_varDisplayMin); parser.print (','); // Daim phiaj 2 tau muab zais. Tsis xa cov ntaub ntawv. parser.print (','); // Daim phiaj 3 tau muab zais. Tsis xa cov ntaub ntawv. parser.println (); // kawg ntawm CSV cov ntaub ntawv kaw tseg}}

~ 2019/4/19 3: 33: 5 ib feem ntawm {@ cov lus teb cia pfodApp paub dab tsi pfodDevice xav tias yog hnub thiab sijhawm tam sim no. Koj cov duab kos tuaj yeem xa cov ntaub ntawv nrog yMd Hms timestamps thiab pfodApp yuav npaj lawv ib yam li lub sijhawm dhau los ntawm lub sijhawm txuas lossis LOSSIS raws li hnub thiab sijhawm, nyob ntawm X-axis hom uas koj qhia.

Thaum npaj phiaj xwm tiv thaiv hnub thiab sijhawm, pfodApp cov phiaj xwm niaj hnub kho rau ib qho 'drift' hauv RTC los ntawm kev sib piv pfodDevice cov ntawv tshaj tawm lub sijhawm tam sim no tiv thaiv lub xov tooj lub sijhawm tam sim no. Qhov kev kho no tseem ua haujlwm RTC tau teeb tsa lub sijhawm sib txawv los ntawm koj lub xov tooj ntawm tes hauv cheeb tsam. millis () timestamps txuas ntxiv ua haujlwm zoo li Siv Arduino millisecond timestamps, Kauj Ruam 5 saum toj no.

Nov yog qhov piv txwv daim ntawv nthuav qhia ntawm chav sov ntau dua li 8 hnub, Office_Temp.xls Thaum cov ntaub ntawv teev npe tau nkag mus thawj kab ntawv tau cim ua YMD los hloov cov ntawv mus rau hnub/sijhawm. Koj tseem yuav tsum tau tshem tus thawj coj 'daim ntawv teev sijhawm hauv zos, UTC thiab Chaw Ua Haujlwm Temp lub sijhawm tam sim no kom muaj daim ntawv nthuav qhia txhais lawv raws li hnub thiab sijhawm.

Txhawm rau kom tau txais cov phiaj xwm tib yam uas pfodApp qhia, koj yuav tsum xam "Kho Hnub/Sijhawm". Hauv qhov no RTC lub sijhawm yog 2 vib nas this tom qab lub sijhawm hauv xov tooj ntawm tes, yog li rau txhua lub sijhawm RTC tau ntxiv (lub sijhawm hauv zos - Lub Sijhawm Ua Haujlwm Lub Sijhawm tam sim no) kom tau txais lub sijhawm tiag tiag hauv cheeb tsam.

Txog sijhawm cov phiaj xwm dhau los, tsim kab ntawv tshiab uas muaj (hnub tim/sijhawm timstamp-Lub Sijhawm Ua Haujlwm tam sim no) thiab siv qhov ntawd raws li X-axis hauv kab ntawv (Office_TempElapsed.xls) Qhov tseeb hauv qhov no, pfodApp tsim cov sijhawm teev sijhawm zoo dua hauv hnub hr: feeb: sec.

Kauj Ruam 10: Siv GPS Module

Siv GPS module zoo ib yam li siv RTC tus qauv, tshwj tsis yog tias GPS cov qauv muaj milliseconds muaj, xyoo pib ntawm 2000 thiab lub sijhawm ploj UTC leap thib ob (saib https://tycho.usno.navy.mil/leapsec.html) Hnub GPS thiab sijhawm tam sim no yog 18 vib nas this ua ntej UTC, zoo li thaum Lub Ib Hlis 2018.

Adafruit GPS lub tsev qiv ntawv rau Adafruit Ultimate GPS, tsis zoo li RTClib, tsis ntxiv qhov 2000 xyoo offset rau GPS xyoo, yog li ntawd yuav tsum tau ntxiv thaum koj xa hnub tim thiab sijhawm timestamp. Tsis tas li txawm hais tias lub tsev qiv ntawv GPS muab khoom siv milliseconds uas muaj qhov ua tau zoo mus sij hawm ntev, lawv tsis raug. Lub sijhawm GPS hloov tshiab tsuas yog ib zaug txhua 100mS thiab tom qab ntawd muaj qhov ncua sijhawm ntxiv tau txais cov ntaub ntawv xov xwm ntawm qeeb 9600 baud thiab lwm qhov ncua hauv kev txheeb xyuas nws. Txhua yam uas ntxiv rau lub millisecond hauv qhov tseeb thaum timestamping cov ntaub ntawv nyeem.

Nov yog qee qhov qauv piv txwv hloov pauv rau pfodDesigner tsim cov duab kos rau kev siv GPS module, piv txwv tias koj tab tom siv Adafruit lub tsev qiv ntawv GPS thiab tau ntxiv cov cai kom tau txais thiab cais cov lus rau hauv GPS yam khoom.

// tuav {@} thov} lwm tus yog ('@' == cmd) {// pfodApp thov 'tam sim no' lub sijhawm plot_mSOffset = millis (); // ntes tam sim no millis raws li offset rawdata timestamps parser.print (F ("{@` 0 "}); // rov qab 0 raws li 'tam sim no' cov ntaub ntawv nyoos milliseconds parser.print ('~'); // pib hlua ntawm hnub tim/sijhawm xaDateTime (& GPS); // xa yyyy/M/d/H: m: s rau parser.print, dhau qhov chaw nyob & raws li arg. parser.print ('}'); // kawg ntawm@@ teb xws li {@`0 ~ 2019/4/19 3: 33: 5}….

// xa hnub tim rau parser printvoid sendDateTime (Adafruit_GPS* gps) {parser.print (F ("20"); // 20.. xyoo parser.print (gps-> xyoo, DEC); parser.print ('/ '); parser.print (gps-> hli, DEC); parser.print ('/'); parser.print (gps-> hnub, DEC); parser.print (' '); parser.print (gps- > teev, DEC); parser.print (':'); parser.print (gps-> feeb, DEC); parser.print (':'); parser.print (gps-> thib ob, DEC); // parser.print ('.'); yog tias xa cov milliseconds // yog tias koj xav xa mS koj yuav tsum tau pad lub gps-> milliseconds tus nqi nrog ua zeros // piv txwv li 3 yuav tsum tau padded rau 003}

void sendData () {yog (plotDataTimer.isFinished ()) {plotDataTimer.repeat (); // rov pib dua cov phiaj xwm cov ntaub ntawv timer, tsis muaj drift // muab qhov tseem ceeb rau cov phiaj hloov pauv los ntawm koj cov kev hloov pauv los yog nyeem ADC cov tswv yim plot_1_var = analogRead (A0); // nyeem cov tswv yim rau cov phiaj // plot_2_var zaj lus zais Yog li tsis muaj cov ntaub ntawv muab rau ntawm no // plot_3_var zaj lus zais Thaum tsis muaj cov ntaub ntawv muab rau ntawm no // xa cov ntaub ntawv phiaj xwm hauv CSV hom xaDateTime (& GPS); // xa yyyy/M/d/H: m: s rau parser.print, dhau qhov chaw nyob & raws li arg. parser.print (','); parser.print (((ntab) (plot_1_var - plot_1_varMin)) * plot_1_scaling + plot_1_varDisplayMin); parser.print (','); // Daim phiaj 2 tau muab zais. Tsis xa cov ntaub ntawv. parser.print (','); // Daim phiaj 3 tau muab zais. Tsis xa cov ntaub ntawv. parser.println (); // kawg ntawm CSV cov ntaub ntawv kaw tseg}}

Thaum npaj phiaj xwm tawm tsam hnub tim thiab sijhawm, pfodApp cia li kho rau vib nas this. Raws li thaum Lub Ib Hlis 2018, GPS sijhawm yog 18 sec ua ntej ntawm UTC. pfodApp kho qhov no los ntawm kev sib piv hnub/sijhawm rov qab los ntawm GPS ntawm kev sib txuas, ntawm {@ teb, tawm tsam lub xov tooj UTC hnub thiab sijhawm. Tsim cov phiaj hauv daim ntawv nthuav tawm los ntawm pfodApp cav cov ntaub ntawv yog tib yam li rau RTC cov qauv, saum toj no. Ntxiv rau (lub sijhawm hauv nroog - Lub Sijhawm Ua Haujlwm Lub Sijhawm tam sim no) rau GPS lub sijhawm cim raug rau lub vib nas this dhia.

millis () timestamps txuas ntxiv ua haujlwm zoo li Siv Arduino millisecond timestamps, Kauj Ruam 5 saum toj no.

Kauj Ruam 11: Xaus

Siv pfodApp ntawm koj lub xov tooj ntawm tes cia koj npaj cov ntaub ntawv tiv thaiv hnub thiab sijhawm lossis sijhawm dhau los, siv tsuas yog Arduino's millis () ua haujlwm. Siv pfodApp cav cov ntaub ntawv koj tuaj yeem rov tsim cov phiaj xwm hnub/sijhawm no hauv daim ntawv nthuav tawm. Yog tias koj txoj haujlwm Arduino muaj tus lej RTC, koj tuaj yeem nkag mus thiab sau hnub tim thiab lub sijhawm RTC sijhawm timestamps, kho qhov raug rau RTC 'drift'. Yog tias koj txoj haujlwm Arduino muaj GPS module koj tuaj yeem nkag mus thiab tawm tswv yim nws cov sijhawm tau raug thiab pfodApp yuav kho qhov GPS ploj mus ib pliag vib nas this.

Hauv txhua qhov xwm txheej cov ntaub ntawv nyoos los ntawm koj txoj haujlwm Arduino tau nkag mus raws qhov tau txais, tsis raug kho. Txawm li cas los xij pfodApp cav cov ntaub ntawv suav nrog cov ntaub ntawv ntxiv los tso cai rau koj rov tsim cov kev hloov kho no hauv daim ntawv nthuav tawm los ntawm cov ntawv teev npe rub tawm.

Tsis xav tau Android coding. Cov phiaj xwm phiaj xwm yog txhua qhov teev tseg los ntawm kab ntawv me me hauv koj daim duab Arduino. Pub dawb pfodDesigner tsim kom tiav Arduino cov ntaub ntawv logging thiab npaj cov duab kos rau ntau yam ntawm Arduino cov laug cam txuas ntawm WiFi, Classic Bluetooth, BLE thiab SMS

Pom zoo: