List all MESH messages on a serial port

Hello everyone,

I need your help to find a solution to my problem. I use a mesh network to measure the level of the water tank.

This mesh network is not connected to the internet
I have in each tank a xenon with a lidar sensor (9x)
I have many xenon to relay antennas
I have a xenon to transmit the MESH data on a raspberry through a USB port, this data is read with Node-Red.

But we are limited to 5 Mesh.subcrive. Do you know a trick so you can increase to 9?

Thank you in advance for your answers.
Christophe

You can use one subscribe for all events that start with a particular prefix
e.g. one subscribe for tankData_ will accept all of the following

tankData_Node1
tankData_Node2
tankData_Average
tankData_Max
tankData_Min
...

Inside the subscribe handler you can then check the suffix contained in name (first parameter) to distinguish between them.

This is what the docu means with that


https://docs.particle.io/reference/device-os/firmware/xenon/#subscribe-

1 Like

You are the best !

Thx you very much
Christophe

1 Like

And it’s my code. It’s working perfect. Thx you very much @ScruffR !

SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(AUTOMATIC);

void setup() {
    Mesh.subscribe("G001_", Information);
    Serial.begin(9600);
}

void loop() {
}

void Information(const char *event, const char *data)
{
    if(strcmp(event, "G001_S001") == 0)
    {
        Serial.print(String(data));
    }
    else if(strcmp(event, "G001_S002") == 0)
    {
        Serial.print(String(data));
    }
    else if(strcmp(event, "G001_S003") == 0)
    {
        Serial.print("R"+String(data));
    }
    else if(strcmp(event, "G001_S004") == 0)
    {
        Serial.print("T"+String(data));
    }
    else if(strcmp(event, "G001_S005") == 0)
    {
        Serial.print("S"+String(data));
    }
}
1 Like