Cov txheej txheem:

Kev Ntsuas Kub thiab Vaum Siv SHT25 thiab Particle Photon: 5 Kauj Ruam
Kev Ntsuas Kub thiab Vaum Siv SHT25 thiab Particle Photon: 5 Kauj Ruam

Video: Kev Ntsuas Kub thiab Vaum Siv SHT25 thiab Particle Photon: 5 Kauj Ruam

Video: Kev Ntsuas Kub thiab Vaum Siv SHT25 thiab Particle Photon: 5 Kauj Ruam
Video: Lub Zog Nruab Nrog (Hmong Dubbed) 2024, Kaum ib hlis
Anonim
Image
Image

Tsis ntev los no peb tau ua haujlwm ntawm ntau txoj haujlwm uas xav tau kev ntsuas kub thiab av noo thiab tom qab ntawd peb pom tau tias ob qhov kev ntsuas no tau ua lub luag haujlwm tseem ceeb hauv kev kwv yees ntawm kev ua haujlwm ntawm lub system. Ob qho tib si ntawm qib kev lag luam thiab cov txheej txheem tus kheej qhov ntsuas kub zoo tshaj yog qhov yuav tsum tau ua kom tau txais txiaj ntsig zoo ntawm lub kaw lus.

Qhov no yog vim li cas, hauv qhov kev qhia no peb yuav piav qhia kev ua haujlwm ntawm SHT25 cov av noo thiab qhov ntsuas kub nrog cov duab me me.

Kauj Ruam 1: SHT25 Txheej Txheem:

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

Ua ntej tshaj plaws cia pib nrog kev nkag siab yooj yim ntawm lub sensor thiab cov txheej txheem uas nws ua haujlwm.

SHT25 I2C Vaum thiab Kub Sensor ± 1.8%RH ± 0.2 ° C I2C Mini Module. Nws yog qhov tseeb cov av noo thiab qhov ntsuas kub tau dhau los ua tus txheej txheem kev lag luam raws li daim ntawv foos thiab kev txawj ntse, muab kev ntsuas ntsuas, ntsuas qhov ntsuas qhov ntsuas hauv digital, hom I2C. Kev koom ua ke nrog tshwj xeeb analog thiab digital Circuit no lub ntsuas pa yog ib qho cuab yeej siv tau zoo tshaj plaws los ntsuas qhov kub thiab txias.

Cov txheej txheem kev sib txuas lus uas lub sensor ua haujlwm yog I2C. I2C sawv cev rau kev sib koom ua ke. Nws yog cov txheej txheem kev sib txuas lus uas kev sib txuas lus tau tshwm sim los ntawm SDA (cov ntaub ntawv xov xwm) thiab SCL (cov xov tooj). Nws tso cai txuas ntau yam khoom siv tib lub sijhawm. Nws yog ib qho ntawm cov txheej txheem kev sib txuas lus yooj yim tshaj plaws thiab muaj txiaj ntsig tshaj plaws.

Kauj Ruam 2: Yam Koj Xav Tau..

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

Cov ntaub ntawv uas peb xav tau kom ua tiav peb lub hom phiaj suav nrog cov khoom siv hauv qab no:

1. SHT25 av noo thiab ntsuas kub

2. Particle Photon

3. I2C Cable

4. I2C Shield rau particle photon

Kauj Ruam 3: Khoos Phis Tawj Hookup:

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:

SHT25 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 4: Txoj Cai Saib Xyuas Kub thiab Vaum:

Kev Ntsuas Kub thiab Vaum Cov Cai
Kev Ntsuas Kub thiab Vaum Cov Cai

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

Thaum siv lub ntsuas qhov 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

// SHT25 I2C chaw nyob yog 0x40 (64)

#define Ntxiv 0x40

ntab ntub = 0.0, cTemp = 0.0, fTemp = 0.0;

void teeb tsa ()

{

// Teem sib txawv

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

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

Particle.variable ("cTemp", cTemp);

// Pib I2C kev sib txuas lus li MASTER

Hlau.begin ();

// Initialise serial communication, teeb baud tus nqi = 9600

Serial.begin (9600);

ncua (300);

}

void lub voj ()

{

unsigned int cov ntaub ntawv [2];

// Pib I2C kev sib txuas lus

Wire.beginTransmission (Addr);

// Xa cov lus ntsuas ntsuas av noo, Tsis muaj tus tswv tuav

Hlau.write (0xF5);

// Nres I2C kev xa mus

Wire.endTransmission ();

ncua (500);

// Thov 2 bytes ntawm cov ntaub ntawv

Wire.requestFrom (Addr, 2);

// Nyeem 2 bytes ntawm cov ntaub ntawv

// av noo msb, av noo lsb

yog (Wire.available () == 2)

{

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

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

// Hloov cov ntaub ntawv

av noo = ((((cov ntaub ntawv [0] * 256.0) + cov ntaub ntawv [1]) * 125.0) / 65536.0) - 6;

// Tso tawm cov ntaub ntawv rau dashboard

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

}

// Pib I2C kis tau tus mob

Wire.beginTransmission (Addr);

// Xa cov lus ntsuas ntsuas kub, TSIS tuav tus tswv

Hlau.write (0xF3);

// Nres I2C kev xa mus

Wire.endTransmission ();

ncua (500);

// Thov 2 bytes ntawm cov ntaub ntawv

Wire.requestFrom (Addr, 2);

// Nyeem 2 bytes ntawm cov ntaub ntawv

// temp msb, kub lsb

yog (Wire.available () == 2)

{

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

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

// Hloov cov ntaub ntawv

cTemp = ((((data [0] * 256.0) + data [1]) * 175.72) / 65536.0) - 46.85;

fTemp = (cTemp * 1.8) + 32;

// Tso tawm cov ntaub ntawv rau dashboard

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

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

}

ncua (300);

}

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 5: Cov ntawv thov:

Cov ntawv thov
Cov ntawv thov

SHT25 qhov ntsuas kub thiab qhov txheeb ze cov txheeb ze muaj ntau yam kev siv xws li ntsuas kub, khoos phis tawj ib puag ncig tiv thaiv cua sov. Peb kuj tseem tau ua haujlwm ntsuas qhov ntsuas no rau hauv daim ntawv thov huab cua nrog rau kev tshuaj xyuas tsev cog khoom.

Pom zoo: