Issue Enabling GPIO Port as Output Pin for Laser Module in Mesh Light Application

Device/Board: nRF5340 DK
Application: Mesh Light (Bluetooth Mesh Network)

Use Case:
I am currently working on a Bluetooth Mesh network using the nRF5340 DK. My goal is to control a laser module in addition to LED0 on the board. I have been using the mesh_light example application as it fits my mesh network requirements.

Issue:
I am trying to enable a GPIO pin to control the laser module, similar to how LED0 is controlled in the mesh_light application. However, I am having trouble configuring the GPIO port to function as an output pin for the laser module. The laser module should be triggered along with LED0.

Steps Taken:

I modified the code to enable GPIO pin P0.16 (or another suitable pin) as an output pin.
I followed the typical GPIO configuration steps:
gpio_pin_configure(dev, PIN, GPIO_OUTPUT);
Despite these changes, the laser module does not turn on as expected when LED0 is triggered in the mesh network.
Expected Outcome:
I expect the laser module connected to the specified GPIO pin to turn on and off in synchronization with LED0 when the mesh network sends a signal.

ASSIST NEEDED FOR :

Can you provide guidance on correctly enabling a GPIO port as an output pin for this use case?


Are there any specific configurations or settings for GPIO pins in the mesh_light application that I may be missing?


Is there a recommended approach to integrating external devices like laser modules into the Bluetooth Mesh network in this way?

Logs/Debug Information:


If necessary, I can provide debug logs or configuration files to help with troubleshooting.

Parents
  • Hi Shaik, 

    The model_handle.c is up to the application to implement. So you can choose what you want to do with it. 
    The main job here is to control the extra GPIO pin when there is a set command 

    What you need to do is:
    1. Define one extra led in the device tree (led number 4 for example, led4). You can do this by creating a overlay file of the nrf5340dk_nrf5340_cpuapp (the file should be named nrf5340dk_nrf5340_cpuapp.overlay  If you are not familiar with overlay take a look here: https://academy.nordicsemi.com/courses/nrf-connect-sdk-fundamentals/lessons/lesson-3-elements-of-an-nrf-connect-sdk-application/topic/configuration-files/


    2. Modify  
    led_set() function , you can either modify it so that it detect that it's the command for led_ctx[0] then it will turn on the extra led4. Or you can define your own led_set() for the first model (control LED0) so that it will also control the extra led. 

    I attached here an example. I have only modified to add a 
    led_set_led0 to the model_handle.c so that when the onoff server on the primary element is toggle it will toggle both LED0 and GPIO P0.27. Please take a look at the overlay file in boards folder
    The example was build with SDK v2.7.99-cs2 , but it should be similar process on other SDK. 

    mesh_light.zip


Reply
  • Hi Shaik, 

    The model_handle.c is up to the application to implement. So you can choose what you want to do with it. 
    The main job here is to control the extra GPIO pin when there is a set command 

    What you need to do is:
    1. Define one extra led in the device tree (led number 4 for example, led4). You can do this by creating a overlay file of the nrf5340dk_nrf5340_cpuapp (the file should be named nrf5340dk_nrf5340_cpuapp.overlay  If you are not familiar with overlay take a look here: https://academy.nordicsemi.com/courses/nrf-connect-sdk-fundamentals/lessons/lesson-3-elements-of-an-nrf-connect-sdk-application/topic/configuration-files/


    2. Modify  
    led_set() function , you can either modify it so that it detect that it's the command for led_ctx[0] then it will turn on the extra led4. Or you can define your own led_set() for the first model (control LED0) so that it will also control the extra led. 

    I attached here an example. I have only modified to add a 
    led_set_led0 to the model_handle.c so that when the onoff server on the primary element is toggle it will toggle both LED0 and GPIO P0.27. Please take a look at the overlay file in boards folder
    The example was build with SDK v2.7.99-cs2 , but it should be similar process on other SDK. 

    mesh_light.zip


Children
Related