Read and send voltage level data of an external battery with ble mesh part 2

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
jama_4535901
Level 3
Level 3
10 sign-ins 5 sign-ins 25 replies posted

I did the tests with the mesh battery server / client codes as mentioned by the thread Re: Read and send voltage level data of an external battery with ble mesh

I connected a voltage source that varies the voltage from 1.9v to 3.6v as shown in the image

pila.PNG

but when I asked about the voltage with GET in MeshClienControl app/Models with the board with the mesh battery client code, as shown in the image,

lever battery.PNG

The board with code mesh battery client asks the battery level to another board with code mesh battery server

I change the voltage level at the voltage source between 1.9v to 3.6v

BUT

(On the board with mesh battery client code) In MeshClientControl the voltage level does not change and in the WACED Peripheral UART the voltage level does not change either, it always shows as 99

BATTERY.PNG

Can you tell me, how do I get the battery voltage level?

0 Likes
1 Solution
DheerajPK_41
Moderator
Moderator
Moderator
750 replies posted 500 likes received 500 replies posted

Hi,

The mesh snip applications shows how to implement mesh models defined by SIG in mesh-specifications.

The battery level value you have observed is the value set for battery_level in mesh_battery_t structure. It is upto the designer how to read the battery level of the associated hardware.

// test data

    app_state.battery_level     = 99;

    app_state.time_to_discharge = 200;

    app_state.time_to_charge    = 300;

    app_state.presence          = WICED_BT_MESH_BATTERY_FLAG_PRESENT_REMOVABLE;

    app_state.level_inidicator  = WICED_BT_MESH_BATTERY_FLAG_LEVEL_GOOD;

    app_state.charging          = WICED_BT_MESH_BATTERY_FLAG_CHARGING;

    app_state.servicability     = WICED_BT_MESH_BATTERY_FLAG_SERVICE_NOT_REQUIRED;

typedef struct

{

    uint8_t                                 battery_level;

    uint32_t                                time_to_discharge;

    uint32_t                                time_to_charge;

    wiced_bt_mesh_battery_presence_t        presence;

    wiced_bt_mesh_battery_indicator_t       level_inidicator;

    wiced_bt_mesh_battery_charging_t        charging;

    wiced_bt_mesh_battery_servicibility_t   servicability;

} mesh_battery_t;

Thanks,

-Dheeraj

View solution in original post

0 Likes
3 Replies
DheerajPK_41
Moderator
Moderator
Moderator
750 replies posted 500 likes received 500 replies posted

Hi,

The mesh snip applications shows how to implement mesh models defined by SIG in mesh-specifications.

The battery level value you have observed is the value set for battery_level in mesh_battery_t structure. It is upto the designer how to read the battery level of the associated hardware.

// test data

    app_state.battery_level     = 99;

    app_state.time_to_discharge = 200;

    app_state.time_to_charge    = 300;

    app_state.presence          = WICED_BT_MESH_BATTERY_FLAG_PRESENT_REMOVABLE;

    app_state.level_inidicator  = WICED_BT_MESH_BATTERY_FLAG_LEVEL_GOOD;

    app_state.charging          = WICED_BT_MESH_BATTERY_FLAG_CHARGING;

    app_state.servicability     = WICED_BT_MESH_BATTERY_FLAG_SERVICE_NOT_REQUIRED;

typedef struct

{

    uint8_t                                 battery_level;

    uint32_t                                time_to_discharge;

    uint32_t                                time_to_charge;

    wiced_bt_mesh_battery_presence_t        presence;

    wiced_bt_mesh_battery_indicator_t       level_inidicator;

    wiced_bt_mesh_battery_charging_t        charging;

    wiced_bt_mesh_battery_servicibility_t   servicability;

} mesh_battery_t;

Thanks,

-Dheeraj

0 Likes

Will it always stay at 99?

how can i get the battery voltage level of the hardware and print to waced ... UART?

I have seen that the temperature sensor example changes the temperature level, I also want the true battery voltage level to be printed in wace .... UART as in the code of the temperature sensor example

Do I have to connect the voltage of the battery to another pin like the one of the temperature sensor? and I do the conversion or what could I do?

What codes could I use?

in the end I want  that in this code that you gave me(Re: we need help with BLE MESH ), that in the data variable sent by the p_scan_result-> remote_bd_addr, p_scan_result-> rssi, the data is also sent with the battery voltage level to another board through the mesh network

Please, can you help me?

0 Likes

Hi,

In Modustoolbox, the code examples are grouped into fully functional demonstrations (MeshDemo group), and smaller code snippets demonstrate specific Mesh Models (Mesh-Snip group).

mesh_battery_server (or client), which is a snip app, is not coded to read the battery voltage. Instead the Generic battery model implementation is demonstrated in it. So that anyone can develop a logic to read the battery voltage (ADC read), convert it into percentage and update the app_state.battery_level variable.

I would suggest you to go through the lab manual and it's projects, to understand the scope and capability of Modustoolbox.

GitHub - cypresssemiconductorco/CypressAcademy_WBT101_Files: Files for WICED Bluetooth 101 class

Thanks,

-Dheeraj

0 Likes