Cov txheej txheem:

Raspberry PI Ntau I2C Devices: 3 Cov Kauj Ruam
Raspberry PI Ntau I2C Devices: 3 Cov Kauj Ruam

Video: Raspberry PI Ntau I2C Devices: 3 Cov Kauj Ruam

Video: Raspberry PI Ntau I2C Devices: 3 Cov Kauj Ruam
Video: I2C Part 2 - Build a I2C Sensor 2024, Kaum ib hlis
Anonim
Raspberry PI Ntau I2C Devices
Raspberry PI Ntau I2C Devices
Raspberry PI Ntau I2C Devices
Raspberry PI Ntau I2C Devices

Tsis txaus siab vim tias koj tsis tuaj yeem siv ntau ntawm tib I2C cov cuab yeej hauv koj txoj haujlwm. Tsis tas yuav siv qeeb multiplexers. Qhov tseeb raspbian kernel txhawb kev tsim ntau I2C busses siv GPIO pins. Cov tshuaj no yog nrawm heev.

Kauj Ruam 1: Qee Cov Plhaub Comands

Qee lub Plhaub Comands
Qee lub Plhaub Comands

Txuas ib qho ntawm koj lub cuab yeej i2c thaum koj raspberry pi yog ntawm, pib koj raspberry pi thiab khiav

sudo i2cdetect -y 1

Koj yuav pom lub rooj zoo li hauv daim duab txuas. Kuv tau xa BMP280 qhov kub thiab txias siab ntsuas. Qhov chaw nyob i2c yog 0x76 raws li cov lus. Nco qhov chaw nyob no.

Ua qhov no rau tag nrho koj cov cuab yeej i2c.

Kauj Ruam 2: Case One: I2c Devices Muaj Tib Qhov Chaw Nyob

Case One: I2c Devices Muaj Tib Qhov Chaw Nyob
Case One: I2c Devices Muaj Tib Qhov Chaw Nyob

Qhov no ib txwm muaj teeb meem teeb meem. Lub tsheb npav i2c tuaj yeem siv ntau yam khoom siv, tab sis lawv yuav tsum muaj qhov chaw nyob sib txawv i2c. Qee cov khoom siv i2c muaj cov dhia dhia los teeb tsa lwm qhov chaw nyob i2c, tab sis ntau tus tsis ua. Hauv qhov no koj tuaj yeem siv i2c multiplexer (kho vajtse) tig lub i2c SDA (Cov Ntaub Ntawv) thiab SCL (Clock) lossis koj tuaj yeem tsim lub npav i2c ntxiv lossis ntau dua.

Kuv yuav tsim ob lub npav ntxiv, nl npav 3 thiab 4

Qhib cli thiab khiav

cd /pib

sudo nano teeb tsa.txt

Ntxiv cov kab hauv qab no, nyiam dua hauv ntu uas spi thiab i2c tau qhib.

dtoverlay = i2c-gpio, npav = 4, i2c_gpio_delay_us = 1, i2c_gpio_sda = 23, i2c_gpio_scl = 24

Kab ntawv no yuav tsim ib lub npav i2c ntxiv (tsheb npav 4) ntawm GPIO 23 raws li SDA thiab GPIO 24 raws li SCL (GPIO 23 thiab 24 yog qhov ua tsis tau)

Kuj ntxiv cov kab hauv qab no los tsim i2c npav 3

dtoverlay = i2c-gpio, npav = 3, i2c_gpio_delay_us = 1, i2c_gpio_sda = 17, i2c_gpio_scl = 27

GPIO 17 yuav yog SDA thiab GPIO 27 yuav yog SCL rau i2c npav 4.

Tipe tswj X kom tawm mus.

Nco tseg ntawm Tus Npav Npav Npav thiab xaj:

Tsis txhob siv tsheb npav 0 thiab 2, nws yog siv rau lwm yam hauv pawg thawj coj zoo li eprom ntawm lub kaus mom thiab lwm yam

Rau lub Plaub Hlis 2019 raspbian tso tawm:

Koj yuav tsum ib txwm pib nrog lub npav loj tshaj (Tsheb 4 hauv qhov no) hauv koj qhov kev teeb tsa.txt thiab ua haujlwm dhau mus rau lub npav qis tshaj (tsheb npav 3).

Lub tsheb npav qis tshaj yuav tsum yog npav 3

Yog tias koj xav tau 5 lub tsheb npav ntxiv, cov tsheb npav yuav tsum yog ob qho ntawm 7, 6, 5, 4, 3

Qhov teeb meem ntawm kev xaj tsheb npav tsis nyob ntawd thaum Phau Ntawv Qhia no tau xub sau tseg. Nws zoo li kev hloov pauv tau ua rau lub ntsiav.

Kaw koj tus PI, hloov nws ntawm. Txuas koj lub cuab yeej i2c mus rau npav 4 (SDA rau GPIO 23 thiab SCL rau GPIO 24) thiab lwm qhov rau i2c npav 3 (SDA rau GPIO 17 thiab SCL rau GPIO 27).

Hloov rau pi.

Khiav:

sudo i2cdetect -l (Cov Ntaub Ntawv L)

Tam sim no koj yuav pom tias i2c npav 3 thiab 4 kuj tau teev tseg. Kuj khiav:

sudo i2cdetect -y 3

sudo i2cdetect -y 4

Tam sim no koj tuaj yeem siv koj lub sensor hauv koj cov lus programming. Nco ntsoov qhia qhov tseeb i2c busses.

Txuas yog qhov piv txwv rau qhov nrov BMP280 Kub thiab Siab sensor. Tsis muaj multiplexer tuaj yeem nyeem 2 BMP280s qhov nrawm no.

Ib qho piv txwv ntawm 2 Sensirion SDP 810 sensors kuj tseem txuas nrog. Ib zaug ntxiv ua haujlwm tau nrawm dua li lub tshuab multiplexer kuv tau siv yav dhau los

Kuv tsim cov nab npawb nab npawb los nyeem ob qhov tshiab BMP388s los ntawm adafruit.

Kuv kuj tseem tuaj yeem ntxiv lwm qhov ntsuas pom yav tom ntej rau

Kauj Ruam 3: Rooj Plaub 2: Qhov Chaw I2c Txawv

Yooj yim. i2c yog bus. Lub tsheb npav purpouse yog sib tham nrog ntau yam khoom siv. Txuas cov cuab yeej txuas mus rau tib lub tsheb npav i2c. Koj tuaj yeem siv npav npav.

Khiav:

sudo i2cdetect -y 1

Koj yuav pom cov cuab yeej teev tseg.

Pom zoo: