RAK12039 github example bug?

Hi everyone,

My first post, I have to say that it is really good documented work what you guys are doing.

Back to the subject.
I am using a rak3172 evaluation board, with rak19010.
But there is a particular sensor(rak12039 PM dust sensor), that when connected and run rakwireless_github_example with Arduino IDE, AT commands will stop working. And I will have to repair firmware to get it back to work.

It happened twice already.

Is that small piece of code broken? or am I using the wrong example code? I might be doing something wrong.

Thanks,

Hi, updated info,

I have changed a small part of the code, and I have “AT commands” working again.

repo code:

..
Wire.begin();
  if(!PMSA003I.begin())
  {
    Serial.println("PMSA003I begin fail,please check connection!");
    delay(100);
    while(1);
  }
..

edited code:

Wire.begin(); delay(500);
  if(!PMSA003I.begin())
  {
    Serial.println("PMSA003I begin fail,please check connection!");
    while (1){ delay(100);}
  }

It was always getting into that “while(1);” loop trap.

However, I still can not get “PMSA003I.begin()” return true.

From my experience with the RAK12039, it can take up to 3 seconds after power up before the sensor responds on I2C.

Try to add this little bit of code before you call PMSA003I.begin():

  Wire.begin();
  Wire.setClock(100000);

  // Wait for sensor to go online
  time_t wait_sensor = millis();
  uint32_t error = 0;
  while (1)
  {
	delay(500);
	Wire.beginTransmission(0x12);
	error = Wire.endTransmission();
	if (error == 0)
	{
	  Serial.printf("RAK12039 answered at %ld ms\n", millis());
	  break;
	}
	if ((millis() - wait_sensor) > 5000)
	{
	  Serial.printf("RAK12039 timeout after 5000 ms");
	  pinMode(WB_IO6, INPUT);
	  break;
	}
  }

  if (!PMSA003I.begin())
  {
    Serial.println("PMSA003I begin fail,please check connection!");
    delay(100);
    while(1);
  }

that will solve “PMSA003I.begin()” troubles.

However, now gets stuck on “PMSA003I.readDate(&data)” function.

It goes through that function less than 10 times(printing “PMSA003I read failed!”), and then… it will stop responding.

extra notes: I am using two different dust sensors, both same results.

I have to push this to our RUI3 R&D team.

It works on Arduino BSP and it works with our RUI3 based RAK4631-R. But it fails with the RAK3172 Evaluation Board.

1 Like