Cov txheej txheem:

Arduino Nano - TSL45315 Ambient Light Sensor Qhia: 4 Kauj Ruam
Arduino Nano - TSL45315 Ambient Light Sensor Qhia: 4 Kauj Ruam

Video: Arduino Nano - TSL45315 Ambient Light Sensor Qhia: 4 Kauj Ruam

Video: Arduino Nano - TSL45315 Ambient Light Sensor Qhia: 4 Kauj Ruam
Video: Arduino Nano - TSL45315 Ambient Light Sensor Tutorial 2024, Kaum ib hlis
Anonim
Image
Image

TSL45315 yog lub teeb pom kev zoo ib puag ncig digital. Nws kwv yees tib neeg qhov muag teb raws ntau yam teeb pom kev zoo. Cov cuab yeej muaj peb lub sijhawm xaiv ua ke thiab muab ncaj qha 16-ntsis lux tso tawm ntawm I2C tsheb npav sib cuam tshuam. Cov cuab yeej muaj cov kab ntawv photodiode, kev sib xyaw ua ke sib piv-rau-digital hloov pauv (ADC), teeb liab ua cov kab hluav taws xob, cov lej xav txog qhov xav tau, thiab I2C cov lej sib cuam tshuam ntawm ib qho CMOS kev sib txuas ua ke los muab cov ntaub ntawv lux. Nov yog nws qhov ua piv txwv nrog arduino nano.

Kauj Ruam 1: Yam Koj Xav Tau..

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

1. Arduino Nano

2. TSL45315

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 TSL45315 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 TSL45315 tuaj yeem rub tawm los ntawm peb GitHub chaw cia khoom-Dcube Store.

Nov yog qhov txuas rau tib yam:

github.com/DcubeTechVentures/TSL45315…

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.

TSL45315

// Cov cai no tau tsim los ua haujlwm nrog TSl45315_I2CS I2C Mini Module muaj los ntawm hauv Dcube Store.

#suav nrog

// TSL45315 I2C chaw nyob yog 0x29 (41)

#define Ntxiv 0x29

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 Kis

Wire.beginTransmission (Addr);

// Xaiv tswj sau npe

Hlau.write (0x80);

// Ua haujlwm zoo

Hlau.write (0x03);

// Nres I2C kev xa mus

Wire.endTransmission ();

// Pib I2C Kev Kis

Wire.beginTransmission (Addr);

// Xaiv cov npe sau npe

Hlau.write (0x81);

// Multiplier 1x, Xim: 400ms

Hlau.write (0x00);

// Nres I2C kev xa mus

Wire.endTransmission ();

ncua (300);

}

void lub voj ()

{

unsigned int cov ntaub ntawv [2];

// Pib I2C Kev Kis

Wire.beginTransmission (Addr);

// Xaiv cov ntaub ntawv sau npe

Hlau.write (0x84);

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

// luminance lsb, luminance msb

yog (Wire.available () == 2)

{

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

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

}

// Hloov cov ntaub ntawv

ntab luminance = cov ntaub ntawv [1] * 256 + cov ntaub ntawv [0];

// Cov ntaub ntawv tso tawm rau Serial Monitor

Serial.print ("Ambient Light Luminance:");

Serial.print (luminance);

Serial.println ("lux");

ncua (300);

}

Kauj Ruam 4: Cov ntawv thov:

Qhov dav dav dav ntawm lub teeb pom kev ib puag ncig ua rau nws muaj txiaj ntsig tshwj xeeb hauv kev siv sab nraum zoov uas nws raug rau tshav ntuj ncaj qha. Cov cuab yeej siv tau zoo tshaj plaws rau kev siv tsis siv neeg kev teeb ntawm txoj kev thiab kev nyab xeeb, daim ntawv tshaj tawm, thiab teeb pom kev zoo hauv tsheb. TSL45315 cov cuab yeej kuj tseem tuaj yeem siv hauv lub xeev ruaj khov thiab teeb pom kev zoo rau kev tswj tsis siv neeg thiab kev sau hnub nruab hnub kom ua kom muaj kev txuag hluav taws xob ntau. Lwm daim ntawv thov suav nrog tso saib lub teeb pom kev zoo txhawm rau txuas lub roj teeb lub neej thiab ua kom pom kev zoo hauv xov tooj ntawm tes, ntsiav tshuaj, thiab phau ntawv sau.

Pom zoo: