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

Hello @beegee, we are having the exact same problem with the RAK3172. We just bought a bunch of RAK12039 but seems like we cannot use them. Is there any news on the matter?

No solution. Sorry, not sure why this problem exists.

I am afraid we have a hardware incompatibility here.

I2C signals on a RAK4631 RUI3 on RAK19007 with RAK12039 at 100kHz I2C speed

I2C signals on a RAK3372 RUI3 on RAK19007 with RAK12039 at 100kHz I2C speed

RAK3172/RAK3372 seems to have a problem to provide a proper I2C clock signal.

This shows as well when I enable the library debug, the returned results when using a RAK3372 show a lot of FF’s

<readDate><83>buf8[0] = 42
<readDate><83>buf8[1] = 4d
<readDate><83>buf8[2] = 0
<readDate><83>buf8[3] = 1c
<readDate><83>buf8[4] = 0
<readDate><83>buf8[5] = ff
<readDate><83>buf8[6] = ff
<readDate><83>buf8[7] = ff
<readDate><83>buf8[8] = ff
<readDate><83>buf8[9] = ff
<readDate><83>buf8[10] = ff
<readDate><83>buf8[11] = ff
<readDate><83>buf8[12] = ff
<readDate><83>buf8[13] = ff
<readDate><83>buf8[14] = ff
<readDate><83>buf8[15] = ff
<readDate><83>buf8[16] = ff
<readDate><83>buf8[17] = ff
<readDate><83>buf8[18] = ff
<readDate><83>buf8[19] = ff
<readDate><83>buf8[20] = ff
<readDate><83>buf8[21] = ff
<readDate><83>buf8[22] = ff
<readDate><83>buf8[23] = ff
<readDate><83>buf8[24] = ff
<readDate><83>buf8[25] = ff
<readDate><83>buf8[26] = ff
<readDate><83>buf8[27] = ff
<readDate><83>buf8[28] = ff
<readDate><83>buf8[29] = ff
<readDate><90>buf16[0] = 424d
<readDate><90>buf16[1] = 1c
<readDate><90>buf16[2] = ff
<readDate><90>buf16[3] = ffff
<readDate><90>buf16[4] = ffff
<readDate><90>buf16[5] = ffff
<readDate><90>buf16[6] = ffff
<readDate><90>buf16[7] = ffff
<readDate><90>buf16[8] = ffff
<readDate><90>buf16[9] = ffff
<readDate><90>buf16[10] = ffff
<readDate><90>buf16[11] = ffff
<readDate><90>buf16[12] = ffff
<readDate><90>buf16[13] = ffff
<readDate><90>buf16[14] = ffff
<readDate><90>buf16[15] = ffff
<readDate><94>pmsa_data.header = 424d
<readDate><95>pmsa_data.date_len = 1c
<readDate><97>sum = 1992
<readDate><98>pmsa_data->check_sum = ffff
<readDate><102>PMSA003I read date fail.
[PMS] Read 14 failed!

Not sure if it can be solved or how.

Have you checked the documentation or specifications for both the sensor and the evaluation board to ensure proper compatibility and integration?