Open IMBCIT opened 2 years ago
After looking at the driver and datasheet further 0xC02
is just hardcoding the sensor ID to this value which is the hex representation of the decimal number 3074 which was verified by writing a small C++ program using the unified sensor driver to access the struct. The humidity sensor ID is just this value +1 as seen by the source code.
This was tested after creating 2 separate objects for the Temp and Humidity sensors and passing in the base sensor class:
#include <Adafruit_SCD30.h>
Adafruit_SCD30 scd30;
Adafruit_SCD30_Temp temp_test = Adafruit_SCD30_Temp(&scd30);
Adafruit_SCD30_Humidity humid_test = Adafruit_SCD30_Humidity(&scd30);
void setup(void) {
Serial.begin(115200);
while (!Serial) delay(10);
Serial.println("Adafruit SCD30 test!");
if (!scd30.begin()) {
Serial.println("Failed to find SCD30 chip");
while (1) { delay(10); }
}
Serial.println("SCD30 Found!");
sensor_t temp;
sensor_t humid;
temp_test.getSensor(&temp);
Serial.println("SCD30 Temp id: ");
Serial.println(temp.sensor_id);
humid_test.getSensor(&humid);
Serial.println("SCD30 Humid ID: ");
Serial.println(humid.sensor_id);
The expected and verified output from below was:
Adafruit SCD30 test!
SCD30 Found!
SCD30 Temp id:
3074
SCD30 Humid ID:
3075
While we are able to set this value ourselves this would require changes to the Python library potentially and would require some manual intervention as I do not believe there is a way of saving this value. Using the USB interface might give a unique ID but there is a possibility that this value is not viable.
I will focus on seeing if using this approach could prove viable in the long term.
Adafruit Unified Sensor Driver Support
There is a C++ library that can be used to create driver support here: Adafruit_Sensor
Upon using this sensor to test some functionality with the SCD-30 there is support for a unique sensor_id that is located in a struct that the driver accesses. In theory this should allow each sensor to have a unique ID that can be read by the end user.
The issue that I have found is that even though there is availability using this generic driver not all sensors support this from my initial investigation. I spun up an Arduino and wrote some C++ code to try and grab an unique ID from the SCD-30 but got back a generic value of '0' and '1'. This was done using the Adafruit_SCD30 library.
In this library it grabs the sensorID from the register
0xC02
. Upon reviewing the datasheet from the sensor manufacturer this register cannot be found and may be an issue or perhaps an open register to use as a place to store an ID. The datasheet in question is located here SCD30 Datasheet.There is a default address in both the SCD30 C++ and SCD30 Python library located at
0x61
Python driver here.Potential Solutions
Options that we have are reading into the datasheet more to see if there is EEPROM or other memory that can be used/written to give each sensor a unique name or try and see if there is a more unique access identifier that is not only available through I2C as that also has it's own possible limitation when using the MCP2221A.
These current issues are only in regards to the SCD30 and other sensors have a unique Id that can be easily accessed from the manufacturer.