Cov txheej txheem:

Chav Huab Cua Hauv Chav Siv Arduino & BME280: 4 Cov Kauj Ruam
Chav Huab Cua Hauv Chav Siv Arduino & BME280: 4 Cov Kauj Ruam

Video: Chav Huab Cua Hauv Chav Siv Arduino & BME280: 4 Cov Kauj Ruam

Video: Chav Huab Cua Hauv Chav Siv Arduino & BME280: 4 Cov Kauj Ruam
Video: Nco Koj Tshaj - Chav Mib Yaj (Txhawb Kev Xav Txhab Kev Npau Suav | เติมความฝัน สานความคิด) 2024, Hlis ntuj nqeg
Anonim
Chav Chaw Huab Cua Siv Arduino & BME280
Chav Chaw Huab Cua Siv Arduino & BME280

Yav dhau los kuv tau qhia qhov chaw nres tsheb huab cua yooj yim uas qhia qhov Kub thiab Vaum ntawm thaj chaw. Qhov teeb meem nrog nws yog tias nws yuav siv sijhawm hloov kho thiab cov ntaub ntawv tsis raug. Hauv qhov kev qhia no peb yuav ua ib qho kev tshuaj xyuas huab cua sab hauv tsev uas tuaj yeem pab tau rau kev khaws cia qhov ntsuas kub, av noo thiab siab nyob hauv chav.

Yog li tsis tas yuav nkim sijhawm ntxiv, cia peb pib ua.

Kauj Ruam 1: Yuav Tsum Tau:

Yuav tsum
Yuav tsum
Yuav tsum
Yuav tsum
Yuav tsum
Yuav tsum
Yuav tsum
Yuav tsum

Nov yog cov npe ntawm ntu peb yuav siv rau kev tsim.

  • GY-BME280 Sensor …………… (Amazon US / Amazon EU)
  • Arduino UNO …………………….. (Amazon US / Amazon EU)
  • Arduino Pro Mini ………………… (Amazon Asmeskas / Amazon EU)
  • OLED 128*64 Zaub …………. (Amazon US/ Amazon EU)
  • Breadboard nrog Jumpers ……. (Amazon US / Amazon EU)

Nrog rau cov khoom siv saum toj no, peb kuj xav tau qee lub tsev qiv ntawv ib yam:

  • Arduino IDE Cov
  • Adafruit_BME280.h Lub Tsev Qiv Ntawv
  • Adafruit_SH1106.h Lub Tsev Qiv Ntawv
  • Adafruit_GFX.h Lub Tsev Qiv Ntawv

Kauj Ruam 2: Kev Sib Txuas:

Kev Sib Txuas
Kev Sib Txuas
Kev Sib Txuas
Kev Sib Txuas
Kev Sib Txuas
Kev Sib Txuas

Peb yuav siv I2C txuas rau kev sib txuas lus ntawm cov khoom siv. I2C siv 2 pins Serial Data (SDA) thiab Serial Clock (SCL) los sib txuas lus. Yog li hauv kev sib txuas Kuv tau txuas cov pins hauv kev teeb tsa hauv qab no:

  • SDA = A5
  • SCL = A4
  • GND = GND
  • VCC = 3.3v

Cov kev sib txuas zoo ib yam rau Arduino UNO thiab Pro Mini.

Kauj ruam 3: Coding:

Coding
Coding
Coding
Coding

Ua ntej rub tawm cov cai, peb yuav tsum teeb tsa lub tsev qiv ntawv uas xav tau.

Hauv kab ntawv tshawb nrhiav sau lub npe ntawm cov tsev qiv ntawv thiab teeb tsa txhua tus los ntawm ib tus.

Tom qab teeb tsa cov tsev qiv ntawv rov pib dua IDE.

NCO TSEG: Cov tsev qiv ntawv thiab cov cai yog rau Sensor thiab OLED module Kuv tau siv (Cov kab ntawv txuas hauv kauj ruam dhau los). Yog tias koj siv lwm cov qauv, xa cov ntaub ntawv txheeb xyuas kom paub siv cov tsev qiv ntawv twg.

Sau cov cai hauv qab no hauv cov ntawv tshiab hauv Arduino IDE:

#suav nrog

#suav nrog #suav nrog #suav nrog #define OLED_RESET 4 Adafruit_SH1106 zaub (OLED_RESET); Adafruit_BME280 bme; teeb tsa tsis muaj dab tsi () {Serial.begin (9600); display.begin (SH1106_SWITCHCAPVCC, 0x3C); display.setFont (& FreeSerif9pt7b); display.display (); ncua (2000); display.clearDisplay (); yog (! bme.begin (0x76)) {Serial.println ("Tsis tuaj yeem pom qhov ntsuas pom BME280 siv tau, tshawb xyuas thaiv!"); thaum (1); }} void loop () {display.clearDisplay (); Serial.print ("Kub ="); Serial.print (bme.readTemperature ()); // luam tawm hauv * C //Serial.print (bme.readTemperature () * 9 /5 + 32); // luam tawm hauv *F Serial.println (" *C"); display.setTextSize (1); display.setTextColor (WHITE); display.setCursor (0, 15); display.print ("Temp:"); display.print ((int) bme.readTemperature ()); // luam tawm hauv * C //display.print (bme.readTemperature () * 9 /5 + 32); // luam tawm hauv *F display.println (" *C"); display.display (); Serial.print ("Siab ="); Serial.print (bme.readPressure ()/100.0F); Serial.println ("hPa"); display.setTextSize (1); display.setTextColor (WHITE); display.print ("Nias:"); display.print (bme.readPressure ()/100.0F); display.println ("Pa"); display.display (); Serial.print ("Vaum ="); Serial.print (bme.readHumidity ()); Serial.println ("%"); display.setTextSize (1); display.setTextColor (WHITE); display.print ("Hum:"); display.print ((int) bme.readHumidity ()); display.println ("%"); display.display (); Serial.println (); ncua (1000); }

Txuas lub arduino rau koj lub khoos phis tawj, xaiv qhov chaw nres nkoj raug thiab nyem rau upload. Tom qab ob peb feeb koj yuav tsum pom cov zaub qhib.

Kauj Ruam 4: Lus Cim Kawg:

Lus Cim Kawg
Lus Cim Kawg

Cov zaub yuav qhia Kev Kub, Vaum thiab Huab Cua Siab. Koj tseem tuaj yeem pom cov ntaub ntawv hauv Serial Monitor. Koj tuaj yeem hloov pauv cov cai lossis tsim raws li koj xav tau. Hauv qhov kev qhia tom ntej no kuv yuav ua qhov Circuit Court no ntawm PCB thiab tsim lub thaiv rau nws. Nco ntsoov koj ua raws rau qhov hloov tshiab ntxiv.

Yog tias koj txaus siab rau neeg hlau thiab xav ua tus neeg hlau yooj yim, Txheeb xyuas kuv li ebook "Mini WiFi Robot". Nws muaj cov lus qhia ib qib zuj zus los tsim cov neeg hlau yooj yim uas tuaj yeem tswj hwm WiFi network.

Vam tias qhov kev qhia no yog xov xwm. Yog tias koj muaj kev tsis ntseeg, thov nug hauv cov lus.

Pom zoo: