Hello, I am currently working with the arduino nano and the VL53L0X (Arduino Code | Adafruit VL53L0X Time of Flight Micro-LIDAR Distance Sensor Breakout | Adafruit Learning System) board
OS: Ubuntu
nano chip CH340
I am trying to use the SDA/SCL pins on the nano, I included wire.h and wired the VL53L0X properly with
SDA -> A5
SCL -> A4
I'm wondering if I did anything wrong, I know the following code works using an arduino uno, however, I want to use the Nano since it is smaller.
When I run the following code, I do not get passed "Adafruit VL53L0X test" in the serial monitor. Let me know if anyone experienced something similar. Thank you for your help
#include "Adafruit_VL53L0X.h"
#include <Wire.h>
#define UPPER_BOUND 250
#define LOWER_BOUND 230
#define LED_PIN 7
Adafruit_VL53L0X lox = Adafruit_VL53L0X();
int dis;
void setup() {
Serial.begin(115200);
pinMode(LED_BUILTIN, OUTPUT);
// wait until serial port opens for native USB devices
while (! Serial) {
delay(1);
}
Serial.println("Adafruit VL53L0X test");
if (!lox.begin()) {
Serial.println(F("Failed to boot VL53L0X"));
while(1);
}
// power
Serial.println(F("VL53L0X API Simple Ranging example\n\n"));
dis = 0;
}
void loop() {
VL53L0X_RangingMeasurementData_t measure;
Serial.print("Reading a measurement... ");
lox.rangingTest(&measure, false); // pass in 'true' to get debug data printout!
if (measure.RangeStatus != 4) { // phase failures have incorrect data
dis = measure.RangeMilliMeter;
if(dis > LOWER_BOUND && dis < UPPER_BOUND) {
digitalWrite(LED_PIN, HIGH);
}
else {
digitalWrite(LED_PIN, LOW);
}
Serial.print("Distance (mm): ");
Serial.println(dis);
} else {
Serial.println(" out of range ");
}
delay(100);
}