Cov txheej txheem:

Ua Cov Ntaub Ntawv Logger Nrog Raspberry Pi: 3 Cov Kauj Ruam (nrog Duab)
Ua Cov Ntaub Ntawv Logger Nrog Raspberry Pi: 3 Cov Kauj Ruam (nrog Duab)

Video: Ua Cov Ntaub Ntawv Logger Nrog Raspberry Pi: 3 Cov Kauj Ruam (nrog Duab)

Video: Ua Cov Ntaub Ntawv Logger Nrog Raspberry Pi: 3 Cov Kauj Ruam (nrog Duab)
Video: Musicians talk about Buckethead 2024, Kaum ib hlis
Anonim
Ua Cov Ntaub Ntawv Logger Nrog Raspberry Pi
Ua Cov Ntaub Ntawv Logger Nrog Raspberry Pi

Tus neeg siv cov ntaub ntawv yooj yim no ntsuas ntsuas lub teeb ib txwm nrog qhov sib piv LDR (Photoresistor) thiab khaws cia hauv cov ntawv sau ntawm koj li Raspberry Pi. Cov ntaub ntawv logger no yuav ntsuas thiab sau lub teeb theem txhua 60 vib nas this, tso cai rau koj los saib xyuas qhov ci ci hloov pauv mus li cas.

Yog tias peb xav siv cov ntsuas sib piv nrog Raspberry Pi, peb yuav tsum muaj peev xwm ntsuas qhov tsis kam ntawm lub ntsuas. Tsis zoo li Arduino, Raspberry Pi's GPIO pins tsis tuaj yeem ntsuas qhov tsis kam thiab tuaj yeem nkag siab tau yog tias qhov hluav taws xob muab rau lawv siab dua qee qhov hluav taws xob (kwv yees li 2 volts). Txhawm rau kov yeej qhov teeb meem no, koj tuaj yeem siv Analogue to Digital Converter (ADC), lossis koj tuaj yeem siv tus nqi hluav taws xob pheej yig dua.

Kauj Ruam 1: Yam Koj Yuav Tsum Tau

Koj Yuav Tsum Tau Dab Tsi
Koj Yuav Tsum Tau Dab Tsi
Koj Yuav Tsum Tau Dab Tsi
Koj Yuav Tsum Tau Dab Tsi
Koj Yuav Tsum Tau Dab Tsi
Koj Yuav Tsum Tau Dab Tsi
Koj Yuav Tsum Tau Dab Tsi
Koj Yuav Tsum Tau Dab Tsi

- RaspberryPi nrog Raspbian twb tau teeb tsa. Koj tseem yuav tsum muaj peev xwm nkag tau Pi siv Monitor, Mouse thiab Keyboard lossis los ntawm Remote Desktop. Koj tuaj yeem siv txhua tus qauv ntawm Raspberry Pi. Yog tias koj muaj ib qho ntawm Pi Zero cov qauv, koj yuav xav muab qee lub taub hau txuas rau GPIO chaw nres nkoj.

- Lub Teeb Ntsuas Tus Kheej (Kuj tseem hu ua LDR lossis Photoresistor)

- A 1 uF Ceramic Capacitor

- Ib Lub Cuab Yeej Tsis Txaus Siab Prototyping Breadboard

- Qee tus txiv neej rau poj niam jumper xov hlau

Kauj Ruam 2: Tsim Koj Li Circuit Court

Tsim Koj Li Circuit Court
Tsim Koj Li Circuit Court
Tsim Koj Li Circuit Court
Tsim Koj Li Circuit Court

Ua kom muaj cov kab lus saum toj no ntawm koj daim ntawv qhia zaub mov kom ntseeg tau tias tsis muaj ib feem ntawm cov khoom coj los kov. Lub Teeb Ntsuas Tus Kws Tiv Thaiv thiab Cov Khoom Siv Hluav Taws Xob tsis muaj qhov sib txawv uas txhais tau tias qhov tsis zoo thiab qhov zoo tam sim no tuaj yeem txuas nrog ob qho tib si. Yog li koj tsis tas yuav txhawj xeeb txog txoj kev uas cov khoom siv no tau txuas nrog hauv koj lub Circuit.

Thaum koj tau txheeb xyuas koj lub Circuit Court, ua tib zoo txuas lub jumper cables rau koj Raspberry Pi's GPIO pins los ntawm kev ua raws daim duab saum toj no.

Kauj Ruam 3: Tsim Python Tsab Ntawv Nyeem thiab Sau Koj Cov Ntaub Ntawv

Tsim Python Script los nyeem thiab Nkag Mus Rau Koj Cov Ntaub Ntawv
Tsim Python Script los nyeem thiab Nkag Mus Rau Koj Cov Ntaub Ntawv

Qhib IDLE ntawm koj li Raspberry Pi (Ntawv Qhia> Programming> Python 2 (IDLE)) thiab qhib qhov haujlwm tshiab (Cov Ntaub Ntawv> Cov Ntaub Ntawv Tshiab). Tom qab ntawv ntaus cov hauv qab no:

ntshuam RPi. GPIO ua GPIO

ntshuam lub sij hawm ntshuam datetime loginterval = 60 #log luv hauv vib nas this savefilename = "lightlevels.txt" SensorPin = 17 TriggerPin = 27

GPIO.setmode (GPIO. BCM)

cap = 0.000001 #1uf adj = 2.130620985

def ntsuas kev tiv thaiv (mpin, tpin):

GPIO.setup (mpin, GPIO. OUT) GPIO.setup (tpin, GPIO. OUT) GPIO.output (mpin, False) GPIO.output (tpin, False) time.sleep (0.2) GPIO.setup (mpin, GPIO. IN) time.sleep (0.2) GPIO.output (tpin, True) starttime = time.time () endtime = time.time () thaum (GPIO.input (mpin) == GPIO. LOW): endtime = time.time () xa rov qab kawg-pib lub sijhawm def sau ntawv (txt, fn): f = qhib (fn, 'a') f.write (txt+'\ n') f.close () i = 0 t = 0 thaum Tseeb: stime = time.time () rau hauv thaj tsam (1, 11): res = (ntsuas kev ntsuas (SensorPin, TriggerPin)/cap)*adj kuv = kuv+1 t = t+res yog a == 10: t = t/i print (t) writeline (str (datetime.datetime.now ())+","+str (t), savefilename) i = 0 t = 0 thaum lub sij hawm stime+loginterval> time.time (): #tos kom txog thaum teev sijhawm muaj dhau sijhawm.s pw (0.0001)

Txuag koj txoj haujlwm li datalogger.py (Cov Ntaub Ntawv> Txuag Raws Li) hauv koj cov ntawv tais ceev tseg.

Tam sim no qhib Terminal (Ntawv Qhia> Accessories> Terminal) thiab ntaus cov lus txib hauv qab no:

nab hab sej datalogger.py

Tsab ntawv yuav tsim cov ntawv sau npe "lightlevels.txt" thiab hloov kho nws txhua 60 vib nas this. Koj tuaj yeem hloov pauv cov npe no ntawm kab 6. Koj tseem tuaj yeem hloov kho cov ntaub ntawv hloov pauv ntau npaum li cas los ntawm hloov kab 5.

Pom zoo: