Cov txheej txheem:

Kev Ntsuas Kub thiab Vaum Siv HDC1000 thiab Arduino Nano: 4 Cov Kauj Ruam
Kev Ntsuas Kub thiab Vaum Siv HDC1000 thiab Arduino Nano: 4 Cov Kauj Ruam

Video: Kev Ntsuas Kub thiab Vaum Siv HDC1000 thiab Arduino Nano: 4 Cov Kauj Ruam

Video: Kev Ntsuas Kub thiab Vaum Siv HDC1000 thiab Arduino Nano: 4 Cov Kauj Ruam
Video: Lub Zog Nruab Nrog (Hmong Dubbed) 2024, Kaum ib hlis
Anonim
Image
Image

HDC1000 yog lub ntsuas cua digital nrog cov ntsuas kub sib xyaw uas muab qhov ntsuas tau zoo heev ntawm lub zog qis heev. Cov cuab yeej ntsuas cov av noo raws li lub peev xwm tshiab sensor. Cov av noo thiab qhov ntsuas kub tau tsim los ntawm lub Hoobkas. Nws ua haujlwm tsis pub dhau -40 ° C txog +125 ° C kub ntau.

Hauv qhov kev qhia no kev cuam tshuam ntawm HDC1000 sensor module nrog arduino nano tau piav qhia. Txhawm rau nyeem qhov ntsuas kub thiab qhov av noo, peb tau siv arduino nrog I2c adapter Qhov no I2C adapter ua rau kev txuas mus rau lub ntsuas qhov ntsuas tau yooj yim thiab ntseeg tau ntau dua.

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. HDC1000

2. Arduino Nano

3. I2C Cable

4. I2C Shield rau Arduino Nano

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

HDC1000 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 ntsuas Kub thiab Vaum:

Txoj Cai ntsuas Kub thiab Vaum
Txoj Cai ntsuas Kub thiab Vaum

Cia pib nrog tus lej arduino tam sim no.

Thaum siv lub ntsuas qhov 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 pawg thawj coj saib arduino.

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

#suav nrog

// HDC1000 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);

// Pib I2C kev sib txuas lus

Wire.beginTransmission (Addr);

// Xaiv cov npe sau npe

Hlau.write (0x02);

// Kub, ua kom cov av noo, daws teeb meem = 14-ntsis, rhaub rau

Hlau.write (0x30);

// Nres I2C Kev Kis

Wire.endTransmission ();

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 ntsuas

Hlau.write (0x00);

// Nres I2C Kev Kis

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

int temp = (cov ntaub ntawv [0] * 256) + cov ntaub ntawv [1];

ntab cTemp = (temp / 65536.0) * 165.0 - 40;

ntab fTemp = cTemp * 1.8 + 32;

// Pib I2C kev sib txuas lus

Wire.beginTransmission (Addr);

// Xa cov lus ntsuas ntsuas av noo

Hlau.write (0x01);

// Nres I2C Kev Kis

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

ntab ntub = (cov ntaub ntawv [0] * 256) + cov ntaub ntawv [1];

av noo = (av noo / 65536.0) * 100.0;

// Cov ntaub ntawv tso tawm rau tus saib xyuas

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

Serial.print (av noo);

Serial.println (" %RH");

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

Serial.print (cTemp);

Serial.println ("C");

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

Serial.print (fTemp);

Serial.println ("F");

ncua (500);

}

Hauv cov tsev qiv ntawv xaim Wire.write () thiab Wire.read () yog siv los sau cov lus txib thiab nyeem cov ntawv tso tawm.

Serial.print () thiab Serial.println () yog siv los tso saib cov zis ntawm lub sensor ntawm cov saib xyuas ntawm Arduino IDE.

Qhov tso tawm ntawm lub ntsuas hluav taws xob tau qhia hauv daim duab saum toj no.

Kauj Ruam 4: Cov ntawv thov:

Cov ntawv thov
Cov ntawv thov

HDC1000 tuaj yeem ua haujlwm ua cua sov, tso cua thiab cua txias (HVAC), Ntse Thermostats thiab Chav Saib Xyuas. Qhov ntsuas no tseem pom nws daim ntawv thov hauv Cov Tshuab Luam Ntawv, Cov Ntsuas Hluav Taws Xob, Cov Khoom Siv Kho Mob, Kev Thauj Khoom Nkoj nrog rau Automotive Windshield Defog.

Pom zoo: