RAK3172 Mesh Network?

Hi,

Currently i’m working on RAK3172 and RUI3. I have some node sensors (TX) and only one receiver (RX) to collect some sensor datas on one point. I’m using LoRa P2P mode (not LoRaWAN mode). Code will be on arduino ide.

Node sensors sending data to receiver with constant target adress. It means that, when system deployed, in any error situation, it’s not possible to change target adresses without updating node firmware.

So i’m looking for how to establish the P2P communication with something like “mesh” network.

What i need:

  • When node sensors powered up, they will scan another devices in range and be aware about them.

I found this code and don’t know it gonna work or not. Can anyone help me?

#include <RHMesh.h>
#include <RH_RF95.h>

#define NODE_ADDRESS 1

RH_RF95 rf95;

RHMesh mesh(rf95, NODE_ADDRESS);

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, HIGH);

  Serial.begin(9600);
  while (!Serial) ;

  if (!rf95.init()) {
    Serial.println("LoRa radio init failed");
    while (1);
  }
  rf95.setFrequency(915.0);
  rf95.setTxPower(23, false);

  mesh.setPromiscuous(true);
  mesh.setRetries(3);
}

void loop() {
  mesh.update();

  if (mesh.available()) {
    RHMesh::Message msg;
    if (mesh.recv(msg)) {
      Serial.print("Received message from node ");
      Serial.print(msg.headerFrom, DEC);
      Serial.print(": ");
      Serial.println((char*)msg.data);

      // Forward message to other nodes in mesh network
      msg.headerTo = RH_BROADCAST_ADDRESS;
      mesh.send(msg, 0);
    }
  }

  // Send a message to the receiver node
  char msg[] = "Hello from node 1!";
  RHMesh::Message message(msg, sizeof(msg));
  message.setHeaderTo(2);
  mesh.send(message, 0);

  // Scan for nearby nodes and print their addresses
  RH_RF95::Promiscuous promiscuousMode;
  promiscuousMode = rf95.setPromiscuous(true);
  delay(1000);
  rf95.setPromiscuous(promiscuousMode);

  Serial.println("Available nodes:");
  for (int i = 1; i <= 255; i++) {
    if (mesh.getAddressNodeList().contains(i)) {
      Serial.println(i);
    }
  }

  delay(1000);
}

Hi @whydont ,

It will not work directly since it s based on old LoRa transceiver and not the STM32WL of RAK3172.

You can probably port the mesh library it to RAK3172 though.

Thanks for fast reply.

Do you know any library for mesh?

I haven’t explored yet mesh implementation. Only the LoRa communicator of meshtastic. Let’s wait for some members if they already explored one for RAK3172.

Okay. Thanks much @carlrowan

I tested mesh on a processor that is compatible with RAK3172…same STM32WL55

Works nice…not AT commands…only problem to solve is the LITTLE FS…

Use the MESHTASTIC

Thanks. Can you reference any URL ?

Meshtastic

You will find the e5 implementation, that is STM32WL

Works nice!!!

Only problem to solve is the LITTLE FS :frowning: