Trouble Communicating Two RAK3172s - LoRa P2P

Using Following codes for TX and RX. Communication doesn’t seem to work.
If someone can suggest troubleshooting tips or snags in the code.
LoRa Freq is adjusted accordingly for Australia.

TX:

void send_cb(void) {
  // Optional: leave empty
}

void recv_cb(rui_lora_p2p_recv_t data) {
  // Not used for sending
}

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

  api.lora.nwm.set();             // Set to P2P mode
  api.lora.pfreq.set(921000000);  // Match receiver frequency
  api.lora.psf.set(12);           // Spreading Factor
  api.lora.pbw.set(125);          // Bandwidth
  api.lora.pcr.set(0);            // Coding Rate
  api.lora.ppl.set(8);            // Preamble Length
  api.lora.ptp.set(22);           // TX Power (max)

  api.lora.registerPSendCallback(send_cb);
  api.lora.registerPRecvCallback(recv_cb);  // Optional

  delay(1000);  // Small delay before first transmission
}

void loop() {
  uint8_t payload[] = "Hello";

  api.lora.psend(sizeof(payload), payload);
  delay(3000);  // Send every 5 seconds (adjust as needed)
}

RX:

void recv_cb(rui_lora_p2p_recv_t data) {
  Serial.println("Data received");
}

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

  api.lora.nwm.set();             // P2P mode
  api.lora.pfreq.set(921000000);  // Australia frequency
  api.lora.psf.set(12);           // Spreading Factor
  api.lora.pbw.set(125);          // Bandwidth
  api.lora.pcr.set(0);            // Coding Rate
  api.lora.ppl.set(8);            // Preamble Length
  api.lora.ptp.set(22);           // TX power (not used)

  api.lora.registerPRecvCallback(recv_cb);
  api.lora.precv(65533);          // Permanent RX with TX allowed
}

void loop() {
  // RX is handled by callback
}

Appreciate the help.

I compiled your code and run it on two RAK3172 and it works.

(I added a printout of the received payload).

What RUI3 version are you using?

Do you have

  • RAK3172
  • RAK3172-T
  • RAK3172-SIP
  • RAK3172LP-SIP

Each of them requires a different board version:

Hi @beegee Appreciate the help here.

Please find below the details:

Snapshot of the boards:

Following is the Antenna I am using. It was ordered from Ali Express that said suitable for Aussie LoRa Freq Range.

Following are the board specs:


I did noticed I am using RAK3172-T … I should be using Just RAK3172 instead ?
Arduino Screenshot

I’ll try changing the board version. Glad to know the code is working.
Please share if you notice any anomalies. Boards are just pretty basic ones for just testing.

Sorted @beegee. Thanks for the help.
Issue was due to the incorrect board type selection. Should have used Wis Duo RAK3172 Evaluation Board

Now lets see how bad are these Antennas from Ali Express :slight_smile:
Cheers

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