Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I2C Transfer fails after soft Reset #5

Open
WannabeMaker opened this issue Jan 22, 2025 · 3 comments
Open

I2C Transfer fails after soft Reset #5

WannabeMaker opened this issue Jan 22, 2025 · 3 comments
Assignees

Comments

@WannabeMaker
Copy link

Good morning,
I have been experiencing a strange behavior when I am trying to run the SCD example code on a P1AM-200 from Fact Engineering. As found on their website, "this board uses the ATSAMD51P20 Microcontroller like the Adafruit Grand Central M4".

When I try to run the example code out of the box I get the following error:
"Error trying to execute readFirmwareVersion(): Received NACK on transmit of data"

I ran a few different test trying to isolate the issue and the issue originate from the sensor.softReset(); line.

The following code all give the Received NACK on transmit

sensor.stopPeriodicMeasurement();
sensor.softReset();
delay(2000);
sensor.stopPeriodicMeasurement();
sensor.softReset();
delay(5000);
sensor.stopPeriodicMeasurement();
sensor.softReset();

The followoing code works, without the use the softReset();

sensor.stopPeriodicMeasurement();
delay(2000);

The following code works as expected with the softReset();

sensor.stopPeriodicMeasurement();
sensor.softReset();
sensor.stopPeriodicMeasurement();
delay(2000);

This solution seems to be the cleanest one. Line 97 in the Adafruit_SCD30.cpp file gave me this idea.

// first I2C xfer after reset can fail, double tapping seems to get by it

Running the command above in the following order gives the following error: "Error trying to execute readFirmwareVersion(): Wrong CRC found"

sensor.stopPeriodicMeasurement();
sensor.softReset();
delay(2000);
sensor.stopPeriodicMeasurement();

Why would this be happening? Is it the expected behavior of the library?

Thank you in advance.

P.S. I don't write many bug report, please forgive me if it is very lenghty

@qfisch
Copy link

qfisch commented Jan 27, 2025

Hello @WannabeMaker

Interesting behavior you are observing here! and you are not alone since the Adafruit driver has a note about it...
I did not hear about it yet, I might ask around though...
Anyhow I will try to reproduce it when I have a moment and come back to you asap.

Cheers
Q

@qfisch qfisch self-assigned this Jan 27, 2025
@WannabeMaker
Copy link
Author

Hello @qfisch,
We were able to reproduce the same behavior with the I2C library for the SFX6XXX

The following code does not work. When reading the flow we get negative values and large numbers. It is impossible either to give it a set point.

void setup() {

    Serial.begin(115200);
    while (!Serial) {
        delay(100);
    }
    Wire.begin();
    sensor.begin(Wire, SFC6000_I2C_ADDR_24);
    uint32_t productIdentifier = 0;
    uint64_t serialNumber = 0;
    error = sensor.readProductIdentifier(productIdentifier, serialNumber);
    if (error != NO_ERROR) {
        Serial.print("Error trying to execute readProductIdentifier(): ");
        errorToString(error, errorMessage, sizeof errorMessage);
        Serial.println(errorMessage);
        return;
    }

but this one does. To cite the Adafruit library author "double tapping it" seems to do the trick.

void setup() {

    Serial.begin(115200);
    while (!Serial) {
        delay(100);
    }
    Wire.begin();
    tcaselect(7);
    sensor.begin(Wire, SFC6000_I2C_ADDR_24);
    sensor.stopContinuousMeasurement();
    uint32_t productIdentifier = 0;
    uint64_t serialNumber = 0;
    error = sensor.readProductIdentifier(productIdentifier, serialNumber);
    if (error != NO_ERROR) {
        Serial.print("Error trying to execute readProductIdentifier(): ");
        errorToString(error, errorMessage, sizeof errorMessage);
        Serial.println(errorMessage);
        return;
    }

@qfisch
Copy link

qfisch commented Feb 4, 2025

Hello @WannabeMaker

After testing with the boards around (Arduino/ESP32), I could not reproduce the behavior.
We unfortunately do not have any ATSAMD51P20 based board available for testing on the exact platform.

I2C can be pretty sensitive to wiring. Could you share more about your setup/wiring ?

Thanks
Q

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants