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.

  • Hi,

    Since you state you're using Segger Embeded Studio (SES), I assume you're using nRF 5 SDK for Mesh. What I wanted to know is which version of nRF5 SDK for Mesh you're using. Could you state which version that is? Here's a link to the various nRF5 SDKs we have infocenter.nordicsemi.com/.../sdk.html

    Chriis said:
    The PCA10400 SDK, developing for nrf52832 chipsets.

    Just to clarify, there is a disctinction between nRFs such as "PCA10400/nRF52832" which is a DK (or a Development Kit), which is not the same as an SDK, or "Software Development Kit", which is the code base used to develop.

    Kind regards,
    Andreas

  • Have you seen the sensor sample for Mesh? This should illustrate how to do what you're describing in your description.

    Kind regards,
    Andreas

  • I have seen that. Overall that page is just reference to reference so that is extremely hard to normally read and hard to understand if you are just beginning with mesh.

    So it is not really of use to me. I do have that example with a server sensor and a client sensor on my boards. But I am trying to figure out what part of the code includes the mocked sensor data and sends that data over bluetooth.

    Also I got a weird problem. When I provision both boards with one on sensor server and the other on sensor client. And after that I try to click the onboard buttons to send data, it works normally I think. When I click a button on the server board, the client recieves a bunch of data (No idea where that data comes from because I think the server just sends a variable and not a bunch of text aswell). But when I turn off the client for a few seconds and turn it back on, only the data from the server board gets read on the client, but when I click a button on the client, then it said transmission false. Like the board can't recieve data back for some reason.

  • Chriis said:
    Overall that page is just reference to reference so that is extremely hard to normally read and hard to understand if you are just beginning with mesh.

    Yes, overall it is a reference to everything you need to know to understand the server sample located in <nRF5 SDK for Mesh InstallFolder>/examples/sensor, and I do agree that it is hard to follow if you're relatively new to Mesh so I understand the frustration which it might induce, but unfortunately this is where the entry level for applications such as these lies.

    Chriis said:
    But I am trying to figure out what part of the code includes the mocked sensor data and sends that data over bluetooth.

    Have a look at static void app_sensor_get_cb and static void button_event_handler(uint32_t button_number) in server/src/main.c and follow the code with some breakpoints 

    Chriis said:
    (No idea where that data comes from because I think the server just sends a variable and not a bunch of text aswell).

    Are you able to locate where in the code you find the same strings of text as is printed?

    Chriis said:
    But when I turn off the client for a few seconds and turn it back on, only the data from the server board gets read on the client, but when I click a button on the client, then it said transmission false. Like the board can't recieve data back for some reason.

    I will have to look into this behavior to see if it is as expected or not. 

    ---

    Since you mention that you're a beginner with Mesh: if your project allows you to use nRF Connect SDK instead of nRF5 SDK for Mesh, I can recommend you the following resources to get you started and to expand your knowledge with both the new SDK and Mesh:

    I addition to the documentation you linked, I would like to recommend you to have a look at these two webinars regarding Bluetooth Mesh:

    1. https://webinars.nordicsemi.com/introduction-to-bluetooth-mesh-4
    2. https://webinars.nordicsemi.com/developing-bluetooth-mesh-products-4

    The first webinar is only a concept introduction, while the second webinar shows you how to modify the Light and switch samples and should explain how to add a vendor model to the samples.

    In addition, if you're new or intermediate with nRF Connect SDK and Bluetooth Low Energy, I do also recommend you have a look at 

    1. https://academy.nordicsemi.com/courses/nrf-connect-sdk-fundamentals/i Introductory course to nRF Connect SDK. I recommend you start here if you ever switch over to NCS from nRF5 SDK.
    2. https://academy.nordicsemi.com/courses/bluetooth-low-energy-fundamentals/ will be a good supplement to familiarize yourself with Bluetooth Low Energy, which Bluetooth Mesh is based on. It is not quite the same, but it will break down the abstraction somewhat more. 

    Kind regards,
    Andreas

Reply
  • Chriis said:
    Overall that page is just reference to reference so that is extremely hard to normally read and hard to understand if you are just beginning with mesh.

    Yes, overall it is a reference to everything you need to know to understand the server sample located in <nRF5 SDK for Mesh InstallFolder>/examples/sensor, and I do agree that it is hard to follow if you're relatively new to Mesh so I understand the frustration which it might induce, but unfortunately this is where the entry level for applications such as these lies.

    Chriis said:
    But I am trying to figure out what part of the code includes the mocked sensor data and sends that data over bluetooth.

    Have a look at static void app_sensor_get_cb and static void button_event_handler(uint32_t button_number) in server/src/main.c and follow the code with some breakpoints 

    Chriis said:
    (No idea where that data comes from because I think the server just sends a variable and not a bunch of text aswell).

    Are you able to locate where in the code you find the same strings of text as is printed?

    Chriis said:
    But when I turn off the client for a few seconds and turn it back on, only the data from the server board gets read on the client, but when I click a button on the client, then it said transmission false. Like the board can't recieve data back for some reason.

    I will have to look into this behavior to see if it is as expected or not. 

    ---

    Since you mention that you're a beginner with Mesh: if your project allows you to use nRF Connect SDK instead of nRF5 SDK for Mesh, I can recommend you the following resources to get you started and to expand your knowledge with both the new SDK and Mesh:

    I addition to the documentation you linked, I would like to recommend you to have a look at these two webinars regarding Bluetooth Mesh:

    1. https://webinars.nordicsemi.com/introduction-to-bluetooth-mesh-4
    2. https://webinars.nordicsemi.com/developing-bluetooth-mesh-products-4

    The first webinar is only a concept introduction, while the second webinar shows you how to modify the Light and switch samples and should explain how to add a vendor model to the samples.

    In addition, if you're new or intermediate with nRF Connect SDK and Bluetooth Low Energy, I do also recommend you have a look at 

    1. https://academy.nordicsemi.com/courses/nrf-connect-sdk-fundamentals/i Introductory course to nRF Connect SDK. I recommend you start here if you ever switch over to NCS from nRF5 SDK.
    2. https://academy.nordicsemi.com/courses/bluetooth-low-energy-fundamentals/ will be a good supplement to familiarize yourself with Bluetooth Low Energy, which Bluetooth Mesh is based on. It is not quite the same, but it will break down the abstraction somewhat more. 

    Kind regards,
    Andreas

Children
  • 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

Related