Cov txheej txheem:

Raspberry Pi CPS120 Siab Sensor Java Qhia: 4 Kauj Ruam
Raspberry Pi CPS120 Siab Sensor Java Qhia: 4 Kauj Ruam

Video: Raspberry Pi CPS120 Siab Sensor Java Qhia: 4 Kauj Ruam

Video: Raspberry Pi CPS120 Siab Sensor Java Qhia: 4 Kauj Ruam
Video: Raspberry Pi CPS120 Pressure & Temperature Sensor Java Tutorial 2024, Hlis ntuj nqeg
Anonim
Image
Image

CPS120 yog qhov ua tau zoo thiab tus nqi qis capacitive tsis siab sensor nrog kev them nyiaj tag nrho. Nws siv hluav taws xob tsawg heev thiab suav nrog ib qho me me me me Micro-Electro-Mechanical Sensor (MEMS) rau ntsuas ntsuas. Sigma-delta raws ADC kuj tseem muaj nyob hauv nws kom ua tiav qhov xav tau ntawm cov nyiaj them poob haujlwm. Nov yog qhov ua piv txwv nrog java code siv Raspberry Pi.

Kauj Ruam 1: Yam Koj Xav Tau..

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

1. Raspberry Pi

2. CPS120

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 CPS120 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 CPS120 tuaj yeem rub tawm los ntawm peb qhov chaw cia khoom github- Dcube Store

Nov yog qhov txuas rau tib yam:

github.com/DcubeTechVentures/CPS120/blob/master/Java/CPS120.java

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.

CPS120

// Cov cai no tau tsim los ua haujlwm nrog CPS120_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 chav kawm CPS120

{

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, CPS120 I2C chaw nyob yog 0x28 (40)

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

// Xa cov lus txib pib

device.write (0x28, (byte) 0x80);

Xov.sleep (800);

// Nyeem 2 bytes ntawm cov ntaub ntawv, msb ua ntej

byte cov ntaub ntawv = tshiab byte [2];

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

// Hloov cov ntaub ntawv rau kPa

ob npaug siab = (((cov ntaub ntawv [0] & 0x3F) * 256 + cov ntaub ntawv [1]) * (90 / 16384.00)) + 30;

// Cov ntaub ntawv tso tawm rau lub vijtsam

System.out.printf ("Siab yog: %.2f kPa %n", siab);

}

}

Kauj Ruam 4: Cov ntawv thov:

CPS120 muaj ntau yam kev siv. Nws tuaj yeem ua haujlwm nyob rau hauv nqa tau thiab ntsuas barometers, qhov siab thiab lwm yam Kev ntsuas siab yog qhov ntsuas tseem ceeb los txiav txim siab huab cua thiab txiav txim siab tias lub ntsuas no tuaj yeem teeb tsa ntawm cov chaw huab cua ib yam. Nws tuaj yeem suav nrog hauv cov tshuab huab cua nrog rau lub tshuab nqus tsev.

Pom zoo: