Open
Description
I tried setting a new I2C ID using setI2CAddress function. The function returns True , but the communication fails. I tried the following program . I also attached the I2C communication data capturing using Saleae logic analyzer.
/*
Example-01_Basic.ino
This demo shows a basic use of a TMF882X device. The device is connected to,
and a single reading is taken for each loop iteration.
Supported Boards:
SparkFun Qwiic dToF Imager - TMF8820 https://www.sparkfun.com/products/19036
SparkFun Qwiic Mini dToF Imager - TMF8820 https://www.sparkfun.com/products/19218
SparkFun Qwiic Mini dToF Imager - TMF8821 https://www.sparkfun.com/products/19451
SparkFun Qwiic dToF Imager - TMF8821 https://www.sparkfun.com/products/19037
Written by Kirk Benell @ SparkFun Electronics, April 2022
Repository:
https://github.com/sparkfun/SparkFun_Qwiic_TMF882X_Arduino_Library
Documentation:
https://sparkfun.github.io/SparkFun_Qwiic_TMF882X_Arduino_Library/
SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT).
*/
#include "SparkFun_TMF882X_Library.h" //http://librarymanager/All#SparkFun_Qwiic_TMPF882X
SparkFun_TMF882X myTMF882X;
uint8_t new_address = 0x50;
// Structure to hold the measurement results - this is defined by the TMF882X SDK.
static struct tmf882x_msg_meas_results myResults;
void setup()
{
delay(1000);
Serial.begin(115200);
Serial.println("");
Serial.println("In setup");
Serial.println("==============================");
// Initialize the TMF882X device
if(!myTMF882X.begin())
{
Serial.println("Error - The TMF882X failed to initialize - is the board connected?");
while(1);
}else
Serial.println("TMF882X started.");
Serial.println("Change the device address");
delay(2000);
Serial.println(myTMF882X.setI2CAddress(new_address));
delay(2000);
// The device is now ready for operations
}
void loop()
{
delay(2000);
// get a Measurement
if(myTMF882X.startMeasuring(myResults))
{
// print out results
Serial.println("Measurement:");
Serial.print(" Result Number: "); Serial.print(myResults.result_num);
Serial.print(" Number of Results: "); Serial.println(myResults.num_results);
for (int i = 0; i < myResults.num_results; ++i)
{
Serial.print(" conf: "); Serial.print(myResults.results[i].confidence);
Serial.print(" distance mm: "); Serial.print(myResults.results[i].distance_mm);
Serial.print(" channel: "); Serial.print(myResults.results[i].channel);
Serial.print(" sub_capture: "); Serial.println(myResults.results[i].sub_capture);
}
Serial.print(" photon: "); Serial.print(myResults.photon_count);
Serial.print(" ref photon: "); Serial.print(myResults.ref_photon_count);
Serial.print(" ALS: "); Serial.println(myResults.ambient_light); Serial.println();
}
}
[Session 0.zip](https://github.com/sparkfun/SparkFun_Qwiic_TMF882X_Arduino_Library/files/9263378/Session.0.zip)