Cov txheej txheem:

Kev Siv Qhov Teeb Meem Siv BH1715 thiab Arduino Nano: 5 Kauj Ruam
Kev Siv Qhov Teeb Meem Siv BH1715 thiab Arduino Nano: 5 Kauj Ruam

Video: Kev Siv Qhov Teeb Meem Siv BH1715 thiab Arduino Nano: 5 Kauj Ruam

Video: Kev Siv Qhov Teeb Meem Siv BH1715 thiab Arduino Nano: 5 Kauj Ruam
Video: Qhia txuas xaim hluav taws xob daim: 02 2024, Hlis ntuj nqeg
Anonim
Image
Image

Nag hmo peb tau ua haujlwm ntawm LCD cov lus, thiab thaum ua haujlwm dhau ntawm lawv peb tau pom qhov tseem ceeb ntawm kev suav qhov teeb pom kev zoo. Kev siv lub teeb tsis yog tsuas yog qhov tseem ceeb hauv lub cev ntawm lub ntiaj teb no tab sis nws muaj nws lub luag haujlwm hais tau zoo hauv kev siv tshuaj lom neeg ib yam nkaus. Qhov kwv yees kwv yees ntawm lub teeb siv ua lub luag haujlwm tseem ceeb hauv peb cov txheej txheem, hauv kev loj hlob ntawm cov nroj tsuag, thiab lwm yam.

Hauv qhov kev qhia no, peb yuav los qhia txog kev ua haujlwm ntawm BH1715 nrog Arduino Nano.

Kho vajtse uas koj yuav xav tau rau lub hom phiaj no yog raws li hauv qab no:

1. BH1715 - Ambient Teeb Sensor

2. Arduino nano

3. I2C Cable

4. I2C Shield Rau Arduino Nano

Kauj Ruam 1: BH1715 Txheej Txheem:

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

Ua ntej tshaj plaws peb xav paub koj nrog cov yam ntxwv tseem ceeb ntawm lub ntsuas qhov ntsuas uas yog BH1715 thiab cov txheej txheem kev sib txuas lus uas nws ua haujlwm.

BH1715 yog digital Ambient Light Sensor nrog I²C tsheb npav sib cuam tshuam. BH1715 feem ntau yog siv kom tau txais cov ntaub ntawv teeb pom kev zoo los kho LCD thiab Keypad lub teeb pom kev zoo rau lub xov tooj ntawm tes. Cov cuab yeej no muaj 16-ntsis kev daws teeb meem thiab ntsuas ntsuas tau ntau, tso cai kuaj pom los ntawm.23 txog 100, 000 lux.

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. BH1715 - Ambient Teeb Sensor

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 ntsuas cua thiab raspberry pi. 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:

BH1715 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: Teeb Pom Kev Ntsuas Arduino Code:

Teeb Pom Kev Ntsuas Kev Ntsuas Arduino Code
Teeb Pom Kev Ntsuas Kev Ntsuas Arduino Code
Teeb Pom Kev Ntsuas Kev Ntsuas Arduino Code
Teeb Pom Kev Ntsuas Kev Ntsuas Arduino Code

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

// BH1715 I2C chaw nyob yog 0x23 (35) #define Addr 0x23 void setup () {// Initialise I2C kev sib txuas lus li MASTER Wire.begin (); // Initialise Serial Communication, teeb baud tus nqi = 9600 Serial.begin (9600); // Pib I2C Kev Xa Xov Hlau.beginTransmission (Addr); // Xa lub zog ntawm kev hais kom ua Wire.write (0x01); // Nres I2C Kis Kab Hlau.endTransmission (); // Pib I2C Kev Xa Xov Hlau.beginTransmission (Addr); // Xa cov ntsuas ntsuas txuas mus txuas ntxiv Wire.write (0x10); // Nres I2C Kis Kab Hlau.endTransmission (); ncua (300); } void loop () {unsigned int cov ntaub ntawv [2]; // Thov 2 byte ntawm cov ntaub ntawv Wire.requestFrom (Addr, 2); // Nyeem 2 bytes ntawm cov ntaub ntawv // ALS msb, ALS lsb yog (Wire.available () == 2) {data [0] = Wire.read (); cov ntaub ntawv [1] = Wire.read (); } ncua (300); // hloov cov ntaub ntawv ntab luminance = ((cov ntaub ntawv [0] * 256) + cov ntaub ntawv [1]) /1.20; // Cov ntaub ntawv tso tawm mus rau tus saib xyuas Serial.print ("Ambient Light Luminance:"); Serial.print (luminance); Serial.println ("lux"); }

Cov hauv qab no ntawm txoj cai pib ua i2c kev sib txuas lus thiab kev sib txuas lus txuas nrog kev pab ntawm Wire.begin () thiab Serial.begin () ua haujlwm.

// Pib I2C kev sib txuas lus li MASTER

Hlau.begin (); // Initialise Serial Communication, teeb baud tus nqi = 9600 Serial.begin (9600); // Pib I2C Kev Xa Xov Hlau.beginTransmission (Addr); // Xa lub zog ntawm kev hais kom ua Wire.write (0x01); // Nres I2C Kis Kab Hlau.endTransmission (); // Pib I2C Kev Xa Xov Hlau.beginTransmission (Addr); // Xa cov ntsuas ntsuas txuas mus txuas ntxiv Wire.write (0x10); // Nres I2C Kis Kab Hlau.endTransmission (); ncua (300);

Kev siv lub teeb raug ntsuas hauv ntu hauv qab no ntawm cov cai.

unsigned int cov ntaub ntawv [2];

// Thov 2 byte ntawm cov ntaub ntawv Wire.requestFrom (Addr, 2); // Nyeem 2 bytes ntawm cov ntaub ntawv // ALS msb, ALS lsb yog (Wire.available () == 2) {data [0] = Wire.read (); cov ntaub ntawv [1] = Wire.read (); } ncua (300); // hloov cov ntaub ntawv ntab luminance = ((cov ntaub ntawv [0] * 256) + cov ntaub ntawv [1]) /1.20; // Cov ntaub ntawv tso tawm mus rau tus saib xyuas Serial.print ("Ambient Light Luminance:"); Serial.print (luminance); Serial.println ("lux");

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

Kauj Ruam 5: Cov ntawv thov:

Cov ntawv thov
Cov ntawv thov

BH1715 yog lub teeb pom kev ib puag ncig lub teeb pom kev zoo uas tuaj yeem suav nrog hauv xov tooj ntawm tes, LCD TV, NCEJ PC thiab lwm yam. siv lub teeb pom kev zoo.

Pom zoo: