Bluetooth Mesh sensor data

Hello,

I am currently working on a mesh sensor system. I have got one sensor board and one board for connecting in the mesh system.
Now I want to be able to send the sensor data from the board where it is connected to, to the other and than print it in the debugger or console or how you want to call it.

Does anyone have an idea how I can send the data that I get every second and place it in bluetooth mesh packets so it will be sent to the other board. And also how to print it when the other board received it.

Thanks :)

Parents
  • Hi,

    Could you state which SDK you're working with so we can better provide documentation and support? I see that you've tagged the nRF52832. Could you verify that you're aiming to develop for that nRF SoC as well?

    Let me know about this and I'll get to working on finding you some resource recommendations 

    Kind regards,
    Andreas

  • Hey, I am currently working with SEGGER,

    softdevice 132 7.2.0, 

    The PCA10400 SDK, developing for nrf52832 chipsets.

  • Hey, I have been working on mesh the last week. Now I have created a program with a working LPN that reads sensor data. Now I need to make a working Friend Node.

    I base my code of the sensor client example and the light switch server. I want the functionality of the sensor client but including friend functionality. however I can't seem to find what enables Friend funcionality on the light switch server.

    I use SDK for Mesh V5.0.0

    When I try to enable Friend in nrf_mesh_config_core.h and compile it gives these errors. What Do I need to add or what am I missing?


    What enables the friend functionality on the light switch server? 

    And what do I need to implement in the Sensor client program to be able to friend it?

  • Glad to hear that you got the LPN working!

    Based on the error messages it looks like you need to add some missing .c/.h files to your project. Could you look items such as "undefined reference to 'friend_needs_packet'" in your SDK and see in which files they are located? I believe you might be missing friend.c and mesh_friend.h, similarly to what you can see in this case

    Kind regards,
    Andreas

  • Hey, 

    you are right.

    I missed the friend.c file. Implemented it and it works.

  • Can you maybe explain or show how the friend/LPN feature works?

    My understanding is that there is a connection between a LPN and Friend node. After making the connection there is a poll, this poll will retrieve data from the LPN, and the LPN will recieve data from the friend.

    Now these are the questions I have:

    If I have sensor data that needs to be polled, where do I put this variable so it will get sent to the Friend? Or what function do I use?

    When this data is sent, how can I make the Friend, for example, printf the polled sensor data?

    Does the friend node just save everything the LPN publishes and sends it trough?

    Can the LPN send data trough a whole network or just to the friend node, and the friend node sends it further?

  • Hi,

    Chriis said:
    Can you maybe explain or show how the friend/LPN feature works?

    I would recommend you to have a look at Bluetooh SIG's blogpost about 'friendship' in Bluetooth Mesh seen here: https://www.bluetooth.com/blog/bluetooth-mesh-networking-series-friendship/

    I think this blog explains the relation quite well.

    Chriis said:
    If I have sensor data that needs to be polled, where do I put this variable so it will get sent to the Friend? Or what function do I use?

    In general the part that makes a node a low power node is not that the node is powered of while it is sleeping. It is only the radio that is turned off, making the LPN not being in constant RX such as is typical for a device connected to the power grid. This is why you will have to do polling if you want to receive anything from the friend. If you want to send anything from the LPN, then you use the same API and procedures as you would do in a "regular" Mesh transmission. This is also explained in the spec and in our documentation, but I find that the abstraction layer is broken down pretty good in this independent blogpost on allaboutcircuits.com: https://www.allaboutcircuits.com/technical-articles/bluetooth-mesh-network-nodes-elements-node-features/

    But do note that if you're not subscribed to the channel you send the message on/to from the LPN, then the friend node is not the target for that message. In a Mesh network it is both possible to send messages to other nodes in the network and through nodes that relays messages not intended to that node to other nodes in the network.

    Chriis said:
    When this data is sent, how can I make the Friend, for example, printf the polled sensor data?

    If you had been using nRF Connect SDK, I would've recommended you to have a look at the Mesh chat sample for an illustration for how this is done. However since you're not using that you will have to find out how to do what I described in the previous section, i.e find out how to send messages to a node on a node/group address, and then for the receiving devices find out how to subscribe to said channel/group. After this is done, you should be free to (edit 1: I forgot to add the final 3 words here) print said data.

    Chriis said:
    Does the friend node just save everything the LPN publishes and sends it trough?
    Chriis said:
    Can the LPN send data trough a whole network or just to the friend node, and the friend node sends it further?

    These two questions goes hand in hand so the following should answer both:

    As the previous section mentions, the friend node does not necessarily save or see the messages, it might also just relay the messages. In the Allaboutcircuits blogpost there is an image of 3 LPN connected to a friend. These sensors/thermostats may send the data through the friend node to other nodes in the network that for instance needs this temperature data to control something else.

    Another example where the LPN/Friend relation is more direct, you can consider a wireless battery powered LPN light switch and a light bulb router-device connected to the power grid. In this case it makes very much sense for the Light bulb to be subscribed to the on/off messages sent from the light switch because it needs to know if the switch has been toggled.

    (Edit 2: Added the following sentence) It does also make sense that the switch is an LPN because it itself does not need to always be listening to messages (always be in RX) as polling messages from its friend on a schedule is enough to find out if any network configuration parameters has been changed.

    The same switch may also be controlling multiple light bulbs, so the light bulbs can then be subscribed to a group address where all devices in that group are subscribed to messages coming from that switch with the on/off clients. If the bulbs are located in for instance a street light pattern (a straight line with a long distance between each other), the first friend node that is closest to the switch will both receive and use the change in on/off as well as send the signal further down to other devices subscribed to that group.

    Let me know if this clarifies things for you and feel free to ask more questions if anything is unclear in the explaination

    Kind regards,
    Andreas

Reply
  • Hi,

    Chriis said:
    Can you maybe explain or show how the friend/LPN feature works?

    I would recommend you to have a look at Bluetooh SIG's blogpost about 'friendship' in Bluetooth Mesh seen here: https://www.bluetooth.com/blog/bluetooth-mesh-networking-series-friendship/

    I think this blog explains the relation quite well.

    Chriis said:
    If I have sensor data that needs to be polled, where do I put this variable so it will get sent to the Friend? Or what function do I use?

    In general the part that makes a node a low power node is not that the node is powered of while it is sleeping. It is only the radio that is turned off, making the LPN not being in constant RX such as is typical for a device connected to the power grid. This is why you will have to do polling if you want to receive anything from the friend. If you want to send anything from the LPN, then you use the same API and procedures as you would do in a "regular" Mesh transmission. This is also explained in the spec and in our documentation, but I find that the abstraction layer is broken down pretty good in this independent blogpost on allaboutcircuits.com: https://www.allaboutcircuits.com/technical-articles/bluetooth-mesh-network-nodes-elements-node-features/

    But do note that if you're not subscribed to the channel you send the message on/to from the LPN, then the friend node is not the target for that message. In a Mesh network it is both possible to send messages to other nodes in the network and through nodes that relays messages not intended to that node to other nodes in the network.

    Chriis said:
    When this data is sent, how can I make the Friend, for example, printf the polled sensor data?

    If you had been using nRF Connect SDK, I would've recommended you to have a look at the Mesh chat sample for an illustration for how this is done. However since you're not using that you will have to find out how to do what I described in the previous section, i.e find out how to send messages to a node on a node/group address, and then for the receiving devices find out how to subscribe to said channel/group. After this is done, you should be free to (edit 1: I forgot to add the final 3 words here) print said data.

    Chriis said:
    Does the friend node just save everything the LPN publishes and sends it trough?
    Chriis said:
    Can the LPN send data trough a whole network or just to the friend node, and the friend node sends it further?

    These two questions goes hand in hand so the following should answer both:

    As the previous section mentions, the friend node does not necessarily save or see the messages, it might also just relay the messages. In the Allaboutcircuits blogpost there is an image of 3 LPN connected to a friend. These sensors/thermostats may send the data through the friend node to other nodes in the network that for instance needs this temperature data to control something else.

    Another example where the LPN/Friend relation is more direct, you can consider a wireless battery powered LPN light switch and a light bulb router-device connected to the power grid. In this case it makes very much sense for the Light bulb to be subscribed to the on/off messages sent from the light switch because it needs to know if the switch has been toggled.

    (Edit 2: Added the following sentence) It does also make sense that the switch is an LPN because it itself does not need to always be listening to messages (always be in RX) as polling messages from its friend on a schedule is enough to find out if any network configuration parameters has been changed.

    The same switch may also be controlling multiple light bulbs, so the light bulbs can then be subscribed to a group address where all devices in that group are subscribed to messages coming from that switch with the on/off clients. If the bulbs are located in for instance a street light pattern (a straight line with a long distance between each other), the first friend node that is closest to the switch will both receive and use the change in on/off as well as send the signal further down to other devices subscribed to that group.

    Let me know if this clarifies things for you and feel free to ask more questions if anything is unclear in the explaination

    Kind regards,
    Andreas

Children
Related