Cov txheej txheem:
- Kauj Ruam 1: Yam Koj Xav Tau..
- Kauj Ruam 2: Kev Sib Txuas:
- Kauj ruam 3: Code:
- Kauj Ruam 4: Cov ntawv thov:
Video: Particle Photon - MPL3115A2 Precision Altimeter Sensor Tutorial: 4 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:26
MPL3115A2 ntiav MEMS lub siab ntsuas nrog I2C interface los muab cov ntaub ntawv Siab/Qhov Siab thiab Kub. Cov txiaj ntsig sensor tau digitized los ntawm kev daws teeb meem siab 24-ntsis ADC. Kev ua haujlwm sab hauv tshem tawm cov haujlwm them nyiaj los ntawm tus tswv tsev MCU. Nws muaj peev xwm txheeb xyuas qhov hloov pauv tsuas yog 0.05 kPa uas sib npaug rau 0.3m hloov pauv qhov siab. Nov yog nws qhov ua piv txwv nrog Particle photon.
Kauj Ruam 1: Yam Koj Xav Tau..
1. Particle Photon
2. MPL3115A2
3. I²C Cable
4. I²C Shield rau Particle Photon
Kauj Ruam 2: Kev Sib Txuas:
Nqa daim I2C daim ntaub thaiv rau cov photon me me thiab maj mam thawb nws hla cov pins ntawm cov khoom sib nqus.
Tom qab ntawd txuas ib qho kawg ntawm I2C cable rau MPL3115A2 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:
Cov lej me me rau MPL3115A2 tuaj yeem rub tawm los ntawm peb Github chaw cia khoom-DCUBE Store.
Nov yog qhov txuas.
Peb tau siv ob lub tsev qiv ntawv rau cov lej me me, uas yog application.h thiab spark_wiring_i2c.h. Spark_wiring_i2c lub tsev qiv ntawv xav tau los pab txhawb I2C kev sib txuas lus nrog lub sensor.
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.
NPE 31115A2
// Cov cai no tau tsim los ua haujlwm nrog MPL3115A2_I2CS I2C Mini Module
#suav nrog
#suav nrog
// MPL3115A2 I2C chaw nyob yog 0x60 (96)
#define Ntxiv 0x60
ntab cTemp = 0.0, fTemp = 0.0, siab = 0.0, qhov siab = 0.0;
int temp = 0, tHeight = 0; ntev pres = 0;
void teeb tsa ()
{
// Teem sib txawv
Particle.variable ("i2cdevice", "MPL3115A2");
Particle.variable ("cTemp", cTemp);
Particle.variable ("siab", siab);
Particle.variable ("qhov siab", qhov siab);
// Pib I2C kev sib txuas lus
Hlau.begin ();
// Initialise Serial Communication, teeb baud tus nqi = 9600
Serial.begin (9600);
// Pib I2C kis tau tus mob
Wire.beginTransmission (Addr);
// Xaiv tswj sau npe
Hlau.write (0x26);
// Hom ua haujlwm, OSR = 128, hom ntsuas ntsuas
Hlau.write (0xB9);
// Nres I2C kev xa mus
Wire.endTransmission ();
// Pib I2C kis tau tus mob
Wire.beginTransmission (Addr);
// Xaiv cov ntaub ntawv teeb tsa sau npe
Hlau.write (0x13);
// Cov ntaub ntawv npaj cov xwm txheej tau qhib rau qhov siab, siab, kub
Hlau.write (0x07);
// Nres I2C kev xa mus
Wire.endTransmission ();
ncua (300);
}
void lub voj ()
{
unsigned int cov ntaub ntawv [6];
// Pib I2C kis tau tus mob
Wire.beginTransmission (Addr);
// Xaiv tswj sau npe
Hlau.write (0x26);
// Hom ua haujlwm, OSR = 128, hom ntsuas ntsuas
Hlau.write (0xB9);
// Nres I2C kev xa mus
Wire.endTransmission ();
ncua (1000);
// 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 6 bytes ntawm cov ntaub ntawv
Wire.requestFrom (Addr, 6);
// Nyeem 6 bytes ntawm cov ntaub ntawv los ntawm chaw nyob 0x00 (00)
// xwm txheej, tHeight msb1, tHeight msb, tHeight lsb, temp msb, tem lsb
yog (Wire.available () == 6)
{
cov ntaub ntawv [0] = Wire.read ();
cov ntaub ntawv [1] = Wire.read ();
cov ntaub ntawv [2] = Wire.read ();
cov ntaub ntawv [3] = Wire.read ();
cov ntaub ntawv [4] = Wire.read ();
cov ntaub ntawv [5] = Wire.read ();
}
// Hloov cov ntaub ntawv mus rau 20-ntsis
tHeight = (((ntev) cov ntaub ntawv [1] * (ntev) 65536) + (cov ntaub ntawv [2] * 256) + (cov ntaub ntawv [3] & 0xF0)) / 16);
temp = ((cov ntaub ntawv [4] * 256) + (data [5] & 0xF0)) / 16;
qhov siab = tHeight / 16.0;
cTemp = (temp / 16.0);
fTemp = cTemp * 1.8 + 32;
// Pib I2C kis tau tus mob
Wire.beginTransmission (Addr);
// Xaiv tswj sau npe
Hlau.write (0x26);
// Hom ua haujlwm, OSR = 128, hom ntsuas cua
Hlau.write (0x39);
// Nres I2C kev xa mus
Wire.endTransmission ();
// 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 ();
ncua (1000);
// Thov 4 bytes ntawm cov ntaub ntawv
Wire.requestFrom (Addr, 4);
// Nyeem 4 bytes ntawm cov ntaub ntawv
// xwm txheej, pres msb1, pres msb, pres lsb
yog (Wire.available () == 4)
{
cov ntaub ntawv [0] = Wire.read ();
cov ntaub ntawv [1] = Wire.read ();
cov ntaub ntawv [2] = Wire.read ();
cov ntaub ntawv [3] = Wire.read ();
}
// Hloov cov ntaub ntawv mus rau 20-ntsis
pres = (((ntev) cov ntaub ntawv [1] * (ntev) 65536) + (cov ntaub ntawv [2] * 256) + (cov ntaub ntawv [3] & 0xF0)) / 16;
siab = (pres / 4.0) / 1000.0;
// Tso tawm cov ntaub ntawv rau dashboard
Particle.publish ("Qhov siab:", Txoj hlua (qhov siab));
Particle.publish ("Siab:", Txoj hlua (siab));
Particle.publish ("Kub hauv Celsius:", String (cTemp));
Particle.publish ("Kub hauv Fahrenheit:", String (fTemp));
ncua (1000);
}
Kauj Ruam 4: Cov ntawv thov:
Kev siv ntau yam ntawm MPL3115A2 suav nrog Kev Raug Siab Tshaj Plaws, Smartphones/Tablets, Kev Siv Hluav Taws Xob Tus Kheej thiab lwm yam.
Pom zoo:
Particle Photon - TCN75A Kub Sensor Tutorial: 4 Kauj Ruam
Particle Photon-TCN75A Kub Sensor Tutorial: TCN75A yog ob-xaim hluav taws xob ntsuas kub sib xyaw 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 teev npe tso cai rau cov neeg siv
Hws noo Sensor Siv Particle Photon: 6 Kauj Ruam
Hws noo Sensor Siv Particle Photon: Taw qhia Hauv qhov kev qhia no peb tab tom tsim kom muaj lub ntsuas cua noo siv lub Particle Photon thiab nws nyob hauv txaj lossis/thiab sab nraud WiFi kav hlau txais xov. Lub zog ntawm WiFi yog nyob ntawm qhov muaj dej noo hauv huab cua thiab hauv av. Peb siv txoj cai no
Particle Photon - ADT75 Kub Sensor Qhia: 4 Kauj Ruam
Particle Photon - ADT75 Kub Sensor Qhia: ADT75 yog qhov tseeb, ntsuas kub digital. Nws suav nrog qhov sib txawv ntawm qhov ntsuas kub thiab 12-ntsis analog rau digital hloov pauv rau kev saib xyuas thiab digitizing qhov kub thiab txias. Nws qhov kev nkag siab zoo ua rau nws muaj peev xwm txaus rau kuv
Particle Photon - STS21 Kub Sensor Tutorial: 4 Kauj Ruam
Particle Photon - STS21 Kub Sensor Tutorial: STS21 Digital Kub Sensor muaj qhov ua tau zoo tshaj thiab txuag chaw hneev taw. Nws muab kev ntsuas ntsuas, kab cim qhia tawm hauv digital, hom I2C. Kev tsim cov ntsuas no yog ua raws CMOSens thev naus laus zis, uas yog tus yam ntxwv zoo tshaj
Particle Photon - TMP100 Kub Sensor Tutorial: 4 Kauj Ruam
Particle Photon-TMP100 Kub Sensor Tutorial: TMP100 High-Accuracy, Low-Power, Digital Kub Sensor I2C MINI module. TMP100 yog qhov zoo tshaj rau kev ntsuas kub ntxiv. Cov cuab yeej no muab qhov tseeb ntawm ± 1 ° C yam tsis tas yuav ntsuas qhov ntsuas lossis sab nrauv tiv thaiv teeb liab. Nws