Cov txheej txheem:

Raspberry Pi - TMP007 Infrared Thermopile Sensor Java Qhia: 4 Kauj Ruam
Raspberry Pi - TMP007 Infrared Thermopile Sensor Java Qhia: 4 Kauj Ruam

Video: Raspberry Pi - TMP007 Infrared Thermopile Sensor Java Qhia: 4 Kauj Ruam

Video: Raspberry Pi - TMP007 Infrared Thermopile Sensor Java Qhia: 4 Kauj Ruam
Video: Raspberry Pi TMP007 Infrared Thermopile Sensor Java Tutorial 2024, Kaum ib hlis
Anonim
Image
Image

TMP007 yog lub ntsuas hluav taws xob infrared thermopile uas ntsuas qhov ntsuas kub ntawm ib yam khoom yam tsis muaj kev sib cuag nrog nws. Lub zog hluav taws xob hluav taws xob tso tawm los ntawm cov khoom hauv thaj chaw sensor tau nqus los ntawm cov thermopile ua ke hauv lub ntsuas. Qhov ntsuas hluav taws xob thermopile yog digitized thiab pub raws li kev nkag mus rau lub cav ua lej. Lub tshuab ua lej suav nrog no suav qhov ntsuas kub. Nov yog nws qhov kev ua haujlwm pom nrog Raspberry Pi siv java code.

Kauj Ruam 1: Yam Koj Xav Tau..

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

1. Raspberry Pi

2. TSM007

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 TMP007 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 lej java rau TMP007 tuaj yeem rub tawm los ntawm peb qhov chaw cia khoom github- Dcube Store Community

Nov yog qhov txuas rau tib yam:

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

pi4j.com/install.html

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 ua haujlwm.

TSI 007

// Cov cai no tau tsim los ua haujlwm nrog TMP007_I2CS I2C Mini Module

ntshuam com.pi4j.io.i2c. I2CBus;

ntshuam com.pi4j.io.i2c. I2CDevice;

ntshuam com.pi4j.io.i2c. I2CFactory;

ntshuam java.io. IOException;

pej xeem hauv chav kawm TMP007

{

pej xeem zoo li qub tsis muaj dab tsi tseem ceeb (Txoj hlua args ) cuam tshuam zam

{

// Tsim I2CBus

I2CBus tsheb npav = I2CFactory.getInstance (I2CBus. BUS_1);

// Tau txais I2C ntaus ntawv, TMP007 I2C chaw nyob yog 0x41 (64)

I2CDevice ntaus ntawv = bus.getDevice (0x41);

// Xaiv cov npe sau npe

// Kev hloov pauv tas li, hom sib piv

byte teeb tsa = {0x15, 0x40};

ntaus ntawv.write (0x02, teeb tsa, 0, 2);

// Nyeem 2 bytes ntawm cov ntaub ntawv los ntawm chaw nyob 0x03 (3)

// temp msb, kub lsb

byte cov ntaub ntawv = tshiab byte [2];

device.read (0x03, cov ntaub ntawv, 0, 2);

// Hloov cov ntaub ntawv mus rau 14-ntsis

int temp = (((cov ntaub ntawv [0] & 0xFF) * 256 + (data [1] & 0xFC)) / 4);

yog (temp> 8191)

{

temp -= 16384;

}

ob cTemp = temp * 0.03125;

ob fTemp = cTemp * 1.8 + 32;

// Cov ntaub ntawv tso tawm rau lub vijtsam

System.out.printf ("Kub hauv Celsius: %.2f C %n", cTemp);

System.out.printf ("Kub hauv Fahrenheit: %.2f C %n", fTemp);

}

}

Kauj Ruam 4: Cov ntawv thov:

TMP007 pom nws daim ntawv thov hauv cov kab ke uas yuav tsum tsis ntsuas qhov ntsuas kub. Lawv tau ua haujlwm hauv lub khoos phis tawj thiab ntsiav tshuaj, roj teeb thiab lwm yam. Nws qhov kev ua tau zoo dua hauv kev ntsuas qhov ntsuas kub yam tsis tau ntsib nrog cov khoom tiag muab nws ib qho ntxiv rau nws cov ntawv thov ntau yam.

Pom zoo: