Hello,
I am trying to get 3 channel distance values from TI OPT3101 board from Pololu
with Arduino101(Intel Curie board) and sample library source code.
The following is the distance values output to the serial monitor.
It contains negative possibly overflowed value. I used my hand to check the distance.
I’d appreciate if someone could give me an advice.
Should I do some kind of calibration operation?, or Did I damaged the sensor hardware?
----------------------------
Amplitude0, Distance0, Amplitude1, Distance1, Amplitude2, Distance2
299,5483, 226,-3159, 460,-3505,
299,5483, 226,-3159, 460,-3505,
299,5483, 226,-3159, 460,-3505,
----------------------------
Below is the OPT3101 sample source code(Advanced sample)
I’ve added Serial.begin(9600) line into the setup() function.
---------------------------
#include <OPT3101.h>
#include <Wire.h>
OPT3101 sensor;
uint16_t amplitudes[3];
int16_t distances[3];
void setup()
{
Serial.begin(9600);
Wire.begin();
// Wait for the serial port to be opened before printing
// messages (only applies to boards with native USB).
while (!Serial) {}
sensor.init();
if (sensor.getLastError())
{
Serial.print(F("Failed to initialize OPT3101: error "));
Serial.println(sensor.getLastError());
while (1) {}
}
sensor.setFrameTiming(256);
sensor.setChannel(0);
sensor.setBrightness(OPT3101Brightness::Adaptive);
sensor.startSample();
}
void loop()
{
if (sensor.isSampleDone())
{
sensor.readOutputRegs();
amplitudes[sensor.channelUsed] = sensor.amplitude;
distances[sensor.channelUsed] = sensor.distanceMillimeters;
if (sensor.channelUsed == 2)
{
for (uint8_t i = 0; i < 3; i++)
{
Serial.print(amplitudes[i]);
Serial.print(',');
Serial.print(distances[i]);
Serial.print(", ");
}
Serial.println();
}
sensor.nextChannel();
sensor.startSample();
}
}
---------------------------
Kind Regards,
– Tomonori Manome