SPS30 not working on RUI3 with RAK3172

I am trying to use an SPS30 with a custom-built RAK3172 board running on RUI3. But I am not able to read SPS30 on the i2c port. I can read the rest of the i2c devices, like DS3231, SCD30, and many more devices except SPS30. I tested the sensor with an ESP32, and it works fine with it. Below is the code which I used for scanning.

#include <Wire.h>
 
 
void setup()
{
  Wire.begin();
    
  Serial.begin(115200);
  while (!Serial);             // Leonardo: wait for serial monitor
  Serial.println("\nI2C Scanner");
}
 
 
void loop()
{
  byte error, address;
  int nDevices;
 
  Serial.println("Scanning...");
 
  nDevices = 0;
  for(address = 1; address < 127; address++ )
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire.beginTransmission(address);
    error = Wire.endTransmission();
 
    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");
 
      nDevices++;
    }
    else if (error==4)
    {
      Serial.print("Unknown error at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");
 
  delay(5000);           // wait 5 seconds for next scan
}

The same thing I am able to read the device in Mbed OS when I scan for i2c devices. (SPS30 address is 0x69)

image

Hi @d.prasannaakumar ,

I am not sure why RAK3172 and other boards can. Hmm. Some things I have in mind.

  1. What is your pull up resistor? Also VDD levels?
  2. Do you have a oscilloscope where we can see the I2C signals? Might be helpful to see the pulses, signal levels, skew, decoded data. (only if possible or you have one)
  3. Might not be really necessary but can you try to introduce little delay between begin and end transmission?
    Wire.beginTransmission(address);
    delay(10);
    error = Wire.endTransmission();
  1. Also, can you try to remove other I2C modules? And only attach SPS30?
  2. Just for sanity check, can you verify continuity of SDA and SCL lines from RAK3172 to SPS30? If they are in different boards?

I guess you did this already, but just checking.

The SEL pin of the SPS30 is pulled to GND to make sure it uses I2C?

Hello @carlrowan ,

Thanks for your comment. I have done everything with it. With the same RAK3172 board, I am able to make it work with Mbed Studio. The setup also has a DS3231. I think the problem is with RUI3 or the library not supporting RUI3.

Hello @beegee ,

Thanks for your comment. Yes, I have done it. I am able to scan and find the SPS30 with Mbed OS.

Hi @d.prasannaakumar ,

If you use a library for SPS30, we cannot guarantee it can be directly compatible to RUI3. However, even if only at I2C device scanning phase, the SPS30 is not detected, we really have to look on the i2c bus.

Hello @carlrowan ,

I tried adding a delay between transmission begin and end transmission. But I was still not able to scan it. However, with the same hardware setup and Mbed OS, I can successfully scan the device.

Does this have anything to do with i2c clock frequency? Should I check that as well?

Thanks!

Hi @d.prasannaakumar ,

The SPS30 seems to use standard i2c clock.

Btw, one more thing you can try is to lessed the pull-up resistor value. If you are using 10k, probably try 4.7k or 2.1k (lowest). These are just blind fix attempts. The best way really is to see the signal where it is failing via oscilloscope or logic analyzer.

Hello @carlrowan ,
Thanks for your suggestion. I’ll check that.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.