Cov txheej txheem:

Kev Ntsuas Kev Ntsuas Siv HYT939 thiab Particle Photon: 4 Kauj Ruam
Kev Ntsuas Kev Ntsuas Siv HYT939 thiab Particle Photon: 4 Kauj Ruam

Video: Kev Ntsuas Kev Ntsuas Siv HYT939 thiab Particle Photon: 4 Kauj Ruam

Video: Kev Ntsuas Kev Ntsuas Siv HYT939 thiab Particle Photon: 4 Kauj Ruam
Video: Xwm Kab Yog Dab Tsi?: Hmoob Nkag Siab Yuam Kev Tag Lawm 2024, Hlis ntuj nqeg
Anonim
Image
Image

HYT939 yog lub ntsuas hluav taws xob digital uas ua haujlwm ntawm I2C kev sib txuas lus raws tu qauv. Cov av noo yog qhov ntsuas tseem ceeb thaum nws los txog rau kev kho mob thiab chaw kuaj mob, Yog li txhawm rau ua kom tiav cov hom phiaj no peb tau sim cuam tshuam HYT939 nrog raspberry pi. Hauv qhov kev qhia no kev cuam tshuam ntawm HYT939 sensor module nrog particle photon tau piav qhia.

Txhawm rau nyeem qhov ntsuas qhov av noo, peb tau siv cov khoom me me photon nrog I2c adapter. Qhov I2C adapter ua rau kev txuas mus rau qhov ntsuas qhov ntsuas tau yooj yim thiab ntseeg tau ntau dua. Particle photon yog pawg thawj coj uas pab xa thiab tau txais cov ntaub ntawv los ntawm lub vev xaib, uas yog txhawb nqa feem ntau qhov tseem ceeb ntawm Internet Ntawm Yam (IoT).

Kauj Ruam 1: Yuav Tsum Kho Vajtse:

Yuav tsum tau kho vajtse
Yuav tsum tau kho vajtse
Yuav tsum tau kho vajtse
Yuav tsum tau kho vajtse
Yuav tsum tau kho vajtse
Yuav tsum tau 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. HYT939

2. Particle Photon

3. I2C Cable

4. I2C Shield Rau Particle Photon

Kauj ruam 2: Khoos phis tawj sib txuas:

Kho vajtse Hookup
Kho vajtse Hookup
Kho vajtse Hookup
Kho vajtse Hookup

Tshooj khoos phis tawj sib txuas ntu piav qhia qhov txuas txuas txuas uas xav tau ntawm lub sensor thiab cov duab photon. 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:

HYT939 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: Txoj Cai Rau Kev Ntsuas Ntsuas:

Txoj Cai Ntsuas Kev Ntsuas
Txoj Cai Ntsuas Kev Ntsuas

Cia peb pib nrog cov lej me me tam sim no.

Thaum siv lub ntsuas ntsuas nrog Arduino, peb suav nrog application.h thiab lub tsev qiv ntawv spark_wiring_i2c.h. "application.h" thiab lub tsev qiv ntawv spark_wiring_i2c.h muaj cov haujlwm uas pab txhawb kev sib txuas lus i2c ntawm lub sensor thiab cov khoom me me.

Tag nrho cov cai hauv qab no tau muab rau hauv qab no kom yooj yim ntawm tus neeg siv:

#suav nrog

#suav nrog

// HYT939 I2C chaw nyob yog 0x28 (40)

#define Ntxiv 0x28

ob npaug av noo = 0.0, cTemp = 0.0, fTemp = 0.0;

void teeb tsa ()

{

// Teem sib txawv

Particle.variable ("i2cdevice", "HYT939");

Particle.variable ("cTemp", cTemp);

Particle.variable ("av noo", av noo);

// Pib I2C kev sib txuas lus li MASTER

Hlau.begin ();

// Initialise Serial Communication

Serial.begin (9600);

ncua (300);

}

void lub voj ()

{

unsigned int cov ntaub ntawv [4];

// Pib I2C kis tau tus mob

Wire.beginTransmission (Addr);

// Xa ib txwm hais kom ua hom

Hlau.write (0x80);

// Nres I2C kev xa mus

Wire.endTransmission ();

ncua (300);

// Thov 4 bytes ntawm cov ntaub ntawv los ntawm lub cuab yeej

Wire.requestFrom (Addr, 4);

// Nyeem 4 bytes ntawm cov ntaub ntawv

// humidity msb, humidity lsb, temp msb, temp lsb

yog (Wire.available () == 4)

{

cov ntaub ntawv [0] = Wire.read ();

cov ntaub ntawv [1] = Wire.read ();

cov ntaub ntawv [2] = Wire.read ();

cov ntaub ntawv [3] = Wire.read ();

}

// Hloov cov ntaub ntawv mus rau 14-ntsis

av noo = (((cov ntaub ntawv [0] & 0x3F) * 256.0) + cov ntaub ntawv [1]) * (100.0 / 16383.0);

cTemp = (((cov ntaub ntawv [2] * 256.0) + (data [3] & 0xFC)) / 4) * (165.0 / 16383.0) - 40;

fTemp = (cTemp * 1.8) + 32;

// Tso tawm cov ntaub ntawv rau dashboard

Particle.publish ("Tus txheeb ze Vaum yog:", Txoj hlua (av noo));

ncua (1000);

Particle.publish ("Kub hauv Celsius:", String (cTemp));

ncua (1000);

Particle.publish ("Kub hauv Fahrenheit:", String (fTemp));

ncua (1000);

}

Particle.variable () muaj nuj nqi tsim cov kev hloov pauv kom khaws cov zis tawm ntawm lub sensor thiab Particle.publish () muaj nuj nqi qhia cov zis ntawm lub dashboard ntawm lub xaib.

Cov zis sensor tau pom hauv daim duab saum toj no rau koj siv.

Kauj Ruam 4: Cov ntawv thov:

Cov ntawv thov
Cov ntawv thov

HYT939 ua qhov ntsuas cov av noo zoo tau ua haujlwm hauv Kev Kho Mob, Autoclaves. Ntsuas dej ntsuas taw tes thiab Tshuab Kom Qhuav kuj pom qhov siv ntawm qhov ntsuas qhov ntsuas no. Hauv ntau qhov Laboratories qhov twg cov av noo tsim nyog yog qhov ntsuas tseem ceeb rau kev sim, qhov ntsuas no tuaj yeem siv rau qhov ntsuas qhov av noo.

Pom zoo: