2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

STマイクロの6軸IMUセンサーLSM6DSV16Xを使ってみました。
作成したライブラリ等も載せています。

使用した部品

・6軸IMUセンサーモジュールAE-LSM6DSV16X
・ESP32C3 SuperMini

開発環境

エディタ: Visual Studio Code
拡張機能: PlatformIO

ライブラリ

作成したライブラリはGitHubに載せています。

サンプルコード

Arduino IDE用のサンプルコードです。

#include <Arduino.h>
#include "LSM6DSV16X.h"

#define IMU_CS 10
#define IMU_SPI_FREQ 10000000
LSM6DSV16X IMU(&SPI);

static float Accel[3];
static float Gyro[3];

void setup(){
    Serial.begin(115200);
    
    pinMode(IMU_CS, OUTPUT);
    digitalWrite(IMU_CS, HIGH);
    SPI.begin();

    IMU.Init(IMU_CS, IMU_SPI_FREQ);
    IMU.SetAccelScale(ACCEL_SCALE_8G);
    IMU.SetGyroScale(GYRO_SCALE_500DPS);
    
}

void loop(){
    IMU.ReadAccel(Accel);
    IMU.ReadGyro(Gyro);
    Serial.printf("ax: %#10.6f, ay: %#10.6f, az: %#10.6f, gx: %#10.6f, gy: %#10.6f, gz: %#10.6f\r\n", Accel[0], Accel[1], Accel[2], Gyro[0], Gyro[1], Gyro[2]);
    delay(100);
}

VScodeとPlatformIOを使用する場合はplatformio.iniに以下の設定を書いてください。

[env:esp32c3_supermini]
platform = espressif32
board = esp32-c3-devkitm-1
framework = arduino

board_upload.flash_size = 4MB
board_build.partitions = huge_app.csv
board_upload.maximum_size = 3145728

upload_speed = 921600
monitor_speed = 115200
build_flags = -D ARDUINO_USB_MODE=1, -D ARDUINO_USB_CDC_ON_BOOT=1

免責事項

参考にしていただくのは嬉しいですが、その結果損害等が生じても責任は負えません。
自己責任でお願いします。

最後に

最後までお読みいただきありがとうございました。
もし内容に誤り等がありましたらXの方で教えていただけると助かります。
Xアカウント: nichicon 𝕏(@_electro_master)

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?