Cov txheej txheem:
- Kauj Ruam 1: Yuav Tsum Kho Vajtse:
- Kauj ruam 2: Khoos phis tawj sib txuas:
- Kauj Ruam 3: Java Code rau Kev Ntsuas Kub:
- Kauj Ruam 4: Cov ntawv thov:
Video: Kev Ntsuas Kub Siv TMP112 thiab Raspberry Pi: 4 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:26
TMP112 High-Accuracy, Low-Power, Digital Kub Sensor I2C MINI module. TMP112 yog qhov zoo tshaj rau kev ntsuas kub ntxiv. Cov cuab yeej no muab qhov tseeb ntawm ± 0.5 ° C yam tsis tas yuav ntsuas qhov ntsuas lossis sab nrauv tiv thaiv teeb liab.
Hauv qhov kev qhia no kev cuam tshuam ntawm TMP112 sensor module nrog raspberry pi tau pom thiab nws cov phiaj xwm siv Java lus kuj tseem tau piav qhia. Txhawm rau nyeem qhov ntsuas kub, 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:
Cov ntaub ntawv uas peb xav tau kom ua tiav peb lub hom phiaj suav nrog cov khoom siv hauv qab no:
1. TMP112
2. Raspberry Pi
3. I2C Cable
4. I2C Shield rau raspberry pi
Kauj ruam 2: Khoos phis tawj sib txuas:
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:
TMP112 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: Java Code rau Kev Ntsuas Kub:
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 zoo ntawm pawg no, peb tab tom qhia ntawm no nws tau ua haujlwm hauv Java. Tus lej java rau TMP112 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 lub pi4j lub tsev qiv ntawv hauv java, vim tias lub tsev qiv ntawv no txhawb nqa cov haujlwm siv hauv txoj cai. Yog li, txhawm rau rub lub tsev qiv ntawv koj tuaj yeem mus ntsib qhov txuas hauv qab no:
pi4j.com/install.html
Koj tuaj yeem luam qhov ua haujlwm java code rau lub ntsuas no los ntawm no kuj:
ntshuam com.pi4j.io.i2c. I2CBus;
ntshuam com.pi4j.io.i2c. I2CDevice;
ntshuam com.pi4j.io.i2c. I2CFactory;
ntshuam java.io. IOException;
pej xeem chav kawm TMP112
{
pej xeem zoo li qub tsis muaj dab tsi tseem ceeb (Txoj hlua args ) cuam tshuam zam
{
// Tsim I2C npav
I2CBus tsheb npav = I2CFactory.getInstance (I2CBus. BUS_1);
// Tau txais I2C ntaus ntawv, TMP112 I2C chaw nyob yog 0x48 (72)
I2CDevice ntaus ntawv = bus.getDevice (0x48);
byte teeb tsa = tshiab byte [2];
// Kev hloov pauv mus tas li, 12-ntsis kev daws teeb meem, Kev ua tsis raug yog 1
config [0] = (byte) 0x60;
// Polarity tsawg, Thermostat hauv Comparator hom, Disables Shutdown mode
config [1] = (byte) 0xA0;
// Sau teeb tsa rau npe 0x01 (1)
ntaus ntawv.write (0x01, teeb tsa, 0, 2);
Xov.sleep (500);
// Nyeem 2 Bytes ntawm cov ntaub ntawv los ntawm chaw nyob 0x00 (0), msb ua ntej
byte cov ntaub ntawv = tshiab byte [2];
device.read (0x00, cov ntaub ntawv, 0, 2);
// Hloov cov ntaub ntawv
int temp = (((cov ntaub ntawv [0] & 0xFF) * 256) + (data [1] & 0xFF))/16;
yog (temp> 2047)
{
temp -= 4096;
}
ob cTemp = temp * 0.0625;
ob fTemp = cTemp * 1.8 + 32;
// Tso tawm rau lub vijtsam
System.out.printf ("Kub hauv Celsius yog: %.2f C %n", cTemp);
System.out.printf ("Kub hauv Fahrenheit yog: %.2f F %n", fTemp);
}
}
Lub tsev qiv ntawv uas txhawb nqa i2c kev sib txuas lus ntawm lub sensor thiab pawg thawj coj yog pi4j, nws ntau pob khoom I2CBus, I2CDevice thiab I2CFactory pab tsim kom muaj kev sib txuas.
ntshuam com.pi4j.io.i2c. I2CBus; ntshuam com.pi4j.io.i2c. I2CDevice; ntshuam com.pi4j.io.i2c. I2CFactory; ntshuam java.io. IOException;
sau () thiab nyeem () lub luag haujlwm tau siv los sau qee cov lus txib tshwj xeeb rau lub ntsuas cua kom nws ua haujlwm hauv ib qho tshwj xeeb thiab nyeem cov ntawv tso tawm feem.
Qhov tso tawm ntawm lub sensor kuj tseem muaj nyob hauv daim duab saum toj no.
Kauj Ruam 4: Cov ntawv thov:
Ntau daim ntawv thov suav nrog TMP112 lub zog qis, qhov tseeb cov ntsuas ntsuas kub suav nrog Lub Hwj Huam Saib Xyuas Kub Kub, Khoos phis tawj Ib puag ncig tiv thaiv cua sov, Kev tswj roj teeb nrog rau lub tshuab ua haujlwm.
Pom zoo:
Siv Smartphone Raws Li Tsis Siv Tus Kheej Ntsuas Kub / Tus Ntsuas Ntsuas Kub: 8 Kauj Ruam (nrog Duab)
Siv Smartphone Raws Li Tsis Siv Tus Kws Ntsuas Kub / Tus Ntsuas Kub Portable: Ntsuas lub cev kub nrog qhov tsis sib cuag / tsis sib cuag zoo li rab phom thermo. Kuv tsim txoj haujlwm no vim tias Thermo Gun tam sim no kim heev, yog li kuv yuav tsum tau txais lwm txoj hauv kev los ua DIY. Thiab lub hom phiaj yog ua nrog cov peev txheej qis .SuppliesMLX90614Ardu
Kev Ntsuas thiab Kev Ntsuas Kub Siv HIH6130 thiab Arduino Nano: 4 Cov Kauj Ruam
Kev Ntsuas thiab Kev Ntsuas Kub Siv HIH6130 thiab Arduino Nano: 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
Kev Ntsuas thiab Kev Ntsuas Kub Siv HTS221 thiab Arduino Nano: 4 Cov Kauj Ruam
Kev Ntsuas thiab Kev Ntsuas Kub Siv HTS221 thiab Arduino Nano: HTS221 yog lub ntsuas hluav taws xob me me uas muaj peev xwm ntsuas tau rau qhov txheeb ze thiab qhov kub thiab txias. Nws suav nrog lub hauv paus ntsiab lus thiab cov teeb liab sib xyaw daim ntawv thov tshwj xeeb kev sib txuas (ASIC) los muab cov ntaub ntawv ntsuas los ntawm cov lej
Kev Ntsuas thiab Kev Ntsuas Kub Siv HTS221 thiab Raspberry Pi: 4 Cov Kauj Ruam
Kev Ntsuas thiab Kev Ntsuas Kub Siv HTS221 thiab Raspberry Pi: HTS221 yog lub ntsuas hluav taws xob me me uas muaj peev xwm ntsuas tau rau qhov txheeb ze thiab qhov kub thiab txias. Nws suav nrog lub hauv paus ntsiab lus thiab cov teeb liab sib xyaw daim ntawv thov tshwj xeeb kev sib txuas (ASIC) los muab cov ntaub ntawv ntsuas los ntawm cov lej
Kev Ntsuas thiab Kev Ntsuas Kub Siv HIH6130 thiab Raspberry Pi: 4 Kauj Ruam
Kev Ntsuas Cov Ntsuas thiab Kub Siv HIH6130 thiab Raspberry Pi: 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