1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

レーザー測距センサモジュール VL53L0XをArduinoで使う

Last updated at Posted at 2025-03-31

STマイクロ社モジュールの使い方備忘録

測定範囲:3~200cm
レーザー:940nm Class 1

商品情報はこちらから 秋月電子通商のページ
マニュアル(PDF)はこちら 秋月電子通商のマニュアル

配線は以下の通りです。

No sensor arduino
1 赤 電源3.3~5V 5V
2 黒 GND GND
3 黄 SDA I2C data SDA
4 緑 SCL I2c clock SCL
5 青 Shutdown signal -
6 紫 GPIO output -

laser_sensor.jpg
Arduino_uno.JPG
Arduino_uno_5V_GND.JPG

Arduino IDEを起動する
「ツール」「ボード」でArduino Uno を選択
「ポート」で COM# (#は数字)を確認

ソフトはpolulu のGithubを利用
pololu/vl53l0x-arduino
(*) Arduino IDE versions 1.6 以上

ソフトの準備

  1. Githubの上記のサイトで、<> Code を右クリックして Download ZIP で zipファイルを保存
  2. Arduino IDEで「スケッチ」「ライブラリを使用」「ライブラリをインストール」でzipファイルを登録
    これは、最初の1回目だけでOK
  3. 「ファイル」「スケッチの例」「VL53L0X」で「Continuous」を選択
  4. 以下のスケッチが表示される
  5. startContinuous(100) の100を測定間隔に応じてセットする(100 ms)
  6. 必要に応じて、名前をつけてスケッチを保存
VL53L0X sketch example
#include <Wire.h>  / I2C library
#include <VL53L0X.h> / VL53L0X library

VL53L0X sensor;

void setup()
{
  Serial.begin(9600); / connection rate 9600 bps
  Wire.begin(); / I2C start

  sensor.setTimeout(500); 500ms time-out
  if (!sensor.init())
  {
    Serial.println("Failed to detect and initialize sensor!");
    while (1) {}
  }

  // set time interval in millisecond
  sensor.startContinuous(100);
}

void loop()
{
  Serial.print(sensor.readRangeContinuousMillimeters());
  if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); }

  Serial.println();
}

「ㇾ」をクリックで検証(コンパイル)
「⇒」をクリックで検証+マイコンボード書き込み

「ツール」「シリアルモニタ」で出力表示(単位:mm)

シリアルモニタではなく、Tera Term で読み込む場合

  1. Tera Term を起動
  2. 「TCP/IP」 ではなく 「シリアル」を選択
  3. ポート番号を確認して、「OK]をクリック
  4. 出力表示(単位:mm)を確認

以上

1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?