Cov txheej txheem:

Arduino Altimeter Siv BMP thiab SPI lossis I2C OLED: 5 Kauj Ruam
Arduino Altimeter Siv BMP thiab SPI lossis I2C OLED: 5 Kauj Ruam

Video: Arduino Altimeter Siv BMP thiab SPI lossis I2C OLED: 5 Kauj Ruam

Video: Arduino Altimeter Siv BMP thiab SPI lossis I2C OLED: 5 Kauj Ruam
Video: MS5611 Barometer/Altimeter Tutorial with Arduino || BME280 vs MS5611 Comparison 2024, Kaum ib hlis
Anonim
Arduino Altimeter Siv BMP thiab SPI lossis I2C OLED
Arduino Altimeter Siv BMP thiab SPI lossis I2C OLED

Tau ntev kuv tau tshawb nrhiav qhov ntsuas kub thiab ntsuas kub siv ib qho ntsuas thiab tso tawm rau SPI raws li OLED. Raws li kuv nrhiav tsis tau ib yam meej, xav tias kuv yuav tsim kuv tus kheej siv U8glib lub tsev qiv ntawv. Muaj ib qho kev qhia hauv youtube tab sis kuv yeej ntxub cov vis dis aus qhia, Kuv nyiam cov ntawv nrog cov lus qhia ncaj qha thiab tsis muaj kev sib txuas ua lag luam.

Kauj Ruam 1: Thawj Yam Ua Ntej

Ua ntej ua txoj haujlwm no, Kuv xav kom koj ua kom tiav SSD1306/OLED qhia rau I2C lossis SPI (qhov twg koj xav siv). Qhov no yuav ua kom ntseeg tau tias koj paub yuav ua li cas txuas/xaim koj cov zaub, nrog rau koj cov zaub ua haujlwm. Ua cov lus qhia adafruit thiab/lossis u8glib piv txwv qhia. Peb yuav siv u8glib ntawm no yog li pom zoo rau cov neeg siv qib siab.

Kauj ruam 2: Tsim Nyog Hardware

Tsim Nyog Hardwares
Tsim Nyog Hardwares

1. Arduino UNO lossis Nano lossis zoo sib xws.

2. BMP085 lossis BMP180 Barometric Siab Sensor.

3. SSD1306 I2C lossis SPI Bus (Configurable in sketch).

4. Jumper xov hlau thiab daim ntawv qhia zaub mov lossis vero board rau kev sib txuas.

Kauj Ruam 3: Arduino IDE Libraries for Compiling

1. Wire.h

2. Adafruit_BMP085.h (yuav ua haujlwm rau BMP180 ib yam)

3. U8glib.h

Kauj Ruam 4: Kev Sib Txuas

Kev sib txuas zoo ib yam rau ob qho tib si I2C thiab SPI OLED zaub. Tsuas yog kev sib txuas los tso saib yuav txawv.

1. BMP rau Arduino:

VCC> 3.3V

GND> Hauv av

SCL> A5/SCL

SDA> A4/SDA

SCK = 12, MOSI = 11, CS = 10, A0 = 9, Pib dua = 13

2. SPI OLED rau Arduino

VDD> 5V

GND> Hauv av

SCK/D0> D12 (Digital 12)

SDA/D1/Mosi> D11

CS/Chip Xaiv> D10

A0/DC> D9

RES/Pib dua> D13

(Yog tias koj tus SPI OLED tsis muaj Pib dua tus pin ntawm nws tsuas yog tshem tawm pib dua thiab rov pib dua tus pin los ntawm daim duab kos xaiv xaiv tsis)

3. I2C OLED

Ib yam li BMP thaiv, lawv siv tib lub chaw nres nkoj thiab hom tsheb npav.

Kauj ruam 5: Sketch Uploading

Zoo nkauj ncaj. Tsuas yog rub tawm cov ntawv zip thiab qhib hauv Arduino IDE. Txhua yam yog teeb tsa hauv daim duab. SPI OLED cov neeg siv tsuas tuaj yeem tso cov duab kos yam tsis muaj kev kho thiab nws yuav ua haujlwm. Rau I2C OLED cov neeg siv, tsuas yog tsis txaus siab rau koj lub npe zaub/xaiv los ntawm Zaub Xaiv xaiv ntawm daim duab kos, thiab tawm tswv yim thiab kaw SPI Display qauv/ntsuas kom tsis siv SPI OLED.

SPI Zaub Parameter:

// U8GLIB_SSD1306_128X64 u8g (12, 11, 10, 9, 13); // SW SPI Com: SCK = 12, MOSI = 11, CS = 10, A0 = 9, Pib dua = 13

I2C Zaub Parameter:

// U8GLIB_SSD1306_128X64 u8g (U8G_I2C_OPT_NO_ACK); // Zaub uas tsis xa AC

Txhawm rau ua kom muaj qhov ntsuas, tsuas yog tshem tawm // kos npe thaum pib kom tsis tawm lus nws. Nco ntsoov tias tsuas yog ib qho zaub raug xaiv/tsis hais tawm.

Cov lus qhia:

1. BMP sensors ua rau cua, cua sov thiab teeb pom kev zoo. Nco ntsoov npog nws, cov txiaj ntsig zoo tshaj plaws tau ua tiav los ntawm kev ua Npuas Ua Ntej nrog qhov cua nkag tau zoo rau nws. Tej yam zoo li daim kab xev yuav ua haujlwm ib yam tab sis yuav tsis raug.

2. BMP feem ntau siv 3.3V tshwj tsis yog koj lub chaw tsim khoom hais lwm yam. OLED yuav ua haujlwm los ntawm 3.3v-5.5V (4-5V pom zoo)

3. Teeb tsa txhua yam ntawm daim ntawv qhia zaub mov ua ntej pom zoo.

4. Yog tias koj yog tus tshiab rau OLED thov sim ua cov khoom yooj yim ua ntej xws li cov ntawv thiab dummy buffers kom paub tseeb tias koj cov zaub ua haujlwm nrog rau koj kev sib txuas raug.

Pom zoo: