Hello,
I am using an I2C sensor with my nrf52832 board and if I do the sensor_sample_fetch(dev), I get an error code of -16.
What does that mean?
Is there a table to look up the error codes?
My code looks as follows:
void main(void)
{
const char *const devname = DT_LABEL(DT_INST(0, microchip_mcp9808));
const struct device *dev = device_get_binding(devname);
int rc;
if (dev == NULL) {
printf("Device %s not found.\n", devname);
return;
}
while (1) {
struct sensor_value temp;
rc = sensor_sample_fetch(dev);
if (rc != 0) {
printf("sensor_sample_fetch error: %d\n", rc);
break;
}
rc = sensor_channel_get(dev, SENSOR_CHAN_AMBIENT_TEMP, &temp);
if (rc != 0) {
printf("sensor_channel_get error: %d\n", rc);
break;
}
printf("%s: %g C\n", now_str(),
sensor_value_to_double(&temp));
k_sleep(K_SECONDS(2));
}
}
Thank you for your help!