Cov txheej txheem:

Raspberry Pi - HIH6130 I2C Vaum & Kub Sensor Python Qhia: 4 Kauj Ruam
Raspberry Pi - HIH6130 I2C Vaum & Kub Sensor Python Qhia: 4 Kauj Ruam

Video: Raspberry Pi - HIH6130 I2C Vaum & Kub Sensor Python Qhia: 4 Kauj Ruam

Video: Raspberry Pi - HIH6130 I2C Vaum & Kub Sensor Python Qhia: 4 Kauj Ruam
Video: Amazing arduino project 2024, Hlis ntuj nqeg
Anonim
Image
Image

HIH6130 yog qhov ntsuas cua thiab ntsuas kub nrog cov zis digital. Cov ntsuas no muab qib raug ntawm ± 4% RH. Nrog kev lag luam-ua kom muaj kev ruaj ntseg mus sij hawm ntev, qhov tseeb kub-them nyiaj digital I2C, Kev lag luam ua rau muaj kev ntseeg siab, Kev siv hluav taws xob zoo thiab Ultra-pob me me qhov loj me thiab xaiv. Nov yog nws qhov ua piv txwv nrog raspberry pi siv tus lej nab npawb.

Kauj Ruam 1: Yam Koj Xav Tau..

Yam Koj Xav Tau.. !!
Yam Koj Xav Tau.. !!

1. Raspberry Pi

2. HIH6130

3. I²C Cable

4. I²C Shield rau Raspberry Pi

5. Ethernet Cable

Kauj Ruam 2: Kev Sib Txuas:

Kev Sib Txuas
Kev Sib Txuas
Kev Sib Txuas
Kev Sib Txuas
Kev Sib Txuas
Kev Sib Txuas
Kev Sib Txuas
Kev Sib Txuas

Siv daim I2C daim thaiv rau raspberry pi thiab maj mam thawb nws hla gpio pins ntawm raspberry pi.

Tom qab ntawd txuas ib qho kawg ntawm I2C cable rau HIH6130 sensor thiab lwm qhov kawg rau I2C daim ntaub thaiv.

Kuj txuas Ethernet cable rau pi lossis koj tuaj yeem siv WiFi module.

Kev sib txuas tau qhia hauv daim duab saum toj no.

Kauj ruam 3: Code:

Txoj Cai
Txoj Cai

Tus nab npawb nab npawb rau HIH6130 tuaj yeem rub tawm los ntawm peb GitHub chaw cia khoom- Dcube Store.

Nov yog qhov txuas rau tib yam:

github.com/DcubeTechVentures/HIH6130

Peb tau siv SMBus lub tsev qiv ntawv rau sej code, cov kauj ruam rau nruab SMBus ntawm raspberry pi tau piav qhia ntawm no:

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

Koj tseem tuaj yeem luam cov cai los ntawm no, nws tau muab raws li hauv qab no:

# Faib nrog daim ntawv tso cai yuav dawb.

# Siv nws txhua txoj hauv kev uas koj xav tau, muaj txiaj ntsig lossis pub dawb, muab nws haum rau hauv daim ntawv tso cai ntawm nws cov haujlwm sib txuam.

# HWM 6130

# Txoj cai no tau tsim los ua haujlwm nrog HIH6130_I2CS I2C Mini Module muaj nyob hauv Dcube Store.

ntshuam smbus

lub sij hawm ntshuam

# Tau I2C npav

npav = smbus. SMBus (1)

# HIH6130 chaw nyob, 0x27 (39)

# Nyeem cov ntaub ntawv rov qab los ntawm 0x00 (00), 4 bytes

# av noo MSB, av noo LSB, huab cua MSB, huab cua LSB

cov ntaub ntawv = bus.read_i2c_block_data (0x27, 0x00, 4)

# Hloov cov ntaub ntawv mus rau 14-ntsis

av noo = ((((data [0] & 0x3F) * 256) + data [1]) * 100.0) / 16383.0

temp = (((cov ntaub ntawv [2] & 0xFF) * 256) + (data [3] & 0xFC)) / 4

cTemp = (temp / 16384.0) * 165.0 - 40.0

fTemp = cTemp * 1.8 + 32

# 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

Kauj Ruam 4: Cov ntawv thov:

HIH6130 tuaj yeem siv los muab cov txheeb ze txheeb ze txheeb xyuas qhov kub thiab txias hauv cov cua txias, nkag siab lub cev, ntsuas cua sov, ua kom cua txias/de-humidifiers, thiab humidistats kom muaj kev nyob nyab xeeb. Nws kuj tseem tuaj yeem ua haujlwm hauv cov tshuab cua, cov chaw huab cua thiab cov khoom sib tham hauv xov tooj.

Pom zoo: