Cov txheej txheem:

Kev Ntsuas Kub thiab Vaum Siv SHT25 thiab Arduino Nano: 5 Kauj Ruam
Kev Ntsuas Kub thiab Vaum Siv SHT25 thiab Arduino Nano: 5 Kauj Ruam

Video: Kev Ntsuas Kub thiab Vaum Siv SHT25 thiab Arduino Nano: 5 Kauj Ruam

Video: Kev Ntsuas Kub thiab Vaum Siv SHT25 thiab Arduino Nano: 5 Kauj Ruam
Video: Lub Zog Nruab Nrog (Hmong Dubbed) 2024, Hlis ntuj nqeg
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 ntsuas kub nrog Arduino Nano.

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 Vaum thiab ntsuas kub

2. Arduino Nano

3. I2C Cable

4. I2C Shield Rau Arduino nano

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 uas xav tau ntawm lub sensor thiab arduino nano. 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 Arduino code tam sim no.

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

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

#suav nrog

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

#define Ntxiv 0x40

void teeb tsa ()

{

// 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 kis tau tus mob

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

float humidity = (((data [0] * 256.0 + data [1]) * 125.0) / 65536.0) - 6;

// Cov ntaub ntawv tso tawm rau Serial Monitor

Serial.print ("Tus txheeb ze Vaum:");

Serial.print (av noo);

Serial.println (" %RH");

}

// 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

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

ntab fTemp = (cTemp * 1.8) + 32;

// Cov ntaub ntawv tso tawm rau Serial Monitor

Serial.print ("Kub hauv Celsius:");

Serial.print (cTemp); Serial.println ("C");

Serial.print ("Kub hauv Fahrenheit:");

Serial.print (fTemp);

Serial.println ("F");

}

ncua (300);

}

Txhua yam koj yuav tsum tau ua yog hlawv cov cai hauv Arduino thiab tshawb xyuas koj cov ntawv nyeem ntawm qhov chaw nres nkoj. Cov zis tau pom hauv daim duab saum toj no.

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: