Cov txheej txheem:

Vaum thiab Qhov Ntsuas Kub Siv Raspberry Pi Nrog SHT25 hauv Python: 6 Cov Kauj Ruam
Vaum thiab Qhov Ntsuas Kub Siv Raspberry Pi Nrog SHT25 hauv Python: 6 Cov Kauj Ruam

Video: Vaum thiab Qhov Ntsuas Kub Siv Raspberry Pi Nrog SHT25 hauv Python: 6 Cov Kauj Ruam

Video: Vaum thiab Qhov Ntsuas Kub Siv Raspberry Pi Nrog SHT25 hauv Python: 6 Cov Kauj Ruam
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Hlis ntuj nqeg
Anonim
Image
Image
Cov Khoom Siv Tseem Ceeb Peb Xav Tau
Cov Khoom Siv Tseem Ceeb Peb Xav Tau

Ua tus neeg mob siab rau Raspberry Pi, peb xav txog qee qhov kev sim zoo tshaj plaws nrog nws.

Hauv qhov phiaj xwm no, peb yuav ua Tus Txheeb Xyuas Qhov Kub thiab Kub uas ntsuas tus txheeb ze Vaum thiab Kub uas siv Raspberry Pi thiab SHT25, Cov Vaum thiab Kub Kub. Yog li cia saib ntawm txoj kev taug no txhawm rau tsim Homemade Humidity thiab Temperature Observer kom ua tiav ib puag ncig zoo tshaj plaws hauv tsev. Tus Ntsuas thiab Cov Ntsuas Kub yog qhov haujlwm zoo nkauj tsim los. Yam koj yuav tsum ua yog khaws cov khoom sib dhos, sib sau ua ke thiab ua raws cov lus qhia. Tom qab ntawd tsis muaj sijhawm koj tuaj yeem txaus siab rau nws ua tus tswv ntawm teeb tsa no. Tuaj, Cheer Up, Cia Peb Pib.

Kauj Ruam 1: Cov Khoom Siv Tseem Ceeb Peb Xav Tau

Cov Khoom Siv Tseem Ceeb Peb Xav Tau
Cov Khoom Siv Tseem Ceeb Peb Xav Tau
Cov Khoom Siv Tseem Ceeb Peb Xav Tau
Cov Khoom Siv Tseem Ceeb Peb Xav Tau

Cov teeb meem tau tsawg dua rau peb vim peb muaj ntau yam khoom dag nyob ib puag ncig los ua haujlwm los ntawm. Txawm li cas los xij, peb paub nws nyuaj npaum li cas rau lwm tus los sau qhov raug hauv lub sijhawm los ntawm qhov chaw raug rau tus nqi ntawm ib npib. Yog li peb yuav pab koj hauv txhua qhov chaw. Nyeem cov hauv qab no kom tau txais cov npe ua tiav.

1. Raspberry Pi

Thawj kauj ruam yog tau txais Raspberry Pi board. Raspberry Pi yog tib-board Linux-based computer uas ntau tus neeg nyiam ua haujlwm tau siv hauv lawv cov phiaj xwm. Raspberry Pi yog herculean hauv kev suav lub zog, ua kom muaj kev xav ntawm cov pej xeem txawm tias nws me me. Yog li, nws tau siv nyob rau hauv cov kev hloov pauv kub zoo li Internet ntawm Yam (IoT), Lub Nroog Ntse, Kev Kawm Ntawv Hauv Tsev thiab lwm yam ntaub ntawv ntawm cov khoom siv muaj txiaj ntsig.

2. I2C Shield rau Raspberry Pi

Hauv peb qhov kev xav, tsuas yog ib qho Raspberry Pi 2 thiab Pi 3 tsis muaj qhov tseeb yog I portC chaw nres nkoj. Tsis txhawj xeeb. INPI2 (I2C adapter) muab Raspberry Pi 2/3 ib qho I²C chaw nres nkoj rau siv nrog ntau I2C khoom siv. Nws muaj nyob ntawm Dcube Store.

3. SHT25 Vaum thiab Kub Sensor

SHT25 qhov tseeb cov av noo thiab ntsuas qhov ntsuas ntsuas ntsuas, ntsuas qhov ntsuas qhov ntsuas hauv digital, I formatC hom. Peb tau yuav qhov ntsuas no los ntawm Dcube Store.

4. I2C Txuas Txuas Cable

Peb siv I²C kev txuas hluav taws xob muaj nyob ntawm Dcube Store.

5. Micro USB cable

Qhov nyuaj tshaj plaws, tab sis nruj tshaj plaws ntawm kev xav tau lub zog yog Raspberry Pi! Txoj hauv kev yooj yim tshaj plaws rau lub zog Raspberry Pi yog los ntawm Micro USB cable.

6 Ethernet (LAN) Cable/ USB WiFi Dongle

Internet tau dhau los ua lub xwmfab hauv nroog rau tag kis lub ntiaj teb. Tau txais koj li Raspberry Pi txuas nrog Ethernet (LAN) cable thiab ntsaws nws rau hauv koj lub network router. Ib qho ntxiv, saib rau WiFi adapter thiab siv ib qho ntawm USB chaw nres nkoj txhawm rau nkag mus rau lub wireless network. Nws yog qhov kev xaiv ntse, yooj yim, me me thiab pheej yig!

7. HDMI Cable/Kev Nkag Mus Rau Tej Chaw

Nrog HDMI cable ntawm lub nkoj, koj tuaj yeem txuas nws mus rau TV digital lossis rau Monitor. Xav txuag nyiaj! Raspberry Pi tuaj yeem nkag mus tau yooj yim siv txoj hauv kev sib txawv xws li-SSH thiab Kev Nkag Mus Hauv Is Taws Nem. Koj tuaj yeem siv PuTTY qhib qhov software.

Nyiaj feem ntau raug nqi ntau dhau

Kauj Ruam 2: Ua Kev Kho Vajtse Txuas

Ua Kev Sib Txuas Kho Vajtse
Ua Kev Sib Txuas Kho Vajtse
Ua Kev Sib Txuas Kho Vajtse
Ua Kev Sib Txuas Kho Vajtse

Feem ntau, Circuit yog ncaj ncaj rau pem hauv ntej. Ua lub Circuit Court raws li qhov schematic qhia. Ua raws li cov duab saum toj no, kev teeb tsa yog qhov yooj yim, thiab koj yuav tsum tsis muaj teeb meem.

Hauv peb qhov kev xav, peb tau dhau los ntawm cov khoom siv hluav taws xob yooj yim tsuas yog kho dua lub cim xeeb rau kho vajtse thiab software. Peb xav kos cov txheej txheem hluav taws xob yooj yim rau txoj haujlwm no. Hauv hluav taws xob, kev kos duab zoo li lub hauv paus. Kev tsim hluav taws xob xav tau lub hauv paus ruaj khov tsim los ua kom kawg. Thaum koj muaj koj cov lej hluav taws xob rau yam koj xav tsim, qhov seem yog txhua yam tsuas yog ua raws qhov tsim.

Raspberry Pi thiab I2C Shield Bonding

Coj Raspberry Pi thiab tso I²C Shield rau nws. Nias lub Shield maj mam mus rau GPIO tus pin. Thaum koj paub tias koj tab tom ua dab tsi, nws yog ib qho khoom qab zib (saib daim duab).

Sensor thiab Raspberry Pi Bonding

Coj lub sensor thiab Txuas I²C cable nrog nws. Nco ntsoov tias I²C Cov Zis Ib Leeg txuas rau I²C Cov Tswv Yim. Ib yam yuav tsum tau ua raws los ntawm Raspberry Pi nrog I²C daim ntaub thaiv tau hla nws. Ua cov I shieldC daim ntaub thaiv thiab cable yog qhov yooj yim ntsaws thiab ua lwm txoj hauv kev rau feem ntau tsis meej pem thiab yuam kev nws ncaj ncaj txoj hauv kev. Yog tsis muaj nws koj yuav tsum tau nyeem kab duab thiab pinouts, laug rau lub rooj tsavxwm, thiab yog tias koj xav hloov pauv koj daim ntawv thov los ntawm kev ntxiv lossis hloov tawm cov laug cam koj yuav xav tshem tawm txhua qhov no thiab rov pib dua. Qhov no ua rau teeb meem daws teeb meem tsawg dua (Koj tau hnov txog plug-and-play. Qhov no yog qhov ntsaws, ntsaws thiab ua si. Nws yooj yim heev rau siv, nws tsis txaus ntseeg).

