- Joined
- Nov 7, 2021
- Messages
- 25
- Reaction score
- 0
I have this component and I'm connecting a lidar to it. My lidar has its i2c pins connected to IO27 and IO26, how would I code this using the Arduino.cc app? These are GPIO pins and I have no idea how to code them. Nothing is being printed out onto the arduino serial monitor when I run that bare code. What do I replace the numbers inside Wire.begin(33,32) so that it is relevant to the wiring I did? I have to use the arduino app or python to code this, so I cannot use the mind+ app
Code:
```
#include <Wire.h>
#include <SparkFun_VL53L5CX_Library.h> //http://librarymanager/All#SparkFun_VL53L5CX
SparkFun_VL53L5CX myImager;
VL53L5CX_ResultsData measurementData; // Result data class structure, 1356 byes of RAM
int imageResolution = 0; //Used to pretty print output
int imageWidth = 0; //Used to pretty print output
void setup()
{
Serial.begin(115200);
delay(1000);
Serial.println("SparkFun VL53L5CX Imager Example");
//Note: The following line will fail to compile if your platform does not have multiple Wire ports
Wire1.begin(33, 32); //(SDA, SCL) on ESP32. This resets I2C bus to 100kHz
Wire1.setClock(400000); //Sensor has max I2C freq of 400kHz
Serial.println("Initializing sensor board at address 0x3C on Wire port Wire1. This can take up to 10s. Please wait.");
if (myImager.begin(0x29, Wire1) == false) //Device address (0x29 is default), Wire port
{
Serial.println(F("Sensor not found - check your wiring. Freezing"));
while (1) ;
}
myImager.setResolution(8 * 8); //Enable all 64 pads
imageResolution = myImager.getResolution(); //Query sensor for current resolution - either 4x4 or 8x8
imageWidth = sqrt(imageResolution); //Calculate printing width
myImager.startRanging();
}
void loop()
{
//Poll sensor for new data
if (myImager.isDataReady() == true)
{
if (myImager.getRangingData(&measurementData)) //Read distance data into array
{
//The ST library returns the data transposed from zone mapping shown in datasheet
//Pretty-print data with increasing y, decreasing x to reflect reality
for (int y = 0 ; y <= imageWidth * (imageWidth - 1) ; y += imageWidth)
{
for (int x = imageWidth - 1 ; x >= 0 ; x--)
{
Serial.print("\t");
Serial.print(measurementData.distance_mm[x + y]);
}
Serial.println();
}
Serial.println();
}
}
delay(5); //Small delay between polling
}
```
this is a robot master tt btw
Code:
```
#include <Wire.h>
#include <SparkFun_VL53L5CX_Library.h> //http://librarymanager/All#SparkFun_VL53L5CX
SparkFun_VL53L5CX myImager;
VL53L5CX_ResultsData measurementData; // Result data class structure, 1356 byes of RAM
int imageResolution = 0; //Used to pretty print output
int imageWidth = 0; //Used to pretty print output
void setup()
{
Serial.begin(115200);
delay(1000);
Serial.println("SparkFun VL53L5CX Imager Example");
//Note: The following line will fail to compile if your platform does not have multiple Wire ports
Wire1.begin(33, 32); //(SDA, SCL) on ESP32. This resets I2C bus to 100kHz
Wire1.setClock(400000); //Sensor has max I2C freq of 400kHz
Serial.println("Initializing sensor board at address 0x3C on Wire port Wire1. This can take up to 10s. Please wait.");
if (myImager.begin(0x29, Wire1) == false) //Device address (0x29 is default), Wire port
{
Serial.println(F("Sensor not found - check your wiring. Freezing"));
while (1) ;
}
myImager.setResolution(8 * 8); //Enable all 64 pads
imageResolution = myImager.getResolution(); //Query sensor for current resolution - either 4x4 or 8x8
imageWidth = sqrt(imageResolution); //Calculate printing width
myImager.startRanging();
}
void loop()
{
//Poll sensor for new data
if (myImager.isDataReady() == true)
{
if (myImager.getRangingData(&measurementData)) //Read distance data into array
{
//The ST library returns the data transposed from zone mapping shown in datasheet
//Pretty-print data with increasing y, decreasing x to reflect reality
for (int y = 0 ; y <= imageWidth * (imageWidth - 1) ; y += imageWidth)
{
for (int x = imageWidth - 1 ; x >= 0 ; x--)
{
Serial.print("\t");
Serial.print(measurementData.distance_mm[x + y]);
}
Serial.println();
}
Serial.println();
}
}
delay(5); //Small delay between polling
}
```
this is a robot master tt btw