how to use multicast with rui3 and rak3172 for group downlinks

This guide demonstrates how to set up two RAK3172 modules for a multicast session using RUI3 firmware. The example configures both devices to control a relay through a GPIO pin and indicate the relay state using an LED.

The setup uses the WisBlock modular system with the following components:

  • RAK19007 Base Board

  • RAK3372 Core module (RAK3172 on a WisBlock Core PCB)

  • RAK13007 Relay module

The full source code is available in the RUI3-Best-Practice GitHub repo under the  RUI3-Relay-Class-C example.

This application was tested with:

  • ChirpStack LNS (V4.12.1)

  • Actility Thingpark LNS

Set Up the Multicast Group in the LoRaWAN Server

Before starting, ensure the devices are registered on the LoRaWAN server application (ChirpStack) or added to ThingPark (Actility) as Class C devices. Once done, verify that each device can successfully join the LoRaWAN Network Server (LNS) and send uplink messages through a connected gateway.

 

🗒️
NOTE

This guide does not cover how to connect a gateway or add an end device to the LoRaWAN server.

 

Create ChirpStack V4 Multicast

1. In the ChirpStack application, navigate to the Multicast groups tab, then click on Add multicast-group.

chirpstack-create-mc-2.png

 

2. Once done, configure the multicast parameters:

  • Use the icons on the right side to automatically generate random values for:
    • Multicast Address

    • Multicast network session key

    • Multicast application session key

  • Select the correct LoRaWAN Region.

  • Set an appropriate Data-rate for the payload size.

  • Choose a valid downlink Frequency.

  • Under Group Type, select Class-C.

3. Click Submit to save the multicast group.

chirpstack-create-mc-3.png

 

4. Navigate to the Devices tab and select the end nodes that should be connected to the multicast group.

chirpstack-create-mc-4.png

 

5. After selecting the devices, click on Selected devices and choose Add to multicast-group.

chirpstack-create-mc-5.png

6. ChirpStack will display a list of available multicast groups. From the dropdown, select the RUI3-Multicast-Test group that was just created.

chirpstack-create-mc-6.png

 

7. Once selected, return to the Multicast-groups view. Under the Devices tab, you should now see the added end nodes listed.

chirpstack-create-mc-7.png

 

Configure Actility ThingPark Multicast

1. In the ThingPark Base Stations tab, click on the three-dot icon on the right side of the base station entry.

actility-create-mc-1.png

 

2. Add a tag with the Usage set to Multicast.

actility-create-mc-2.png

 

The tag will now appear in the basic station list.

actility-create-mc-3.png

 

3. Go to the Multicast Groups tab and click on the + ADD MULTICAST GROUP button.

actility-create-mc-4.png

 

4. In the upper part of the new window, enter the required fields:

  • Use the gateway EUI as DevEUI

  • Enter custom values or reuse session parameters from ChirpStack

    • Device address

    • NwkSKey

    • AppSKey

actility-create-mc-5.png

5. Scroll to the lower part of the screen, and enter the required fields:

  • Select the Base Station Tags created earlier.

  • Set Class Type to C.

  • Use a valid Downlink Frequency and a suitable Data Rate.

6. After filling in the required multicast group parameters, click ADD to save the group.

 

actility-create-mc-6.png

Now that the Multicast Group is created, it is possible to send Multicast downlinks to all end devices that have registered to this Multicast group and are served through the selected gateway.

In this setup, the served end nodes are the two relay end nodes that will be set up later.


actility-create-mc-7.png

 

RAK3172 Relay Control Setup with Multicast Support

The two end nodes with the RAK3172 are using the code for the RUI3-Relay-Class-C example.

This example code uses downlinks to switch on/off a relay. Only a few lines of code are required to make this application multicast-capable.

1. Add Multicast Session Configuration

Define the LoRaWAN session structure along with the multicast address and keys as global variables.

/** LoRaWAN session structure */
RAK_LORA_McSession session;
/** Multicast address */
uint8_t node_mc_address[4] = {0x00, 0xe2, 0x27, 0x13}; // 00e22713
/** Multicast AppSKey */
uint8_t node_mc_AppSKey[16] = {0x93, 0x98, 0xa5, 0xe3, 0xb6, 0xd2, 0x20, 0xd6, 0x86, 0x15, 0xe0, 0xc6, 0x2d, 0xad, 0x33, 0x07}; // 9398a5e3b6d220d68615e0c62dad3307
/** Multicast NwkSKey */
uint8_t node_mc_NwkSKey[16] = {0xe7, 0x04, 0xca, 0x06, 0xca, 0xf0, 0xbe, 0x78, 0x15, 0x52, 0xc0, 0x4b, 0x4d, 0x46, 0xbd, 0x06}; // e704ca06caf0be781552c04b4d46bd06

2. Prepare the Multicast Session

In the setup() function, the required structure for the multicast is prepared.

    // Setup new multicast session
    session.McDevclass = 2;
    session.McAddress = node_mc_address[0] << 24 | node_mc_address[1] << 16 | node_mc_address[2] << 8 | node_mc_address[3];
    session.McFrequency = 916600000;
    session.McDatarate = 4;
    session.McPeriodicity = 0;
    session.McGroupID = 2;
    session.entry = 0;

    memcpy(session.McAppSKey, node_mc_AppSKey, 16);
    memcpy(session.McNwkSKey, node_mc_NwkSKey, 16);

 

🗒️
NOTE

The multicast session is not active until the device has joined the LoRaWAN network.

 

3. Activate the Multicast Session

The multicast session is activated in the join callback function provided by RUI3. Once the device successfully joins the network, the multicast session is added and becomes active.

        // Try to remove last session
        if (api.lorawan.rmvmulc(node_mc_address[0] << 24 | node_mc_address[1] << 16 | node_mc_address[2] << 8 | node_mc_address[3]) == true)
        {
            MYLOG("JOIN-CB", "Remove Multicast Success");
        }
        else
        {
            MYLOG("JOIN-CB", "Remove Multicast Fail");
        }

        // LoRaWAN Multicast Setting
        if (api.lorawan.addmulc(session) == true)
        {
            MYLOG("JOIN-CB", "Add Multicast Success");
        }
        else
        {
            MYLOG("JOIN-CB", "Add Multicast Fail");
        }

 

🗒️
NOTE

In the code shown above, an existing multicast session is removed before adding a new one. This is optional, as multicast sessions are stored in non-volatile memory and persist after power cycles or resets. It's included here only to demonstrate how to clear a multicast session if needed.

The full source code for the multicast relay control application can be found in the GitHub RUI3-Best-Practice repository.

Once all end nodes are set up and successfully connected to the LoRaWAN server, the multicast downlinks can be tested.

ChirpStack Test

1. In ChirpStack, go to the Application > Multicast-groups and open the multicast group.

2. Select the Queue tab and enter the downlink values. FPort must be 10, as the end nodes expect the downlink on that fPort. The payload can be entered as a HEX value.

  • AA5500 switches the relay off.

  • AA5501 switches the relay on.

3. Push the Enqueue button to start sending the downlink packet.

chirpstack-test-mc-1.png

Actility Test

1. In Actility Thingpark, open the Multicast Groups tab, then open the multicast group you created.

actility-test-mc-1.png

 

2. Push the SEND DOWNLINK button.

actility-test-mc-2.png

 

3. In the popup window, enter the Payload and the Port, then push VALIDATE to send the multicast downlink.

  • The Payload can be entered as HEX value.

    • AA5500 - to switch off the relay

    • AA5501 - toswitch on the relay

  • Port (fPort) must be 10

actility-test-mc-3.png

 

Device Logs

The device log shows the received multicast downlink on both devices:

  • The first multicast downlink is switching the relay off with the payload AA5500.

  • The second multicast downlink is switching the relay on with the payload AA5501.

device-test-log.png

 

Relay Control Application

The above example code is NOT using the loop at all. Instead, it is completely event-driven. The WisDuo/WisBlock module is sleeping unless an event occurs. An event can be:

  • A timer callback

  • An external interrupt

  • If using LoRaWAN Class C, a packet is received from the LoRaWAN server.

This code sets setup a timer that wakes up the device in the desired send interval, sends a packet, and then the system goes back to sleep automatically.

You can extend this by using external interrupts. Refer to the other example codes for guidance.

The application listens for downlinks on fPort 10. If the downlink is in the hex format AAFFxx, it interprets it as a command to:

  • Set the relay if xx = 01

  • Reset the relay if xx = 00

The relay is controlled using the WB_IO4 GPIO. Although this could be handled directly within the receive callbacks, the implementation uses a timer to start the function that controls the GPIO.

The uplink message sent to the LoRaWAN server includes the relay status at a configurable interval. The node must be configured as a Class C device to receive downlinks from the LoRaWAN server immediately.

🗒️
NOTE

Multicast downlinks only work in Class B and Class C.

 

The relay control is handled in the receive callback function provided by RUI3. This callback runs whenever the device receives a downlink, whether it is a direct downlink or a multicast downlink.

Within the callback:

  1. The fPort is checked. The device processes commands only if the fPort is 10.

  2. The payload is checked. It must begin with AA55 in hex.

  3. The next byte determines the relay state:

    • 00 turns the relay off

    • 01 turns the relay on

The relay is not switched directly from the callback, since callback functions should be kept as short as possible. Instead, the callback triggers a one-shot timer to handle the relay and green LED control.


 

bernd-giesecke.png

Bernd Giesecke

Electronics Engineer, 23 years of experience in industrial and automotive HW and SW R&D. Supporting Arduino open-source community since 2014.


Changelog
  • Version 1 - How to Use Multicast with RUI3 and RAK3172 for Group Downlinks
    • Author: Bernd Giesecke
    • Reviewer: Karla Jimenez
    • Date Published: 07/16/2025

 

 

Updated