Cov txheej txheem:

Kev Siv Lub Teeb Nyeem Kom Siv BH1715 thiab Particle Photon: 5 Kauj Ruam
Kev Siv Lub Teeb Nyeem Kom Siv BH1715 thiab Particle Photon: 5 Kauj Ruam

Video: Kev Siv Lub Teeb Nyeem Kom Siv BH1715 thiab Particle Photon: 5 Kauj Ruam

Video: Kev Siv Lub Teeb Nyeem Kom Siv BH1715 thiab Particle Photon: 5 Kauj Ruam
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 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 Particle Photon. Particle Photon yog lub rooj tsavxwm uas tuaj yeem pab txhawb kev tswj hwm ntawm txhua lub cuab yeej hauv internet.

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

1. BH1715 - Ambient Teeb Sensor

2. Particle Photon

3. I2C Cable

4. I2C Shield Rau Particle Photon

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. Particle Photon

3. I2C Cable

4. I2C Shield rau Particle Photon

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: Kev Ntsuas Kev Ntsuas Qhov Ntsuas Particle Code:

Kev Ntsuas Kev Ntsuas Kev Nyuaj Siab Particle Code
Kev Ntsuas Kev Ntsuas Kev Nyuaj Siab Particle Code
Kev Ntsuas Kev Ntsuas Kev Nyuaj Siab Particle Code
Kev Ntsuas Kev Ntsuas Kev Nyuaj Siab Particle Code

Cia peb pib nrog cov lej me me tam sim no.

Thaum siv lub ntsuas qhov ntsuas nrog arduino, peb suav nrog application.h thiab lub tsev qiv ntawv spark_wiring_i2c.h. "application.h" thiab lub tsev qiv ntawv spark_wiring_i2c.h muaj cov haujlwm uas pab txhawb kev sib txuas lus i2c ntawm lub sensor thiab cov khoom me me.

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

#suav nrog

#suav nrog

// BH1715 I2C chaw nyob yog 0x23 (35)

#define Ntxiv 0x23

int luminance = 0;

void teeb tsa ()

{

// Teem sib txawv

Particle.variable ("i2cdevice", "BH1715");

Particle.variable ("luminance", luminance);

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

// Xa lub zog ntawm kev hais kom ua

Hlau.write (0x01);

// Nres I2C Kev Kis

Wire.endTransmission ();

// Pib I2C Kev Kis

Wire.beginTransmission (Addr);

// Xa cov lus ntsuas ntsuas mus tas li

Hlau.write (0x10);

// Nres I2C Kev Kis

Wire.endTransmission ();

ncua (300);

}

void lub voj ()

{

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)

{

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

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

}

ncua (300);

// Hloov cov ntaub ntawv

luminance = ((cov ntaub ntawv [0] & 0xFF) * 256 + (cov ntaub ntawv [1] & 0xFF)) / 1.20;

// Tso tawm cov ntaub ntawv rau dashboard

Particle.publish ("Ambient Light Luminance:", Txoj hlua (luminance));

}

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: