BeagleBone BlackでC言語を使用してVL53L0X(TOF)センサーI2Cアドレスを変更する方法

BeagleBone BlackでC言語を使用してVL53L0X(TOF)センサーI2Cアドレスを変更する方法

目的:BeagleBone Black Board(Debian OS)でC言語を使用して、I2C通信を使用して4つのVL53L0X(TOF)センサーのデータを読み取る。

単一のVL53L0X(TOF)センサー用のcコードを実装しました。https://github.com/bitbank2/VL53L0X

上記のリンクから:


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <tof.h> // time of flight sensor library
int main(int argc, char *argv[])
{
    int i;
    int iDistance;
    int model, revision;

    // For Raspberry Pi's, the I2C channel is usually 1
    // For other boards (e.g. OrangePi) it's 0
    i = tofInit(2, 0x29, 1); // 2=I2CBus, 0x29 i2c slave address, 1 = long range.
    
    if (i != 1)
    {
        return -1; // problem - quit
    }
    printf("VL53L0X device successfully opened.\n");
    i = tofGetModel(&model, &revision);
    usleep(50000); // 50ms
    printf("Model ID =%d,\n", model);
    printf("Revision ID =%d,\n", revision);

    for (i=0; i<1200; i++) // read values 20 times a second for 1 minute
    {
        iDistance = tofReadDistance();
        if (iDistance < 4096) // valid range?
            printf("Distance = %dmm\n", iDistance);
        usleep(50000); // 50ms
    }

return 0;
} /* main() */

しかし、私の申請書は4VL53L0X(TOF)センサー。

または、cコーディングを使用してソリューションを取得する別の方法を使用します。

ありがとうございます。

ベストアンサー1

おすすめ記事