Cov txheej txheem:

Ntsuas Siab Nrog Koj Micro: ntsis: 5 Kauj Ruam (nrog Duab)
Ntsuas Siab Nrog Koj Micro: ntsis: 5 Kauj Ruam (nrog Duab)

Video: Ntsuas Siab Nrog Koj Micro: ntsis: 5 Kauj Ruam (nrog Duab)

Video: Ntsuas Siab Nrog Koj Micro: ntsis: 5 Kauj Ruam (nrog Duab)
Video: Zoo Siab Nrog Koj - Paj Tsua Thoj [ Official MV ] Nkauj Tawm Tshiab 2022 2024, Kaum ib hlis
Anonim
Ntsuas Siab Nrog Koj Micro: me ntsis
Ntsuas Siab Nrog Koj Micro: me ntsis
Ntsuas Siab Nrog Koj Micro: me ntsis
Ntsuas Siab Nrog Koj Micro: me ntsis

Cov lus qhia hauv qab no piav qhia yooj yim los tsim thiab cov cuab yeej pheej yig los ntsuas kev ntsuas thiab ua kom pom Boyle txoj cai, siv micro: me ntsis ua ke nrog BMP280 siab/ntsuas kub.

Whereas qhov koob txhaj tshuaj/lub ntsuas hluav taws xob sib xyaw ua ke twb tau piav qhia hauv ib qho ntawm kuv cov lus qhia yav dhau los, kev sib xyaw nrog micro: me ntsis tab tom muab sijhawm tshiab, piv txwv li rau chav kawm chav haujlwm.

Ib qho ntxiv, cov lej piav qhia ntawm daim ntawv thov uas micro: me ntsis tau siv ua ke nrog I2C uas tau tsav lub sensor yog qhov txwv tsawg kom deb li deb. Kuv vam tias cov lus qhia no yuav yog qhov pib rau lwm cov haujlwm.

Cov cuab yeej tso cai ntsuas qhov ntsuas huab cua ntau, thiab tso saib cov txiaj ntsig ntawm micro: me ntsis LED array lossis ntawm lub khoos phis tawj sib txuas, tom qab siv lub ntsuas ntsuas lossis cov phiaj xwm ua haujlwm ntawm Arduino IDE. Ib qho ntxiv koj muaj kev tawm tswv yim tsis txaus ntseeg, zoo li koj yuav thawb lossis rub lub plunger ntawm lub koob txhaj tshuaj rau koj tus kheej, thiab ntawm no xav tias lub zog xav tau.

Los ntawm lub neej ntawd, cov zaub tso cai rau koj kwv yees lub siab los ntawm qib ntsuas pom ntawm LED matrix. Cov phiaj xwm phiaj xwm ntawm Arduino IDE tso cai ua ib yam, tab sis nrog kev daws teeb meem zoo dua (saib video). Ntau cov kev daws teeb meem tseem muaj, xws li hauv Cov Lus Ua Koj kuj tseem tuaj yeem tso tawm qhov ntsuas ntsuas qhov tseeb ntawm qhov ntsuas thiab ntsuas kub ntawm LED matrix tom qab nias lub A lossis B cov nyees khawm feem, tab sis cov saib xyuas ntawm Arduino IDE nrawm dua, tso cai rau tso saib qhov tseem ceeb nyob ze lub sijhawm.

Tag nrho cov nqi thiab cov txuj ci txuj ci xav tau los tsim cov cuab yeej yog qhov tsawg, yog li nws tuaj yeem yog chav kawm zoo nyob hauv kev saib xyuas ntawm tus kws qhia ntawv. Ntxiv rau qhov cuab yeej tuaj yeem yog cov cuab yeej rau STEM cov haujlwm nrog tsom mus rau lub cev lossis siv hauv lwm qhov haujlwm uas lub zog lossis qhov hnyav yuav tsum tau hloov pauv mus rau tus nqi digital.

Lub hauv paus tau siv los tsim lub micro yooj yim heev: me ntsis dhia-o-meter, lub cuab yeej ntsuas seb koj dhia tob npaum li cas.

Cov ntawv ntxiv 27-Tsib Hlis-2018:

Raws li Pimoroni tau tsim lub tsev qiv ntawv MakeCode rau lub BMP280 sensor, Qhov no tau muab sijhawm rau kuv los txhim kho tsab ntawv los siv rau lub cuab yeej piav qhia ntawm no. Tsab ntawv thiab HEX-cov ntaub ntawv sib xws tuaj yeem nrhiav pom hauv qib kawg ntawm cov lus qhia no. Txhawm rau siv nws, tsuas yog ntsaws cov ntaub ntawv HEX rau koj lub micro: ntsis. Tsis xav tau software tshwj xeeb, thiab koj tuaj yeem siv online MakeCode editor rau kho cov ntawv.

Kauj Ruam 1: Siv Cov Khoom Siv

Cov Khoom Siv
Cov Khoom Siv
Cov Khoom Siv
Cov Khoom Siv
Cov Khoom Siv
Cov Khoom Siv
Cov Khoom Siv
Cov Khoom Siv
  • Ib qho me me: tau txais kuv li ntawm Pimoroni - 13.50 GBP
  • Kitronic Edge Connector rau micro: me ntsis - ntawm Pimoroni - 5 GBP, Nco tseg: Pimorini tam sim no muaj lub khob cij zoo -phooj ywg ntug txuas hu ua tus pin: ntsis nrog pins ntawm I2C chaw nres nkoj.
  • 2 x 2 tus pin header strips
  • Roj teeb lossis LiPo rau micro: me ntsis (tsis tsim nyog, tab sis pab tau), roj teeb cable nrog hloov (dito) - Pimoroni
  • jumper cables rau kev sib txuas ntawm cov sensors rau Ntug txuas
  • ntev (!) jumper cables rau lub ntsuas cua, tsawg kawg ntev npaum li lub koob txhaj tshuaj,, f/f lossis f/m
  • BMP280 siab & ntsuas kub kub - Banggood - 5 US $ rau peb chav ntsuas qhov ntsuas rau qhov ntsuas no yog nruab nrab ntawm 550 txog 1537 hPa.
  • 150 ml yas raj yas raj nrog lub gasket roj hmab - Amazon lossis kho vajtse thiab vaj khw - txog 2 - 3 US $
  • kub kua nplaum/kub kua nplaum rab yaj phom
  • cam khwb cia hlau
  • lub khoos phis tawj nrog Arduino IDE teeb tsa

Kauj Ruam 2: Cov Lus Qhia Los Ua Ke

Cov Lus Qhia Los Ua Ke
Cov Lus Qhia Los Ua Ke
Cov Lus Qhia Los Ua Ke
Cov Lus Qhia Los Ua Ke
Cov Lus Qhia Los Ua Ke
Cov Lus Qhia Los Ua Ke

Cov laug lub taub hau rau BMP280 sensor tawg.

Muab ob lub taub hau 2 txuas rau tus pin 19 thiab tus pin 20 txuas ntawm Ntug txuas (saib duab).

Txuas lub micro: ntsis mus rau Ntug txuas thiab koj lub khoos phis tawj.

Npaj software thiab micro: me ntsis raws li tau piav qhia hauv Adafruit micro: ntsis qhia. Nyeem lawv kom zoo.

Nruab ib lub tsev qiv ntawv xav tau rau Arduino IDE.

Qhib tsab ntawv BMP280 txuas rau hauv cov kauj ruam tom ntej.

Txuas lub sensor mus rau Ntug txuas. GND rau 0V, VCC rau 3V, SCL rau tus pin 19, SDA rau tus pin 20.

Tshaj tawm tsab ntawv mus rau micro: me ntsis.

Txheeb xyuas tias lub ntsuas hluav taws xob muab cov ntaub ntawv tsim nyog, qhov ntsuas siab yuav tsum nyob ib puag ncig 1020 hPa, tso tawm ntawm lub ntsuas saib. Hauv qhov xwm txheej, txheeb xyuas cov kab hluav taws xob thiab kev sib txuas ua ntej, tom qab ntawd teeb tsa software, thiab raug.

Tua micro: me ntsis, tshem lub sensor.

Khiav cov hlua jumper ntev los ntawm lub qhov hluav taws xob ntawm rab koob. Yog tias koj yuav tsum tau qhib qhov qhib. Ceev faj kom tsis txhob hnov qab tias cov cables tau puas lawm.

Txuas lub sensor mus rau jumper cables. Txheeb xyuas tias kev sib txuas raug thiab raug. Txuas mus rau micro: me ntsis.

Txheeb xyuas tias lub sensor ua haujlwm raug. Ua tib zoo rub cov kab hluav taws xob, txav lub ntsuas cua mus rau sab saum toj ntawm lub raj mis.

Ntxig lub plunger thiab txav nws me ntsis ntxiv dua qhov chaw so xav tau (100 ml).

Ntxiv cov kua nplaum kub mus rau qhov kawg ntawm lub raj mis thiab txav lub plunger rov qab me ntsis. Txheeb xyuas yog tias lub koob txhaj tshuaj raug kaw cua nruj, txwv tsis pub ntxiv cov kua nplaum kub ntau. Cia txias cov kua nplaum kub.

Rov xyuas dua tias lub sensor ua haujlwm. Yog tias koj txav lub plunger, cov lej hauv tus lej saib thiab micro: ntsis cov duab yuav tsum hloov pauv.

Yog tias xav tau koj tuaj yeem kho qhov ntim hauv lub koob txhaj tshuaj los ntawm kev nyem nws ze lub gasket thiab txav lub plunger.

Kauj Ruam 3: Me ntsis Kev Ntseeg thiab Qee Qhov Kev Ntsuas Zoo

Me ntsis ntawm Kev Ntseeg thiab Qee Qhov Kev Ntsuas Zoo
Me ntsis ntawm Kev Ntseeg thiab Qee Qhov Kev Ntsuas Zoo
Me ntsis ntawm Kev Ntseeg thiab Qee Qhov Kev Ntsuas Zoo
Me ntsis ntawm Kev Ntseeg thiab Qee Qhov Kev Ntsuas Zoo

Nrog cov cuab yeej piav qhia ntawm no, koj tuaj yeem ua pov thawj qhov sib txheeb ntawm kev nrawm thiab siab hauv kev sim yooj yim physics. Raws li lub koob txhaj tshuaj tuaj nrog "ml" -cale rau nws, txawm tias qhov kev sim ntau npaum li cas yooj yim los ua.

Txoj kev xav tom qab nws: Raws li Boyle txoj cai, [Ntim * Siab] yog tus nqi tas li rau cov pa ntawm qhov ntsuas kub.

Qhov no txhais tau tias yog tias koj ntim cov pa N-quav, piv txwv li ntim zaum kawg yog 1/N quav ntawm qhov qub, nws lub siab yuav nce N-quav, xws li: P0*V0 = P1*V1 = cons t. Yog xav paub ntau ntxiv, thov saib ntawm Wikipedia tsab xov xwm ntawm kev cai lij choj roj. Ntawm theem dej hiav txwv, qhov ntsuas siab feem ntau yog nyob ntawm 1010 hPa (hecto Pascal).

Yog li pib ntawm cov ntsiab lus so ntawm xws li V0 = 100 ml thiab P0 = 1000 hPa, kev sib zog ntawm huab cua mus txog 66 ml (piv txwv li V1 = 2/3 * V0) yuav ua rau muaj qhov siab txog 1500 hPa (P1 = 3/2 ntawm P0). Rub lub plunger mus rau 125 ml (5/4 quav ntim) ua rau muaj qhov siab txog 800 hPa (4/5 siab). Cov kev ntsuas yog qhov xav tsis thoob rau qhov zoo li cov cuab yeej yooj yim.

Cov cuab yeej tso cai rau koj kom muaj kev xav haptic ncaj qha ntau npaum li cas lub zog yuav tsum tau ua kom nrawm lossis nthuav dav me me ntawm huab cua hauv lub raj mis.

Tab sis peb kuj tuaj yeem ua qee qhov kev suav thiab txheeb xyuas lawv qhov kev sim. Xav tias peb ua kom huab cua qis dua 1500 hPa, ntawm qhov ntsuas cua hauv qab ntawm 1000 hPa. Yog li qhov sib txawv ntawm qhov siab yog 500 hPa, lossis 50, 000 Pa.

Tam sim no koj tuaj yeem suav lub zog xav tau los tuav lub piston hauv txoj haujlwm ntawd. Muab P = F/A (Siab yog Force faib los ntawm Cheeb Tsam), lossis hloov pauv F = P*A. SI chav rau kev quab yuam yog "Newton" N, rau qhov ntev "Meter" m, thiab 1 Pa yog 1N ib square meter. Rau ib puag ncig piston, thaj chaw tuaj yeem suav nrog siv A = ((d/2)^2)*pi, uas muab 0.00125 square metres rau kuv lub koob txhaj tshuaj. Yog li

50,000, Pa * 0.00125 m^2 = 63 N.

Hauv Ntiaj Teb, 1 N cuam tshuam nrog qhov hnyav ntawm 100 gr, yog li 63 N yog sib npaug rau tuav qhov hnyav ntawm 6.3 kg.

Qhov no tuaj yeem tshawb xyuas tau yooj yim siv qhov ntsuas. Thawb lub koob txhaj tshuaj nrog lub plunger mus rau qhov ntsuas, kom txog thaum ntsuas siab txog 1500 hPa mus txog, tom qab ntawd nyeem qhov ntsuas. Los yog thawb kom txog thaum ntsuas pom txog 6-7 kg, tom qab ntawd nias lub pob "A" thiab nyeem tus nqi tso tawm ntawm micro: ntsis's LED matrix. Raws li nws tau muab tawm, kev kwv yees raws li cov lus suav saum toj no tsis phem. Lub siab me ntsis siab dua 1500 hPa cuam tshuam nrog qhov pom "hnyav" txog 7 kg ntawm lub cev ntsuas (saib cov duab). Koj kuj tseem tuaj yeem tig lub tswv yim no ib puag ncig thiab siv lub cuab yeej los tsim qhov yooj yim digital ntsuas raws kev ntsuas ntsuas.

Thov nco ntsoov tias qhov txwv siab tshaj plaws rau lub ntsuas ntsuas yog li 1540 hPa, yog li txhua qhov siab saum toj no tsis tuaj yeem ntsuas thiab yuav ua rau lub tshuab puas tsuaj.

Ib sab ntawm lub hom phiaj kev kawm, ib tus kuj tseem tuaj yeem siv lub kaw lus rau qee qhov kev thov hauv ntiaj teb tiag, vim nws tso cai rau ntsuas ntsuas cov rog uas tab tom sim txav lub plunger ib txoj kev lossis lwm qhov. Yog li koj tuaj yeem ntsuas qhov hnyav tso rau ntawm lub plunger lossis lub zog cuam tshuam rau ntawm lub plunger. Los yog tsim qhov hloov pauv uas ua rau lub teeb lossis lub suab nrov lossis ua suab nrov tom qab tus nqi pib mus txog Lossis koj tuaj yeem tsim cov cuab yeej siv suab paj nruag uas hloov pauv ntau zaus nyob ntawm lub zog siv zog rau lub plunger. Los yog siv nws ua tus tswj game. Ua koj lub tswv yim thiab ua si!

Kauj Ruam 4: Tsab Ntawv MicroPython

Txuas nrog koj pom kuv cov ntawv BMP280 rau micro: me ntsis. Nws yog qhov muab los ntawm tsab ntawv BMP/BME280 Kuv pom qee qhov Banggood lub vev xaib, ua ke nrog Adafruit lub Microbit lub tsev qiv ntawv. Thawj zaug tso cai rau koj siv Banggood sensor, qhov thib ob ua kom yooj yim tuav ntawm 5x5 LED zaub. Kuv ua tsaug mus rau tus tsim tawm ntawm ob qho tib si.

Los ntawm lub neej ntawd, tsab ntawv nthuav tawm cov txiaj ntsig ntsuas kev ntsuas hauv 5 kauj ruam ntawm micro: me ntsis 5x5 LED zaub, tso cai rau pom kev hloov pauv nrog qeeb me ntsis. Qhov tseeb qhov tseem ceeb tuaj yeem nthuav tawm ua ke ntawm Arduino IDE cov ntawv xov xwm, lossis cov ncauj lus ntxaws ntxaws tuaj yeem nthuav tawm lub ncauj lus ntxaws ntawm Arduino IDE.

Yog tias koj nias lub pob A, ntsuas qhov ntsuas siab tau tshwm ntawm micro: ntsis's 5x5 LED array. Yog tias koj nias lub pob B, qhov ntsuas kub tau tshwm sim. Thaum qhov no tso cai rau nyeem cov ntaub ntawv raug, ua rau qeeb kev ntsuas ntsuas mus.

Kuv paub tseeb tias muaj ntau txoj hauv kev zoo nkauj los npaj cov haujlwm thiab txhim kho tsab ntawv. Kev pab yog txais tos.

#suav nrog xxx

#suav nrog Adafruit_Microbit_Matrix microbit; #define BME280_ADDRESS 0x76 unsigned long int hum_raw, temp_raw, pres_raw; kos npe ntev int t_fine; uint16_t dig_T1; int16_t dig_T2; int16_t dig_T3; uint16_t dig_P1; int16_t dig_P2; int16_t dig_P3; int16_t dig_P4; int16_t dig_P5; int16_t dig_P6; int16_t dig_P7; int16_t dig_P8; int16_t dig_P9; int8_t dig_H1; int16_t dig_H2; int8_t dig_H3; int16_t dig_H4; int16_t dig_H5; int8_t dig_H6; // ntim rau ntsuas qhov tseem ceeb int tus nqi 0; int tus nqi 1; int tus nqi 2; int nqi 3; tus nqi 4; // ------------------------------------------------------- ----------------------------------------------------------------------- ------------------ void setup () {uint8_t osrs_t = 1; // Kev ntsuas kub ntau x 1 uint8_t osrs_p = 1; // Siab oversampling x 1 uint8_t osrs_h = 1; // Vaum kev txheeb xyuas x 1 uint8_t hom = 3; // Hom qub uint8_t t_sb = 5; // Tstandby 1000ms uint8_t lim = 0; // Lim tawm uint8_t spi3w_en = 0; // 3-wire SPI Disable uint8_t ctrl_meas_reg = (osrs_t << 5) | (osrs_p << 2) | hom; uint8_t config_reg = (t_sb << 5) | (lim << 2) | spi3w_en; uint8_t ctrl_hum_reg = osrs_h; pinMode (PIN_BUTTON_A, INPUT); pinMode (PIN_BUTTON_B, INPUT); Serial.begin (9600); // Serial.println ("Kub [deg C]"); // Serial.print ("\ t"); Serial.print ("Siab [hPa]"); // header Wire.begin (); writeReg (0xF2, ctrl_hum_reg); writeReg (0xF4, ctrl_meas_reg); writeReg (0xF5, config_reg); readTrim (); // microbit.begin (); // microbit.print ("x"); ncua (1000); } // ------------------------------------------------------- ----------------------------------------------------------------------- -------- void loop () {double temp_act = 0.0, press_act = 0.0, hum_act = 0.0; kos npe ntev int temp_cal; unsigned ntev int press_cal, hum_cal; tus N; // teeb tsa tus nqi pib rau LED matrix zaub, hauv hPa ob npaug max_0 = 1100; ob max_1 = 1230; ob max_2 = 1360; ob max_3 = 1490; nyeem cov ntaub ntawv (); temp_cal = calibration_T (temp_raw); press_cal = calibration_P (pres_raw); hum_cal = calibration_H (hum_raw); temp_act = (ob npaug) temp_cal / 100.0; press_act = (ob npaug) press_cal / 100.0; hum_act = (ob npaug) hum_cal / 1024.0; microbit.clear (); // pib dua LED matrix /* Serial.print ("XOV XWM:"); Serial.println (nias_act); Serial.print ("hPa"); Serial.print ("TEMP:"); Serial.print ("\ t"); Serial.println (temp_act); */ yog (! digitalRead (PIN_BUTTON_B)) {// tso tawm qhov tseem ceeb hauv tus lej qeeb ntsuas lub voj voog microbit.print ("T:"); microbit.print (temp_act, 1); microbit.print ("'C"); // Serial.println (""); } lwm tus yog (! digitalRead (PIN_BUTTON_A)) {microbit.print ("P:"); microbit.print (nias_act, 0); microbit.print ("hPa"); } lwm tus {// tso tawm qhov ntsuas siab raws li pixels lossis kab hauv qee qib // 5 cov kauj ruam: 1490 hPa // thresholds txhais los ntawm max_n qhov tseem ceeb yog (press_act> max_3) {(N = 0); // sab saud} lwm qhov yog (press_act> max_2) {(N = 1); } lwm yog (press_act> max_1) {(N = 2); } lwm yog (press_act> max_0) {(N = 3); } lwm {(N = 4); // pib kab} // Serial.println (N); // rau kev txhim kho lub hom phiaj // microbit.print (N); // as Line // microbit.drawLine (N, 0, 0, 4, LED_ON); // hloov qhov tseem ceeb mus rau kab tom ntej tus nqi 4 = tus nqi 3; tus nqi 3 = tus nqi 2; tus nqi 2 = tus nqi 1; tus nqi 1 = tus nqi 0; tus nqi 0 = N; // kos duab, kab los ntawm kab microbit.drawPixel (0, value0, LED_ON); // raws li Pixel: kem, kab. 0, 0 sab laug kaum sab sauv microbit.drawPixel (1, value1, LED_ON); microbit.drawPixel (2, tus nqi 2, LED_ON); microbit.drawPixel (3, value3, LED_ON); microbit.drawPixel (4, value4, LED_ON); } // xa cov ntaub ntawv mus rau tus saib xyuas thiab cov phiaj xwm phiaj xwm // Serial.println (press_act); // xa tus nqi (s) mus rau qhov chaw nres nkoj rau cov lej lej, xaiv tau

Serial.print (nias_act); // xa tus nqi mus rau qhov chaw nres nkoj txuas rau cov phiaj xwm

// kos cov kab cim qhia thiab kho kom pom ntau yam Serial.print ("\ t"); Serial.print (600); Serial.print ("\ t"); Serial.print (1100), Serial.print ("\ t"); Serial.println (1600); ncua (200); // Ntsuas peb zaug ib pliag} // ---------------------------------------- ----------------------------------------------------------------------- ----------------------------------------------------------------------- - // cov hauv qab no xav tau rau bmp/bme280 sensor, khaws raws li nws tsis muaj dab tsi readTrim () {uint8_t cov ntaub ntawv [32], i = 0; // Kho 2014/Wire.beginTransmission (BME280_ADDRESS); Hlau.write (0x88); Wire.endTransmission (); Wire.requestFrom (BME280_ADDRESS, 24); // Kho 2014/thaum (Wire.available ()) {data = Wire.read (); kuv ++; } Wire.beginTransmission (BME280_ADDRESS); // Ntxiv 2014/Wire.write (0xA1); // Ntxiv 2014/Wire.endTransmission (); // Ntxiv 2014/Wire.requestFrom (BME280_ADDRESS, 1); // Ntxiv 2014/cov ntaub ntawv = Wire.read (); // Ntxiv 2014/i ++; // Ntxiv 2014/Wire.beginTransmission (BME280_ADDRESS); Hlau.write (0xE1); Wire.endTransmission (); Wire.requestFrom (BME280_ADDRESS, 7); // Kho 2014/thaum (Wire.available ()) {data = Wire.read (); kuv ++; } dig_T1 = (data [1] << 8) | cov ntaub ntawv [0]; dig_P1 = (data [7] << 8) | cov ntaub ntawv [6]; dig_P2 = (cov ntaub ntawv [9] << 8) | cov ntaub ntawv [8]; dig_P3 = (data [11] << 8) | cov ntaub ntawv [10]; dig_P4 = (data [13] << 8) | cov ntaub ntawv [12]; dig_P5 = (data [15] << 8) | cov ntaub ntawv [14]; dig_P6 = (data [17] << 8) | cov ntaub ntawv [16]; dig_P7 = (cov ntaub ntawv [19] << 8) | cov ntaub ntawv [18]; dig_T2 = (cov ntaub ntawv [3] << 8) | cov ntaub ntawv [2]; dig_T3 = (cov ntaub ntawv [5] << 8) | cov ntaub ntawv [4]; dig_P8 = (cov ntaub ntawv [21] << 8) | cov ntaub ntawv [20]; dig_P9 = (cov ntaub ntawv [23] << 8) | cov ntaub ntawv [22]; dig_H1 = cov ntaub ntawv [24]; dig_H2 = (cov ntaub ntawv [26] << 8) | cov ntaub ntawv [25]; dig_H3 = cov ntaub ntawv [27]; dig_H4 = (data [28] << 4) | (0x0F & cov ntaub ntawv [29]); dig_H5 = (cov ntaub ntawv [30] 4) & 0x0F); // Txhim kho 2014/dig_H6 = cov ntaub ntawv [31]; // Kho 2014/} tsis muaj dab tsi sauReg (uint8_t reg_address, uint8_t cov ntaub ntawv) {Wire.beginTransmission (BME280_ADDRESS); Hlau.write (reg_address); Wire.write (cov ntaub ntawv); Wire.endTransmission (); }

void readData ()

{int kuv = 0; uint32_t cov ntaub ntawv [8]; Wire.beginTransmission (BME280_ADDRESS); Hlau.write (0xF7); Wire.endTransmission (); Wire.requestFrom (BME280_ADDRESS, 8); thaum (Wire.available ()) {data = Wire.read (); kuv ++; } pres_raw = (cov ntaub ntawv [0] << 12) | (cov ntaub ntawv [1] 4); temp_raw = (cov ntaub ntawv [3] << 12) | (cov ntaub ntawv [4] 4); hum_raw = (data [6] << 8) | cov ntaub ntawv [7]; }

kos npe ntev int calibration_T (kos npe ntev int adc_T)

{kos npe ntev int var1, var2, T; var1 = (((adc_T >> 3) - ((kos npe ntev int) dig_T1 11; var2 = ((((adc_T >> 4) - ((kos npe ntev int) dig_T1)) * ((adc_T >> 4) - ((kos npe ntev int) dig_T1))) >> 12) * ((kos npe ntev int) dig_T3)) >> 14; t_fine = var1 + var2; T = (t_fine * 5 + 128) >> 8; rov qab T;} unsigned ntev int calibration_P (kos npe ntev int adc_P) {kos npe ntev int var1, var2; unsigned ntev int P; var1 = (((kos npe ntev int) t_fine) >> 1) - (kos npe ntev int) 64000; var2 = (((var1 >> 2) * (var1 >> 2)) >> 11) * ((kos npe ntev int) dig_P6); var2 = var2 + ((var1 * ((kos npe ntev int) dig_P5)) 2) + (((kos npe ntev int) dig_P4) 2) * (var1 >> 2)) >> 13)) >> 3) + (((kos npe rau ntev) dig_P2) * var1) >> 1)) >> 18; var1 = ((((32768+var1)))*((kos npe ntev int) dig_P1)) >> 15); yog (var1 == 0) {rov qab 0; } P = (((unsigned ntev int) (((kos npe ntev int) 1048576) -adc_P)-(var2 >> 12)))*3125; yog (P <0x80000000) {P = (P << 1) / ((unsigned ntev int) var1); } lwm {P = (P / (unsigned ntev int) var1) * 2; } var1 = (((kos npe ntev int) dig_P9) * ((kos npe ntev int) (((P >> 3) * * (P >> 3)) >> 13))) >> 12; var2 = (((kos npe ntev int) (P >> 2)) * ((kos npe ntev int) dig_P8)) >> 13; P = (unsigned ntev int) ((kos npe ntev int) P + ((var1 + var2 + dig_P7) >> 4)); rov P; } unsigned ntev int calibration_H (kos npe ntev int adc_H) {kos npe ntev int v_x1; v_x1 = (t_fine - ((kos npe ntev int) 76800)); v_x1 = ((((adc_H << 14) -((kos npe ntev int) dig_H4) 15) * ((((((v_x1 * ((kos npe ntev int) dig_H6)) >> 10) * (((v_x1 * ((kos npe ntev int) dig_H3)) >> 11) + ((kos npe ntev int) 32768))) >> 10) + ((kos npe ntev int) 2097152)) * ((kos npe ntev int) dig_H2) + 8192) >> 14)); v_x1 = (v_x1 - ((((((v_x1 >> 15) * * (v_x1 >> 15)) >> 7) * ((kos npe ntev int) dig_H1)) >> 4)); v_x1 = (v_x1 419430400? 419430400: v_x1); rov qab (unsigned ntev int) (v_x1 >> 12);}

Kauj ruam 5: MakeCode/JavaScript Scripts

MakeCode/JavaScript Scripts
MakeCode/JavaScript Scripts

Tsis ntev los no Pimoroni tau tshaj tawm cov enviro: me ntsis, uas los nrog BMP280 lub ntsuas siab, lub teeb/xim xim thiab MEMS lub microphone. Lawv kuj muab MicroPython thiab MakeCode/JavaScript lub tsev qiv ntawv.

Kuv siv tom qab los sau ib tsab ntawv MakeCode rau lub ntsuas siab. Cov ntawv hex sib xws tuaj yeem theej ncaj qha rau koj lub micro: ntsis. Cov cai tau tshwm sim hauv qab no thiab tuaj yeem hloov kho siv tus kho MakeCode online.

Nws yog qhov hloov pauv ntawm tsab ntawv rau micro: me ntsis dhia-o-meter. Los ntawm lub neej ntawd nws qhia txog qhov sib txawv raws li kab duab kab. Nias khawm A teeb tsa qhov siab siv, nyem khawm B qhia qhov sib txawv ntawm qhov tseeb thiab siv qhov siab hauv hPa.

Ntxiv rau qhov yooj yim barcode version koj tseem pom "X", crosshair version thiab "L" version, npaj kom nyeem tau yooj yim dua.

cia Kab = 0

let remain = 0 let Row = 0 let Meter = 0 let Delta = 0 let Ref = 0 let Is = 0 Is = 1012 basic.showLeds (` # # # # # # …. # #. #. #…. # # # # # # # `) Ref = 1180 basic.clearScreen () basic.forever (() => {basic.clearScreen () yog (input.buttonIsPressed (Button. A)) {Ref = envirobit.getPressure () basic.showLeds (` #. #. #. #. #. #. #. #. #. #. #. #. #. #. #. #` `basic.pause (1000)} lwm tus yog (input.buttonIsPressed (Button B.)) {basic.showString ("" + Delta + "hPa") basic.pause (200) basic.clearScreen ()} lwm qhov {Yog = envirobit.getPressure () Delta = Yog - Ref Meter = Math.abs (Delta) yog (Meter> = 400) {Kab = 4} lwm qhov yog (Meter> = 300) {Kab = 3} lwm tus yog (Meter> = 200) {Kab = 2} lwm qhov yog (Meter> = 100) {Kab = 1} lwm {Kab = 0} nyob = Meter - Kab * 100 yog (tseem nyob = = 80) {Kab ntawv = 4} lwm yog (tseem nyob> = 60) {Kab = 3} lwm yog (nyob> = 40) {Kab = 2 } lwm yog (tseem nyob> = 20) {Kab ntawv = 1} lwm {Column = 0} rau (cia ColA = 0; ColA <= Column; ColA ++) {led.plot (ColA, Row)} pib.pause (500)}})

Pom zoo: