You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was unable to find a quick and simple connector between Qwik and shield pins (not entirely sure what they're called), therefore soldered out the following (sorry for the image quality):
4 pins soldered to the chip - GND, 3V3, SDA, SCL
Via standard jumper wire they're connected to the shield (respectively to GND, 3V3, SDA and SCL slots):
Just to verify that slots on the shield are correct:
After connecting the components I see that the LED on the sensor is glowing red (so I suppose it's connected).
Now in my project, I'm trying to initialize the sensor as follows:
#include"Arduino.h"
#include"Adafruit_TinyUSB.h"
#include"SparkFun_TMF882X_Library.h"
#defineSAMPLE_TIMEOUT_MS3000
SparkFun_TMF882X tofSensor;
voidonMeasurementCallback(structtmf882x_msg_meas_results *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 (uint32_t 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();
}
voidsetup()
{
Serial.println("Delaying the initialization for 500ms...");
delay(500);
Serial.begin(9600);
Serial.println("Initializing the ToF Sensor");
if (!tofSensor.begin())
{
Serial.println("Error - The TMF882X failed to initialize - is the board connected?");
while (true)
{
Serial.println("Issue with initializing the ToF sensor!");
delay(500);
};
}
// set our call back function
tofSensor.setMeasurementHandler(onMeasurementCallback);
// Set our delay between samples - 1 second - note it's in ms
tofSensor.setSampleDelay(700);
}
voidloop()
{
Serial.println("Starting the loop logic in 2 seconds...");
delay(2000);
Serial.println("---------------------------------------------------------");
Serial.print("Taking Samples over a period of: ");
Serial.print(SAMPLE_TIMEOUT_MS);
Serial.println(" MS");
Serial.println();
// If number of desired samples is 0, the system loops forever - until timeout// is hit, or stopped in the callback function.int nSamples = tofSensor.startMeasuring(0, SAMPLE_TIMEOUT_MS);
Serial.print("Took ");
Serial.print(nSamples);
Serial.println(" data samples.");
Serial.println();
Serial.println("---------------------------------------------------------\n\n");
}
But on the serial output I see:
Issue with initializing the ToF sensor!
Issue with initializing the ToF sensor!
Issue with initializing the ToF sensor!
Issue with initializing the ToF sensor!
Issue with initializing the ToF sensor!
So I suppose that something is missing here. Probably I've misconfigured something. Any help would be appreciated, and please note I'm quite a beginner so any explanation or clue would be helpful.
The text was updated successfully, but these errors were encountered:
Do you have another way to test the I2C "Wire" interface? The TMF882X library defaults to using the "Wire" I2C interface. Maybe the XIAO has more than one Wire port (e.g. Wire1)? Do you have another I2C sensor you can try? Or can you run a Wire port scanner example - it should detect the TMF8821 at address 41 Hex, 65 Decimal?
hi @PaulZC ,
it seems like your clues are correct. I'm not entirely sure what's happening under the hood, but I was able to identify the following behavior:
When I run I2C Scanner on a board itself (without the Shield attached), it runs fine - since no I2C devices are connected, the scanner reports "no devices" (as expected).
However, if I plug the board into the shield, the I2C scanner hangs on one of the following lines:
The only thing I understand is that the issue is irrelevant to the sensor itself - it's somehow related to the way how shield attachment works with the Wire library.
The I2C Scanner should still work when you attach the Shield (but do not attach the sensor). Please check your soldering and wiring. Is SCL or SDA shorted to GND (or 3.3V)?
Hi SparkFun team,
I have a project with the following hardware:
I was unable to find a quick and simple connector between Qwik and shield pins (not entirely sure what they're called), therefore soldered out the following (sorry for the image quality):
Now in my project, I'm trying to initialize the sensor as follows:
But on the serial output I see:
So I suppose that something is missing here. Probably I've misconfigured something. Any help would be appreciated, and please note I'm quite a beginner so any explanation or clue would be helpful.
The text was updated successfully, but these errors were encountered: