The reference to 37 sensors and actuators has been widely circulated on the Internet. In fact, there must be more than 37 sensor modules compatible with Arduino. In view of the fact that I have accumulated some sensor and actuator modules on hand, according to the concept of practice to get true knowledge (must be done), for the purpose of learning and communication, I am going to try a series of experiments one by one, regardless of success (the program goes through) or not, They will be recorded - small progress or unsolvable problems, hoping to inspire others.
[Arduino] 168 kinds of sensor module series experiments (data code + simulation programming + graphics programming)
Experiment 158: GY-530 VL53L0X laser ranging ToF ranging time-of-flight ranging sensor module IIC communication protocol
[Arduino] 168 sensor module series experiments (data code + simulation programming + graphics programming)
Experiment 158: GY-530 VL53L0X laser ranging ToF ranging time-of-flight ranging sensor module IIC communication protocol
Item 7: Query the IIC address of VL53L0X module and SSD1306 OLED module
Experimental open source code
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验一百五十八:GY-530 VL53L0X 激光测距 ToF测距 飞行时间测距传感器模块 IIC通信协议
项目之七:查询VL53L0X模块和SSD1306 OLED模块的IIC地址
模块接线:
VL53L0X Arduino
VCC 5V
GND GND
SCL A5
SDA A4
*/
#include <Wire.h>
void setup()
{
Wire.begin();
Serial.begin(9600);
while (!Serial); // Leonardo: wait for serial monitor
Serial.println("\nI2C Scanner");
}
void loop()
{
byte error, address;
int nDevices;
Serial.println("Scanning...");
nDevices = 0;
for (address = 1; address < 127; address++ )
{
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the address.
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0)
{
Serial.print("I2C device found at address 0x");
if (address < 16)
Serial.print("0");
Serial.print(address, HEX);
Serial.println(" !");
nDevices++;
}
else if (error == 4)
{
Serial.print("Unknown error at address 0x");
if (address < 16)
Serial.print("0");
Serial.println(address, HEX);
}
}
if (nDevices == 0)
Serial.println("No I2C devices found\n");
else
Serial.println("done\n");
delay(5000); // wait 5 seconds for next scan
}
Experimental serial port return
[Arduino] 168 sensor module series experiments (data code + simulation programming + graphics programming)
Experiment 158: GY-530 VL53L0X laser ranging ToF ranging time-of-flight ranging sensor module IIC communication protocol
Project 8: Use VL53L0X for range measurement and display on SSD1306 OLED (mm)
Experimental open source code
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验一百五十八:GY-530 VL53L0X 激光测距 ToF测距 飞行时间测距传感器模块 IIC通信协议
项目之八:使用 VL53L0X 进行范围测量并在 SSD1306 OLED 上显示(mm)
模块接线:SSD1306 OLED模块相同
VL53L0X Arduino
VCC 5V
GND GND
SCL A5
SDA A4
*/
#include <Wire.h>
#include "Adafruit_VL53L0X.h"
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 display = Adafruit_SSD1306();
Adafruit_VL53L0X lox = Adafruit_VL53L0X();
#if (SSD1306_LCDHEIGHT != 32)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
void setup() {
Serial.begin(9600);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x64)
// init done
display.display();
delay(1000);
Wire.begin();
if (!lox.begin()) {
Serial.println(F("Failed to boot VL53L0X"));
while (1);
}
// text display big!
display.setTextSize(4);
display.setTextColor(WHITE);
}
void loop() {
VL53L0X_RangingMeasurementData_t measure;
lox.rangingTest(&measure, false); // pass in 'true' to get debug data printout!
if (measure.RangeStatus != 4) {
// phase failures have incorrect data
display.clearDisplay();
display.setCursor(0, 0);
display.print(measure.RangeMilliMeter);
display.print("mm");
display.display();
Serial.println();
delay(50);
} else {
display.display();
display.clearDisplay();
return;
}
}
Arduino experiment scene diagram
Experimental open source simulation programming (Linkboy V4.62)
Item 9: Serial port display VL53L0X ranging
Experimental serial port output
Experimental open source simulation programming (Linkboy V4.62)
Project 10: Serial port display VL53L0X ranging waveform
Experimental serial port plotter return status