Nco tseg: Cov xaim xim av yuav tsum ib txwm ua raws hauv av (GND) kev sib txuas ntawm cov khoom siv ntawm ib lub cuab yeej thiab cov tswv yim ntawm lwm lub cuab yeej

Networking, USB, thiab Wireless yog qhov tseem ceeb

Ib qho ntawm thawj yam uas koj yuav xav ua yog kom tau txais koj li Raspberry Pi txuas nrog rau Internet. Koj muaj ob txoj kev xaiv: txuas siv Ethernet (LAN) cable lossis lwm txoj hauv kev tab sis txoj hauv kev zoo los siv WiFi adapter.

Kev ua kom muaj zog ntawm Circuit Court

Txuas lub Micro USB cable rau hauv lub hwj chim nkaus ntawm Raspberry Pi. Teeb nws thiab voila, peb zoo mus!

Kev Sib Txuas rau Screen

Peb tuaj yeem muaj HDMI cable txuas nrog tus saib/TV lossis peb tuaj yeem peb muaj tswv yim me ntsis los ua lub taub hau Pi uas yog tus nqi siv tau zoo siv cov kev nkag mus deb xws li-SSH/PuTTY. Remember, tsev kawm qib siab yog tib lub sijhawm ua neeg txom nyem thiab qaug cawv yog qhov siv tau.

Kauj Ruam 3: Python Programming Raspberry Pi

Python code rau Raspberry Pi thiab SHT25 Sensor yog nyob hauv peb Github chaw cia khoom.

Ua ntej mus rau qhov haujlwm, xyuas kom tseeb tias koj nyeem cov lus qhia muab rau hauv Readme cov ntaub ntawv thiab teeb tsa koj li Raspberry Pi kom haum. Moisture hais txog qhov muaj cov kua, tshwj xeeb yog dej, feem ntau hauv kab ntawv. Cov dej me me tuaj yeem pom, piv txwv li, hauv huab cua (av noo), hauv zaub mov, thiab hauv ntau yam khoom lag luam.

Hauv qab no yog tus nab npawb nab npawb. Koj tuaj yeem clone thiab kho cov cai hauv txhua txoj kev uas koj nyiam.

# Faib nrog daim ntawv tso cai yuav dawb.# Siv nws txhua txoj hauv kev koj xav tau, muaj txiaj ntsig lossis pub dawb, muab nws haum rau hauv daim ntawv tso cai ntawm nws cov haujlwm ua haujlwm. # SHT25 # Txoj cai no yog tsim los ua haujlwm nrog SHT25_I2CS I2C Mini Module muaj los ntawm ControlEverything.com. #

ntshuam smbus

lub sij hawm ntshuam

# Tau I2C npav

npav = smbus. SMBus (1)

# SHT25 chaw nyob, 0x40 (64)

# Xa qhov ntsuas ntsuas kub # 0xF3 (243) TSIS MUAJ HOLD tus tswv tsheb npav.write_byte (0x40, 0xF3)

sijhawm.s pw (0.5)

# SHT25 chaw nyob, 0x40 (64)

# Nyeem cov ntaub ntawv rov qab, 2 bytes # Temp MSB, Temp LSB data0 = bus.read_byte (0x40) data1 = bus.read_byte (0x40)

# Hloov cov ntaub ntawv

temp = data0 * 256 + data1 cTemp = -46.85 + ((temp * 175.72) / 65536.0) fTemp = cTemp * 1.8 + 32

# SHT25 chaw nyob, 0x40 (64)

# Xa cov lus ntsuas ntsuas av noo # 0xF5 (245) TSIS MUAJ HOLD tus tswv bus.write_byte (0x40, 0xF5)

sijhawm.s pw (0.5)

# SHT25 chaw nyob, 0x40 (64)

# Nyeem cov ntaub ntawv rov qab, 2 bytes # Humidity MSB, Humidity LSB data0 = bus.read_byte (0x40) data1 = bus.read_byte (0x40)

# Hloov cov ntaub ntawv

av noo = data0 * 256 + data1 av noo = -6 + ((av noo * 125.0) / 65536.0)

# Cov ntaub ntawv tso tawm rau lub vijtsam

luam "Cov txheeb ze vaum yog: %.2f %%" %av noo luam tawm "Kub hauv Celsius yog: %.2f C" %cTemp luam "Kub hauv Fahrenheit yog: %.2f F" %fTemp

Kauj Ruam 4: Kev Ua Haujlwm

Hom Kev Ua Tau
Hom Kev Ua Tau

Tam sim no, rub tawm (lossis git rub) cov cai thiab qhib nws hauv Raspberry Pi.

Khiav cov lus txib kom Sib Sau thiab Tshaj Tawm cov cai ntawm lub davhlau ya nyob twg thiab pom cov khoom tso tawm ntawm Zaub. Tom qab ob peb lub sijhawm, nws yuav tso tawm txhua qhov ntsuas. Tom qab ua kom ntseeg tau tias txhua yam ua haujlwm zoo ib yam li pancake, koj tuaj yeem tsim kho thiab txav mus ntxiv nrog txoj haujlwm mus rau qhov nthuav dua.

Kauj Ruam 5: Cov ntawv thov thiab Nta

Tus tshiab SHT25 cov av noo thiab qhov ntsuas kub yuav siv lub tshuab thev naus laus zis mus rau qib tshiab nrog kev ua haujlwm tsis sib xws, ntau yam sib txawv, thiab cov yam ntxwv tshiab. Haum rau ntau yam kev lag luam, xws li Cov Khoom Siv Hauv Tsev, Kev Kho Mob, IoT, HVAC, lossis Kev Lag Luam. Tsis tas li, muaj nyob hauv qib tsheb.

Rau xws li Ua siab ntev thiab mus rau Sauna!

Hlub Sauna! Saunas tau ntxim nyiam ntawm ntau tus. Thaj chaw uas nyob ib puag ncig - feem ntau yog ntoo, ua kom sov ua kom sov lub cev ntawm tus neeg sab hauv. Nws tau paub tias lub cev cua sov muaj txiaj ntsig zoo. Hauv qhov phiaj xwm no, peb yuav ua Tus Sauna Jacuzzi Tus Neeg Soj Ntsuam uas ntsuas tus txheeb ze Vaum thiab Kub uas siv Raspberry Pi thiab SHT25. Koj tuaj yeem tsim lub Tsev Sauna Jacuzzi Tus Neeg Soj Ntsuam kom ua tiav ib puag ncig zoo tshaj plaws rau kev da dej Sauna txhua lub sijhawm.

Kauj Ruam 6: Xaus

Vam tias txoj haujlwm no txhawb nqa kev sim ntxiv. Hauv Raspberry Pi lub ntiaj teb, koj tuaj yeem xav txog qhov tsis muaj qhov xaus ntawm Raspberry Pi, nws lub zog tsis siv zog, nws siv thiab yuav ua li cas koj tuaj yeem kho koj cov kev nyiam siv hluav taws xob, kev tsim qauv, tsim qauv, thiab lwm yam. Cov tswv yim muaj ntau heev. Qee zaum qhov txiaj ntsig yuav ua rau koj qis qis dua tab sis tsis tso tseg. Tej zaum yuav muaj lwm txoj hauv kev ib puag ncig lossis lub tswv yim tshiab tuaj yeem hloov pauv los ntawm qhov ua tsis tiav (Txawm tias yuav tsim yeej). Koj tuaj yeem tawm tsam koj tus kheej los ntawm kev tsim qhov tshiab thiab ua kom tiav txhua qhov ntawm nws. Txhawm rau kom yooj yim rau koj, peb muaj cov vis dis aus nthuav qhia hauv Youtube uas tuaj yeem qiv tes rau koj qhov kev tshawb fawb thiab yog tias koj xav tau kev piav qhia ntxiv ntawm txhua qhov ntawm txoj haujlwm.

Pom zoo: