RAK3172 LoRa P2P not sending

Hello I’m having some troubles with the RAK3172 module, first time I upload the code it’s working and when I reupload the same code it’s not working. Here it’s my custom PCB schematic :

And the code I’ve tryed arduino and also the example from RAK based on stm32.

And here it’s my code that is working on the first time programming only:

Welcome to the forum @Athereos

first time I upload the code it’s working and when I reupload the same code it’s not working.

What does “not working” mean? It does not start at all or it starts, but throws errors or hangs?

How do you upload the code? I see UART2 is not connected, so it is either STM32CubeProgrammer or Jlink?

Code generated from the compilation is not including the RAK bootloader, so you must not do a Chip Erase before uploading a new firmware. Otherwise you loose the RAK bootloader and the device will not start the application.

Hello Bernd, I use STM32CubeProgrammer to program it, and the code works and when I enter on debug mode it’s doing all the processes but when I measure the current it does not increase at the sending process, but the first time that it’s working the current increased up to 100mA.
image

Also I have a reciever and didn’t recieve nothing from this RAK the second time I programmed it.

Sorry, I can’t help with code from STM32CubeIDE.

What code based on RUI3 did you try?

Yes I just tryed this and didn’t work I get no transmission from RAK
#include <Arduino.h>

uint32_t TempSensorSN = 0;
float CurrentTemp = 0;
uint8_t array[11];
uint16_t SleepTime = 10;

uint32_t STS31_GetSN() {
return 0x12345678; // número de serie fake
}
float STS31_read_temp() {
return 25.37; // valor ficticio
}

// ---------------- Setup ----------------
void setup() {
Serial.begin(115200);
delay(2000);

// Cambiar a modo P2P
if(api.lora.nwm.get() != 0)
{
Serial.printf(“Set Node device work mode %s\r\n”,
api.lora.nwm.set() ? “Success” : “Fail”);
api.system.reboot();
}

api.lora.pfreq.set(868000000); // Frecuencia
api.lora.psf.set(7); // Spreading Factor
api.lora.pbw.set(125); // Bandwidth (kHz)
api.lora.pcr.set(1); // Coding Rate 4/5
api.lora.ppl.set(8); // Preamble length
api.lora.ptp.set(22); // Potencia de TX (dBm)

}

// ---------------- Loop ----------------
void loop() {
uint16_t Battery = 3700;
int8_t TempInt;
uint8_t TempDec;

Battery = analogRead(PA1);

TempSensorSN = STS31_GetSN();
for (int i = sizeof(uint32_t) - 1; i >= 0; --i) {
array[i] = (uint8_t)(TempSensorSN >> ((sizeof(uint32_t) - 1 - i) * 8));
}

array[6] = (uint8_t)(Battery >> 8);
array[7] = (uint8_t)(Battery & 0xFF);
array[8] = 0x4B; // ID
array[9] = 0xAC; // ID

CurrentTemp = STS31_read_temp();
TempInt = (int16_t)CurrentTemp;
TempDec = ((int)(CurrentTemp * 100) % 100);

array[4] = (uint8_t)TempInt;
array[5] = (uint8_t)TempDec;

// ---- TX ----
Serial.println(“Enviando paquete LoRa P2P…”);
api.lora.psend(sizeof(array), array);

delay(1000);

}
Thanks.

You could have a timing problem.
Your P2P settings and the payload length results in a “time on air” of nearly 1 second.
You repeat the loop every 1 second.

Does anything change if you switch to 2 seconds or longer?

What does api.lora.psend(sizeof(array), array);, does it return true or false?

How is your receiver setup? Is it RUI3 as well?

I finally managed to fix it on stm32, it was the config of the “clock” just like this


.
And now it’s working :
image

But now I want to put the micro on sleep mode but i can’t get a decent consumption, I get 352 uA and it has to be about 2uA.

There’s an specific command to put in on sleep appart from this?

 		HAL_Delay(Radio.GetWakeupTime() +1000);
 		uint8_t array[11];
 		array[0] = 0x11;
 		array[1] = 0x12;
 		array[2] = 0x13;
 		array[3] = 0x14;
 		array[4] = 0x05;
 		array[5] = 0x06;
 		array[6] = 0x01; //ID
 		array[7] = 0x12; //ID
 		array[8] = 0x4b; //ID
 		array[9] = 0xAC; //ID


 	Radio.Send((uint8_t *)array, sizeof(array));

 	UTIL_LPM_EnterLowPower();