Cov txheej txheem:

Kev Ntsuas Kub thiab Vaum Siv HDC1000 thiab Raspberry Pi: 4 Kauj Ruam
Kev Ntsuas Kub thiab Vaum Siv HDC1000 thiab Raspberry Pi: 4 Kauj Ruam

Video: Kev Ntsuas Kub thiab Vaum Siv HDC1000 thiab Raspberry Pi: 4 Kauj Ruam

Video: Kev Ntsuas Kub thiab Vaum Siv HDC1000 thiab Raspberry Pi: 4 Kauj Ruam
Video: Lub Zog Nruab Nrog (Hmong Dubbed) 2024, Kaum ib hlis
Anonim
Image
Image

HDC1000 yog lub ntsuas cua digital nrog cov ntsuas kub sib xyaw uas muab qhov ntsuas tau zoo heev ntawm lub zog qis heev. Cov cuab yeej ntsuas cov av noo raws li lub peev xwm tshiab sensor. Cov av noo thiab qhov ntsuas kub tau tsim los ntawm lub Hoobkas. Nws ua haujlwm tsis pub dhau -40 ° C txog +125 ° C kub ntau.

Hauv qhov kev qhia no kev cuam tshuam ntawm HDC1000 sensor module nrog raspberry pi tau pom thiab nws cov phiaj xwm siv cov lus nab nab kuj tau piav qhia. Txhawm rau nyeem qhov ntsuas kub thiab av noo, peb tau siv raspberry pi nrog I2C adapter Qhov no I2C adapter ua rau kev txuas mus rau lub ntsuas qhov ntsuas tau yooj yim thiab ntseeg tau ntau dua.

Kauj Ruam 1: Yuav Tsum Kho Vajtse:

Yuav tsum tau kho vajtse
Yuav tsum tau kho vajtse
Yuav tsum tau kho vajtse
Yuav tsum tau kho vajtse
Yuav tsum tau kho vajtse
Yuav tsum tau kho vajtse

Cov ntaub ntawv uas peb xav tau kom ua tiav peb lub hom phiaj suav nrog cov khoom siv hauv qab no:

1. HDC1000

2. Raspberry Pi

3. I2C Cable

4. I2C Shield rau raspberry pi

5. Ethernet Cable

Kauj ruam 2: Khoos phis tawj sib txuas:

Kho vajtse Hookup
Kho vajtse Hookup
Kho vajtse Hookup
Kho vajtse Hookup

Tshooj khoos phis tawj sib txuas ntu piav qhia qhov txuas txuas uas xav tau ntawm lub ntsuas cua thiab raspberry pi. Ua kom muaj kev sib txuas raug yog qhov tseem ceeb xav tau thaum ua haujlwm ntawm ib qho system rau qhov xav tau cov zis. Yog li, qhov xav tau kev sib txuas yog raws li hauv qab no:

HDC1000 yuav ua haujlwm dhau I2C. Nov yog qhov piv txwv kab hluav taws xob daim duab, qhia txog yuav ua li cas xaim txhua lub interface ntawm lub sensor.

Tawm-ntawm-lub thawv, lub rooj tsavxwm tau teeb tsa rau I2C interface, zoo li peb pom zoo siv qhov kev sib txuas no yog tias koj tsis ntseeg lwm yam.

Txhua yam koj xav tau yog plaub lub xov hlau! Tsuas yog plaub qhov kev sib txuas xav tau Vcc, Gnd, SCL thiab SDA tus pin thiab cov no txuas nrog kev pab ntawm I2C cable.

Cov kev sib txuas no tau qhia hauv cov duab saum toj no.

Kauj Ruam 3: Txoj Cai ntsuas Kub thiab Vaum:

Txoj Cai ntsuas Kub thiab Vaum
Txoj Cai ntsuas Kub thiab Vaum

Qhov zoo ntawm kev siv raspberry pi yog, uas muab rau koj hloov pauv ntawm cov lus programming uas koj xav tau los teeb tsa lub rooj tsav xwm txhawm rau txhawm rau cuam tshuam lub sensor nrog nws. Kev siv cov txiaj ntsig ntawm pawg thawj coj no, peb tab tom qhia ntawm no nws tau ua haujlwm nyob hauv nab hab sej. Tus nab npawb nab npawb rau HDC1000 tuaj yeem rub tawm los ntawm peb cov zej zog GitHub uas yog Dcube Store.

Ntxiv rau qhov yooj yim ntawm cov neeg siv, peb tab tom piav qhia cov cai ntawm no thiab:

Raws li thawj kauj ruam ntawm kev sau npe, koj yuav tsum rub tawm SMBus lub tsev qiv ntawv thaum muaj nab nab, vim tias lub tsev qiv ntawv no txhawb nqa cov haujlwm uas siv hauv txoj cai. Yog li, txhawm rau rub lub tsev qiv ntawv koj tuaj yeem mus ntsib qhov txuas hauv qab no:

pypi.python.org/pypi/smbus-cffi/0.5.1

Koj tuaj yeem luam tus nab npawb nab npawb ua haujlwm rau lub ntsuas no los ntawm no kuj:

ntshuam smbus

lub sij hawm ntshuam

# Tau I2C npav

npav = smbus. SMBus (1)

# HDC1000 chaw nyob, 0x40 (64)

# Xaiv kev teeb tsa sau npe, 0x02 (02)

# 0x30 (48) Kub, Ua kom av noo, Resolultion = 14-ntsis, Rhaub rau

bus.write_byte_data (0x40, 0x02, 0x30)

# HDC1000 chaw nyob, 0x40 (64)

# Xa qhov ntsuas ntsuas ntsuas, 0x00 (00)

npav.write_byte (0x40, 0x00)

sijhawm.s pw (0.5)

# HDC1000 chaw nyob, 0x40 (64)

# Nyeem cov ntaub ntawv rov qab, 2 bytes

# temp MSB, temp LSB

data0 = npav.read_byte (0x40)

data1 = npav.read_byte (0x40)

# Hloov cov ntaub ntawv

temp = (data0 * 256) + data1

cTemp = (temp / 65536.0) * 165.0 - 40

fTemp = cTemp * 1.8 + 32

# HDC1000 chaw nyob, 0x40 (64)

# Xa cov lus ntsuas ntsuas huab cua, 0x01 (01)

bus.write_byte (0x40, 0x01)

sijhawm.s pw (0.5)

# HDC1000 chaw nyob, 0x40 (64)

# Nyeem cov ntaub ntawv rov qab, 2 bytes

# av noo MSB, av noo LSB

data0 = npav.read_byte (0x40)

data1 = npav.read_byte (0x40)

# Hloov cov ntaub ntawv

av noo = (data0 * 256) + data1

av noo = (av noo / 65536.0) * 100.0

# Cov ntaub ntawv tso tawm rau lub vijtsam

luam tawm "txheeb ze vaum: %.2f %%" %av noo

luam tawm "Kub hauv Celsius: %.2f C" %cTemp

luam tawm "Kub hauv Fahrenheit: %.2f F" %fTemp

Ib feem ntawm cov cai hais hauv qab no suav nrog cov tsev qiv ntawv xav tau los ua kom raug ntawm cov nab npawb nab npawb.

ntshuam smbus

lub sij hawm ntshuam

Txoj cai tuaj yeem ua tiav los ntawm kev ntaus cov lus hais hauv qab no hauv kab hais kom ua.

$> nab nab HDC1000.py gt; nab hab sej HDC1000.py

Cov zis ntawm lub ntsuas kuj tseem muaj nyob hauv daim duab saum toj no rau kev siv ntawm tus neeg siv.

Kauj Ruam 4: Cov ntawv thov:

Cov ntawv thov
Cov ntawv thov

HDC1000 tuaj yeem ua haujlwm ua cua sov, tso cua thiab cua txias (HVAC), Ntse Thermostats thiab Chav Saib Xyuas. Qhov ntsuas no tseem pom nws daim ntawv thov hauv Cov Tshuab Luam Ntawv, Cov Ntsuas Hluav Taws Xob, Cov Khoom Siv Kho Mob, Kev Thauj Khoom Nkoj nrog rau Automotive Windshield Defog.

Pom zoo: