Cov txheej txheem:

Arduino Nano - TCN75A Kub Sensor Qhia: 4 Kauj Ruam
Arduino Nano - TCN75A Kub Sensor Qhia: 4 Kauj Ruam

Video: Arduino Nano - TCN75A Kub Sensor Qhia: 4 Kauj Ruam

Video: Arduino Nano - TCN75A Kub Sensor Qhia: 4 Kauj Ruam
Video: Arduino Nano - TCN75A Temperature Sensor Tutorial 2024, Kaum ib hlis
Anonim
Image
Image

TCN75A yog ob txoj kab hluav taws xob ntsuas kub sib xyaw ua ke nrog ntsuas kub-rau-digital hloov pauv. Nws tau suav nrog cov neeg siv cov ntawv sau npe uas muab kev hloov pauv rau kev thov ntsuas kub. Cov chaw tso npe tso cai rau cov neeg siv teeb tsa hom kev txuag hluav taws xob, kaw lub kaw lus, ib hom kev txhaj tshuaj thiab lwm yam. Nov yog nws qhov ua qauv qhia nrog arduino nano.

Kauj Ruam 1: Yam Koj Xav Tau..

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

1. Arduino Nano

2. TCN75A

3. I²C Cable

4. I²C Shield rau Arduino Nano

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 Arduino Nano thiab maj mam thawb nws hla tus pin ntawm Nano.

Tom qab ntawd txuas ib kawg ntawm I2C cable rau TCN75A sensor thiab lwm qhov kawg rau I2C daim ntaub thaiv.

Kev sib txuas tau qhia hauv daim duab saum toj no.

Kauj ruam 3: Code:

Txoj Cai
Txoj Cai

Tus lej Arduino rau TCN75A tuaj yeem rub tawm los ntawm peb Github chaw cia khoom-DCUBE Store.

Nov yog qhov txuas rau tib yam:

github.com/DcubeTechVentures/TCN75A/blob/master/Arduino/TCN75A.ino

Peb suav nrog tsev qiv ntawv Wire.h los pab txhawb I2c kev sib txuas lus ntawm lub sensor nrog Arduino board. 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.

TCN75A

// Tus lej no yog tsim los ua haujlwm nrog TCN75A_I2CS I2C Mini Module

#suav nrog

// TCN75A I2C chaw nyob yog 0x48 (72)

#define Ntxiv 0x48

void teeb tsa ()

{

// Pib I2C kev sib txuas lus raws li tus Xib Hwb

Hlau.begin ();

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

Serial.begin (9600);

// Pib I2C kis tau tus mob

Wire.beginTransmission (Addr);

// Xaiv cov npe sau npe

Hlau.write (0x01);

// 12-ntsis ADC daws teeb meem

Hlau.write (0x60);

// Nres I2C kev xa mus

Wire.endTransmission ();

ncua (300);

}

void lub voj ()

{

unsigned int cov ntaub ntawv [2];

// Pib I2C kis tau tus mob

Wire.beginTransmission (Addr);

// Xaiv cov ntaub ntawv sau npe

Hlau.write (0x00);

// Nres I2C kev xa mus

Wire.endTransmission ();

// 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 mus rau 12-ntsis

int temp = (((cov ntaub ntawv [0] * 256) + (data [1] & 0xF0)) / 16);

yog (temp> 2047)

{

temp -= 4096;

}

ntab cTemp = temp * 0.0625;

ntab fTemp = (cTemp * 1.8) + 32;

// Cov ntaub ntawv tso tawm rau tus saib xyuas

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

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

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

Serial.print (fTemp);

Serial.println ("F");

ncua (1000);

}

Kauj Ruam 4: Cov ntawv thov:

TCN75A yog lub ntsuas cua kub uas tuaj yeem ua haujlwm hauv lub khoos phis tawj ntiag tug thiab servers. Nws tseem tuaj yeem siv rau hauv kev lom zem, chaw ua haujlwm khoom siv, ua haujlwm nyuaj tsav thiab lwm yam khoom siv hauv PC.

Pom zoo: