Cov txheej txheem:

Arduino Datalogger: 8 Kauj Ruam (nrog Duab)
Arduino Datalogger: 8 Kauj Ruam (nrog Duab)

Video: Arduino Datalogger: 8 Kauj Ruam (nrog Duab)

Video: Arduino Datalogger: 8 Kauj Ruam (nrog Duab)
Video: Amazing arduino project 2024, Hlis ntuj nqeg
Anonim
Arduino Datalogger Cov
Arduino Datalogger Cov
Arduino Datalogger Cov
Arduino Datalogger Cov

Hauv qhov kev qhia no, peb yuav ua cov ntaub ntawv yooj yim logger siv Arduino. Lub ntsiab lus yog kawm paub qhov pib ntawm kev siv Arduino txhawm rau ntes cov ntaub ntawv thiab luam tawm mus rau lub davhlau ya nyob twg. Peb tuaj yeem siv qhov teeb tsa yooj yim no kom ua tiav ntau yam haujlwm.

Yuav pib:

Koj yuav xav tau Tinkercad (www.tinkercad.com) tus as khauj. Lub taub hau thiab sau npe nrog koj tus email lossis tus social media account.

Kev nkag mus coj koj mus rau Tinkercad Dashboard. Nyem "Circuits" rau sab laug thiab xaiv "Tsim Circuit Court tshiab". Cia peb pib!

Koj tuaj yeem pom cov ntaub ntawv ua tiav ntawm TInkercad Circuits - Ua tsaug rau kev tshuaj xyuas nws!

Kauj Ruam 1: Ntxiv Qee Cheeb Tsam

Ntxiv Qee Cheeb Tsam
Ntxiv Qee Cheeb Tsam
Ntxiv Qee Cheeb Tsam
Ntxiv Qee Cheeb Tsam
Ntxiv Qee Cheeb Tsam
Ntxiv Qee Cheeb Tsam

Koj yuav xav tau qee yam khoom siv yooj yim. Cov no suav nrog:

  • Arduino pawg thawj coj saib
  • Cov qhob cij

Ntxiv cov ntawd los ntawm kev tshawb fawb rau lawv thiab nyem-rub lawv mus rau thaj tsam nruab nrab.

Muab lub khob cij tso rau ntawm Arduino. Nws ua kom yooj yim dua los saib cov kev sib txuas tom qab.

Kauj Ruam 2: Lus Cim Txog Breadboards

Lus Cim Txog Breadboards
Lus Cim Txog Breadboards

Lub khob cij yog lub cuab yeej pab tau zoo tshaj plaws rau kev tsim qauv sai. Peb siv nws los txuas cov khoom siv. Qee yam yuav tsum nco ntsoov.

  1. Cov dots tau txuas nrog ntsug, tab sis kab hauv nruab nrab cais qhov kev sib txuas no los ntawm kab saum toj thiab hauv qab.
  2. Kab ntawv tsis txuas sab laug mus rau sab xis, zoo li hla kab. Qhov no txhais tau tias txhua lub Cheebtsam yuav tsum txuas nrog hla txhua kab tsis yog nqes saum lawv.
  3. Yog tias koj xav tau siv cov nyees khawm lossis cov hloov pauv, txuas lawv hla qhov tawg hauv nruab nrab. Peb yuav mus ntsib qhov no hauv kev qhia tom qab.

Kauj Ruam 3: Ntxiv Ob Sensors

Ntxiv Ob Sensors
Ntxiv Ob Sensors

Ob lub ntsuas uas peb tab tom siv yog lub ntsuas hluav taws xob thiab lub ntsuas kub.

Cov ntsuas no ntsuas lub teeb thiab kub. Peb siv Arduino los nyeem tus nqi thiab tso tawm hauv Serial monitor ntawm Arduino.

Tshawb nrhiav thiab ntxiv ob lub ntsuas cua. Nco ntsoov tias lawv tau teeb tsa hla cov kab ntawm daim ntawv qhia zaub mov. Muab qhov chaw txaus nruab nrab ntawm lawv kom yooj yim pom lawv.

Kauj Ruam 4: Duab Sensorensitive

Cov duab hluav taws xob
Cov duab hluav taws xob
Cov duab hluav taws xob
Cov duab hluav taws xob
Cov duab hluav taws xob
Cov duab hluav taws xob
Cov duab hluav taws xob
Cov duab hluav taws xob
  1. Rau lub teeb pom kev zoo, ntxiv xaim los ntawm 5V tus pin ntawm Arduino rau tib kab ntawv ib yam li sab xis ntawm ib feem hauv lub khob cij. Hloov cov xim hlau rau liab.
  2. Txuas sab laug ntawm tus pin hauv tib kab ntawv rau A0 (A-zero) tus pin ntawm Arduino. Nov yog tus pin analog, uas peb yuav siv los nyeem tus nqi los ntawm lub ntsuas pa. Xim cov hlau no daj lossis lwm yam uas tsis yog liab lossis dub.
  3. Muab tus tiv thaiv (tshawb nrhiav thiab nyem-rub) rau ntawm lub rooj tsavxwm. Qhov no ua tiav qhov Circuit Court thiab tiv thaiv lub sensor thiab tus pin.

    • Tig nws ib ncig kom nws hla cov kab.
    • Txuas ib txhais ceg mus rau sab xis sab xis ntawm lub khob cij
    • Muab cov xaim los ntawm lwm qhov kawg ntawm tus tiv thaiv rau hauv av

      Hloov cov xim hlau rau dub

  4. Muab ob npaug rau xyuas txhua qhov kev sib txuas. Yog tias qee yam tsis nyob hauv qhov chaw raug, qhov no yuav tsis ua haujlwm raug.

Kauj ruam 5: Pib Txoj Cai

Pib Txoj Cai
Pib Txoj Cai
Pib Txoj Cai
Pib Txoj Cai
Pib Txoj Cai
Pib Txoj Cai

Cia peb saib cov cai rau cov khoom siv no.

Ua ntej, saib daim duab thib peb hauv qib no. Nws muaj qee cov cai nrog ob txoj haujlwm:

void teeb tsa ()

void lub voj ()

Hauv C ++, txhua lub luag haujlwm muab lawv hom rov qab, tom qab ntawd lub npe, tom qab ntawd ob kab zauv kab zauv uas tuaj yeem siv dhau los hauv kev sib cav, feem ntau yog hloov pauv. Hauv qhov no, hom rov qab yog tsis muaj dab tsi, lossis tsis muaj dab tsi. Lub npe yog teeb tsa thiab kev ua haujlwm tsis siv kev sib cav.

Kev teeb tsa ua haujlwm ib zaug thaum khau raj Arduino (thaum koj ntsaws nws lossis txuas cov roj teeb).

Lub voj ua haujlwm khiav hauv lub voj tas li los ntawm millisecond qhov teeb tsa ua tiav.

Txhua yam koj muab tso rau hauv lub voj kev ua haujlwm yuav khiav thaum Arduino khiav. Txhua yam sab nraud uas yuav tsuas yog khiav thaum raug hu. Zoo li yog peb tau txhais thiab hu ua lwm txoj haujlwm sab nraum lub voj.

Ua Haujlwm

Qhib qhov Code vaj huam sib luag nrog lub pob hauv Tinkercad. Hloov cov Blocks dropdown rau Text. Pom zoo rau lub thawv ceeb toom uas tshwm tuaj. Tam sim no, rho tawm txhua yam koj pom tsuas yog cov ntawv hauv daim duab thib peb hauv cov kauj ruam no.

Ntau yam

Txhawm rau pib, peb yuav tsum tau muab qee qhov hloov pauv kom peb ua rau peb cov cai muaj txiaj ntsig zoo.

Cov lej sib txawv zoo li cov thoob uas tuaj yeem tuav tau ib qho khoom nkaus xwb (C ++ yog qhov peb hu ua cov khoom taw qhia). Yog, peb muaj arrays, tab sis cov no yog qhov tshwj xeeb hloov pauv thiab peb yuav tham txog lawv tom qab. Thaum peb muab qhov sib txawv, peb yuav tsum qhia nws tias nws yog hom twg, tom qab ntawd muab tus nqi rau nws. Nws zoo li no:

int qeeVar = A0;

Yog li, peb tau muab qhov sib txawv thiab muab nws hom int. Int yog tus lej lossis tag nrho tus lej.

"Tab sis koj tsis tau siv tus lej tag nrho!", Kuv hnov koj hais. Qhov tseeb.

Arduino ua qee yam tshwj xeeb rau peb yog li peb tuaj yeem siv A0 los ua ib tus lej, vim tias hauv lwm cov ntaub ntawv nws txhais A0 ua tus lej, yog li peb tuaj yeem siv A0 tas li los hais txog tus lej no yam tsis tas yuav paub tias nws yog dab tsi. Yog tias peb tsuas yog ntaus 0, peb yuav xa mus rau tus lej digital ntawm txoj haujlwm 0, uas yuav tsis ua haujlwm.

Yog li, rau peb cov cai peb yuav sau qhov sib txawv rau lub sensor peb tau txuas nrog. Whilst Kuv pom zoo muab nws lub npe yooj yim, uas yog rau koj.

Koj tus lej yuav tsum zoo li no:

int lightSensor = A0;

void teeb () {} tsis muaj dab tsi voj () {}

Tam sim no, cia qhia Arduino yuav ua li cas thiaj li ua tau lub sensor ntawm tus pin ntawd. Peb yuav ua haujlwm nyob rau hauv teeb tsa teeb tsa tus pin hom thiab qhia Arduino qhov twg los saib nws.

int lightSensor = A0;

teeb tsa tsis muaj dab tsi () {pinMode (lightSensor, INPUT); } void voj () {}

tus pinMode muaj nuj nqi qhia rau Arduino tias tus pin (A0) yuav raug siv ua tus pin INPUT. Nco tseg camelCaseUsed (saib txhua tsab ntawv thawj yog peev, zoo li nws muaj humps, yog li … ntxhuav …!) Qhov no yog ib lub rooj sib tham thiab zoo rau siv tau.

Thaum kawg, cia siv analogRead ua haujlwm kom tau txais qee cov ntaub ntawv.

int lightSensor = A0;

teeb tsa tsis muaj dab tsi () {pinMode (lightSensor, INPUT); } void loop () {int nyeem = analogRead (lightSensor); }

Koj yuav pom peb khaws cov ntawv nyeem hauv qhov sib txawv. Qhov no tseem ceeb heev raws li peb xav tau luam tawm. Wb siv Serial library (lub tsev qiv ntawv yog tus lej peb tuaj yeem ntxiv rau peb cov cai txhawm rau ua kom nrawm dua rau peb sau, tsuas yog hu nws los ntawm nws lub ntsiab lus) luam tawm qhov no mus rau tus saib xyuas.

int lightSensor = A0;

teeb tsa tsis muaj dab tsi () {// Teeb tus pin hom pinMode (lightSensor, INPUT); // Ntxiv cov tsev qiv ntawv hauv Serial.begin (9600); } void loop () {// Nyeem lub sensor int nyeem = analogRead (lightSensor); // Luam tus nqi rau tus saib Serial.print ("Teeb:"); Serial.println (nyeem ntawv); // ncua lub voj tom ntej los ntawm 3 vib nas this ncua (3000); }

Ob peb yam tshiab! Ua ntej, koj yuav pom cov no:

// Nov yog cov lus pom

Peb siv cov lus los qhia rau lwm tus neeg seb peb cov cai ua haujlwm li cas. Koj yuav tsum siv cov no ntau zaus. Tus compiler yuav tsis nyeem cov no thiab hloov lawv mus rau hauv txoj cai.

Tam sim no, peb kuj ntxiv Serial library nrog kab

Serial.begin (9600)

Nov yog qhov piv txwv ntawm txoj haujlwm uas yuav siv kev sib cav. Koj hu lub tsev qiv ntawv Serial tom qab ntawd tau ua haujlwm (peb paub tias nws yog lub luag haujlwm vim yog cov kab zauv puag ncig) thiab dhau los hauv cov lej ua qhov kev sib cav, teeb tsa Serial kom ua haujlwm ntawm 9600baud. Tsis txhob txhawj xeeb vim li cas - tsuas yog paub tias nws ua haujlwm, rau tam sim no.

Qhov tom ntej uas peb tau ua yog luam tawm mus rau tus saib xyuas. Peb siv ob txoj haujlwm:

// Qhov no luam tawm mus rau ntu uas tsis muaj kab tawg (nkag mus rau qhov kawg)

Serial.print ("Teeb:"); // Qhov no tso rau hauv kab tawg yog li txhua lub sijhawm peb nyeem thiab sau, nws mus rau kab tshiab Serial.println (nyeem);

Dab tsi tseem ceeb kom pom yog tias txhua tus muaj lub hom phiaj sib txawv. Xyuas kom tseeb tias koj cov hlua siv cov cim cim ob npaug thiab koj tawm ntawm qhov chaw tom qab cov nyuv. Qhov ntawd pab nyeem tau yooj yim rau tus neeg siv.

Thaum kawg, peb siv lub sijhawm ua haujlwm qeeb, ua kom peb lub voj qeeb thiab ua kom nws tsuas yog nyeem ib zaug txhua peb feeb. Qhov no tau sau hauv ntau txhiab tus thib ob. Hloov nws nyeem ib zaug ib zaug txhua 5 vib nas this.

Zoo kawg! Peb mus!

Kauj Ruam 6: Simulation

Simulation
Simulation
Simulation
Simulation
Simulation
Simulation

Nco ntsoov xyuas txhua yam ua haujlwm los ntawm kev sim simulation. Txog rau lub voj voog no, koj yuav tsum tau qhib lub simulator los tshuaj xyuas nws ua haujlwm thiab txheeb xyuas koj qhov txiaj ntsig.

Pib qhov kev sim siab thiab tshawb xyuas cov ntawv txuas. Hloov tus nqi ntawm lub teeb pom kev zoo los ntawm txhaj nws thiab hloov tus nqi siv tus swb. Koj yuav tsum pom qhov hloov pauv tus nqi hauv cov saib, ib yam. Yog tias nws tsis yog, lossis yog tias thaum koj nias lub khawm Pib Simulation koj tau txais qhov yuam kev, ua tib zoo rov qab thiab tshawb xyuas txhua yam koj tus lej.

  • Ua kom pom tseeb ntawm cov kab qhia hauv lub qhov rai debugging liab uas yuav nthuav qhia rau koj.
  • Yog tias koj cov cai raug thiab qhov simulation tseem tsis ua haujlwm, txheeb xyuas koj cov xov hlau.
  • Rov qab qhib nplooj ntawv - koj yuav muaj qhov tsis cuam tshuam txog kab ke/server yuam kev.
  • Tuav koj lub nrig ntawm lub computer, thiab tshawb xyuas dua. Txhua tus programmer ua qhov no. Txhua. Cov. Sijhawm.

Kauj Ruam 7: Txhim Kho Qhov Kub Sensor

Txhim Kho Qhov Kub Sensor
Txhim Kho Qhov Kub Sensor

Kuv yuav xav tias koj nyob ntawm txoj kev yog tam sim no. Mus tom ntej thiab xaim ntsuas qhov ntsuas kub zoo li daim duab qhia. Nco tseg qhov muab tso rau ntawm 5V thiab GND xov hlau nyob hauv ib qho chaw ib yam li qhov pom kev. Qhov no zoo. Nws zoo li kev sib tw hauv Circuit Court thiab yuav tsis ua teeb meem hauv qhov simulator. Hauv qhov xwm txheej tiag tiag, koj yuav tsum siv pawg tswj hwm los yog daim thaiv thaiv los muab kev tswj hwm lub zog zoo dua qub thiab kev sib txuas.

Tam sim no, cia peb hloov kho cov cai.

Temp sensor chaws

Nov yog qhov nyuaj me ntsis, tab sis tsuas yog vim peb yuav tsum ua qee qhov lej los hloov kev nyeem ntawv. Nws tsis phem heev.

int lightSensor = A0;

int tempSensor = A1; teeb tsa tsis muaj dab tsi () {// Teeb tus pin hom pinMode (lightSensor, INPUT); // Ntxiv cov tsev qiv ntawv hauv Serial.begin (9600); } void loop () {// Lub ntsuas cua sov // Tsim ob qhov sib txawv ntawm ib kab - huag kev ua haujlwm! // Ntab var khaws cov lej zauv ntab ntus, degreesC; // Nyeem tus lej tus lej thiab hloov nws mus rau qhov nyeem los ntawm 0 - 5 // Qhov tseem ceeb voltage = (5/1023 = 0.004882814); voltage = (analogRead (ntsuas ntsuas) * 0.004882814); // Hloov mus rau Qib C degreesC = (voltage - 0.5) * 100; // Luam tawm mus rau tus saib xyuas Serial.print ("Temp:"); Serial.print (degreesC); Serial.println ("oC"); // Nyeem lub sensor int nyeem = analogRead (lightSensor); // Luam tus nqi rau tus saib Serial.print ("Teeb:"); Serial.println (nyeem ntawv); // ncua lub voj tom ntej los ntawm 3 vib nas this ncua (3000); }

Kuv tau ua qee qhov hloov tshiab rau cov cai. Cia peb taug kev ntawm lawv tus kheej.

Ua ntej, kuv ntxiv kab

int tempSensor = A1;

Ib yam li lightSensor, Kuv yuav tsum khaws tus nqi hauv qhov sib txawv kom yooj yim dua tom qab. Yog tias kuv yuav tsum hloov qhov chaw ntawm lub ntsuas cua no (zoo li rov txuas lub rooj tsavxwm) tom qab ntawd kuv tsuas yog yuav tsum hloov ib kab ntawm cov cai, tsis tshawb nrhiav thoob plaws codebase tag nrho los hloov A0 lossis A1, thiab lwm yam.

Tom qab ntawd, peb tau ntxiv kab los khaws qhov nyeem ntawv thiab ntsuas sov hauv ntab. Nco tseg ob qhov hloov pauv ntawm ib kab.

ntab voltage, degreesC;

Qhov no yog qhov muaj txiaj ntsig tiag tiag vim tias nws txo qis ntawm cov kab kuv yuav tsum sau thiab ua kom nrawm dua cov cai. Nws tuaj yeem nyuab dua kom pom qhov yuam kev, txawm li cas los xij.

Tam sim no, peb yuav ua qhov nyeem thiab khaws nws, tom qab ntawd hloov nws mus rau peb cov txiaj ntsig tso tawm.

voltage = (analogRead (ntsuas ntsuas) * 0.004882814);

degreesC = (qhov hluav taws xob - 0.5) * 100;

Ob txoj kab no zoo li nyuaj, tab sis thawj zaug peb tab tom nyeem thiab muab nws sib npaug los ntawm 0.004 …

Kab thib ob muaj qhov sib npaug uas nyeem los ntawm 100 txhawm rau txav tus lej zauv. Qhov ntawd ua rau peb kub. Neat!

Kauj Ruam 8: Kuaj thiab Txheeb Xyuas

Kuaj thiab Kuaj
Kuaj thiab Kuaj

Txhua yam mus rau txoj kev npaj, koj yuav tsum muaj lub voj voog ua haujlwm. Kuaj los ntawm kev sim simulation thiab siv lub ntsuas saib. Yog tias koj muaj qhov tsis raug, kos, txheeb xyuas dua thiab co koj lub nrig.

Koj puas tau ua? Qhia tawm thiab qhia peb koj zaj dab neeg!

Nov yog qhov kev sib tw zaum kawg rau koj yog li koj tuaj yeem ua si/sim qhov kev tsim zaum kawg. Tsaug rau ua kom tiav kev qhia!

Pom zoo: