Reading Battery percentage of a Sleeping End device

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Reading Battery percentage of a Sleeping End device

2,575 Views
dmsherazi
Contributor IV

Hi, 

I would like to get the battery charge remaining in percentage of a SED (ZGB 3.0)  operated by a disposable battery. I need to know the following 

  1. Will I have to implement any cluster (Power Configuration Cluster 0x0001) ?
  2. Will I have to implement the circuit to read the voltage of battery via a certain ADC or JN516x has any way to find it from VDD?
Labels (1)
0 Kudos
11 Replies

1,893 Views
dmsherazi
Contributor IV

can you please email me a zip with your files for the application.  email to dost.mhd@kindows.net

0 Kudos

1,893 Views
ovidiu_usturoi
NXP Employee
NXP Employee

Hi dostshah,

Sorry for late reply.If still have the issue, please let me know and I will create a similar setup on my side. 

As a first look, the modified files are OK.  Did you tried to read other attribute from different cluster or a mandatory attribute (I think that cluster version is mandatory for each cluster)? (an over the air log will help here).

Regards,

Ovidiu

0 Kudos

1,893 Views
dmsherazi
Contributor IV

Hi , I am still having the issue. unfortunately I don't have a sniffer USB. Can you make a setup on your side and share it with me to check please?

0 Kudos

1,893 Views
ovidiu_usturoi
NXP Employee
NXP Employee

Yep. I will do the setup today.  I will share the results.

Regards,

Ovidiu

0 Kudos

1,893 Views
ovidiu_usturoi
NXP Employee
NXP Employee

Hi dostshah,

I finished my setup based on your updated files.

After I fixed some liker errors related to group, doorlock cluster, the result is:

1. to be sure that the cluster is added correctly, please try to set an attribute of this cluster. For example, I added the following line in function APP_ZCL_vInitialize, after Endpoint registration (eZHA_RegisterBaseDeviceEndPoint function call):

       sBaseDevice.sPowerConfigurationServerCluster.u8BatteryVoltage = 2;

2. Validate build process. The project build (Console window) should look something like this (please ignore the Problems window at this point):

  pastedImage_1.png

3. Create the network and join the EndDevice. In my case I used a Control Bridge as Coordinator. The command used to get the Battery Voltage is:

pastedImage_2.png

4. Over the air validation (value is equal to 2 as I set in APP_ZCL_vInitialize function):

pastedImage_3.png

If you don't have a sniffer,  you can update the ControlBridge message to handle the read attribute response for this cluster (see basic cluster as example).

Please try to follow these steps and let me know about your result.

Regards,

Ovidiu

1,893 Views
dmsherazi
Contributor IV

Hi , Thanks a lot. Can you please share your files? I am still having the issues!

0 Kudos

1,893 Views
ovidiu_usturoi
NXP Employee
NXP Employee

Hi, 

I used actually the official release (from website - JN-SW-4170 as sdk and JN-AN1217 as application), where I added your changes, commenting the doorlock scene and group cluster (from zcl_options.h), because was some linker issues.

If still have issues, maybe will be usefull if you can check the SDK used. You can do using: Proprieties-> NXP JN51xxApplication -> TargetStack as below:

pastedImage_1.png

Regards,

Ovidiu

0 Kudos

1,893 Views
ovidiu_usturoi
NXP Employee
NXP Employee

Hi dostshah,

The power configuration cluster contains battery information that could be used for your use case. Please take a look to PowerConfiguration.h file for a complete list of attributes that could be used (e.g. CLD_PWRCFG_ATTR_BATTERY_PERCENTAGE_REMAINING).

For the second question, yes, you need to integrate an extra circuit to read the remaining voltage.

Regards,

Ovidiu

1,893 Views
dmsherazi
Contributor IV

So far I have added Power Configuration Cluster and I am able to get the events on the SED. But when I query for the voltage attribute the following is printed on the Debug UART.

EP EVT:No action E_ZCL_CBET_DEFAULT_RESPONSE

I am using JN-AN-1217 as a reference application

0 Kudos

1,893 Views
ovidiu_usturoi
NXP Employee
NXP Employee

Did you get the same result for each attribute of the Power configuration cluster? Please consider that by default the optional attributes are disabled. My recommendation is to validate the list of enabled attributes by checking the PowerConfiguration.h file.

For the voltage attribute the following define should not be commented:

#define CLD_PWRCFG_ATTR_MAINS_VOLTAGE

0 Kudos

1,893 Views
dmsherazi
Contributor IV

here is my zcloptions.h

/*****************************************************************************
 *
 * MODULE:             JN-AN-1217 - End Device
 *
 * COMPONENT:          zcl_options.h
 *
 * DESCRIPTION:        ZCL Options Header for Base Device application
 *
 ****************************************************************************
 *
 * This software is owned by NXP B.V. and/or its supplier and is protected
 * under applicable copyright laws. All rights are reserved. We grant You,
 * and any third parties, a license to use this software solely and
 * exclusively on NXP products [NXP Microcontrollers such as JN5168, JN5179].
 * You, and any third parties must reproduce the copyright and warranty notice
 * and any other legend of ownership on each copy or partial copy of the
 * software.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 * Copyright NXP B.V. 2016. All rights reserved
 *
 *
 ***************************************************************************/

#ifndef ZCL_OPTIONS_H
#define ZCL_OPTIONS_H

#include <jendefs.h>

/****************************************************************************/
/***        Macro Definitions                                             ***/
/****************************************************************************/


/****************************************************************************/
/*                      ZCL Specific initialization                         */
/****************************************************************************/
/* This is the NXP manufacturer code.If creating new a manufacturer         */
/* specific command apply to the Zigbee alliance for an Id for your company */
/* Also update the manufacturer code in .zpscfg: Node Descriptor->misc      */

#define ZCL_MANUFACTURER_CODE                                0x1037

/* Sets the number of endpoints that will be created by the ZCL library */
#define ZCL_NUMBER_OF_ENDPOINTS                             1

/* Set this Tue to disable non error default responses from clusters */
#define ZCL_DISABLE_DEFAULT_RESPONSES       (FALSE)
#define ZCL_DISABLE_APS_ACK                 (TRUE)

#define ZCL_ATTRIBUTE_READ_SERVER_SUPPORTED
#define ZCL_ATTRIBUTE_READ_CLIENT_SUPPORTED
#define ZCL_ATTRIBUTE_WRITE_SERVER_SUPPORTED

/* Enable wild card profile */
#define ZCL_ALLOW_WILD_CARD_PROFILE
/****************************************************************************/
/*                             Enable Cluster                               */
/*                                                                          */
/* Add the following #define's to your zcl_options.h file to enable         */
/* cluster and their client or server instances                             */
/****************************************************************************/
#define CLD_BASIC
#define BASIC_SERVER
#define BASIC_CLIENT


#define CLD_IDENTIFY
#define IDENTIFY_CLIENT
#define IDENTIFY_SERVER



#define CLD_SCENES
#define SCENES_SERVER
#define CLD_SCENES_MAX_NUMBER_OF_SCENES                     16
#define CLD_SCENES_DISABLE_NAME_SUPPORT
#define CLD_SCENES_MAX_SCENE_NAME_LENGTH                    0
#define CLD_SCENES_MAX_SCENE_STORAGE_BYTES                  16
#define CLD_SCENES_ATTR_LAST_CONFIGURED_BY

#define CLD_GROUPS
#define GROUPS_SERVER
#define CLD_GROUPS_MAX_NUMBER_OF_GROUPS                     8
#define CLD_GROUPS_DISABLE_NAME_SUPPORT
#define GROUPS_CLIENT

#define CLD_ONOFF
#define ONOFF_CLIENT

#define CLD_LEVEL_CONTROL
#define LEVEL_CONTROL_CLIENT

#define CLD_DOOR_LOCK
#define CLD_DOOR_LOCK_SERVER
//#define CLD_DOOR_LOCK_CLIENT
#define DOOR_LOCK_SERVER
//#define DOOR_LOCK_CLIENT


#define CLD_POWER_CONFIGURATION
//#define POWER_CONFIGURATION_CLIENT
#define POWER_CONFIGURATION_SERVER



/****************************************************************************/
/*             Basic Cluster - Optional Attributes                          */
/*                                                                          */
/* Add the following #define's to your zcl_options.h file to add optional   */
/* attributes to the basic cluster.                                         */
/****************************************************************************/
#define   CLD_BAS_ATTR_APPLICATION_VERSION
#define   CLD_BAS_ATTR_STACK_VERSION
#define   CLD_BAS_ATTR_HARDWARE_VERSION
#define   CLD_BAS_ATTR_MANUFACTURER_NAME
#define   CLD_BAS_ATTR_MODEL_IDENTIFIER
#define   CLD_BAS_ATTR_DATE_CODE
#define   CLD_BAS_ATTR_SW_BUILD_ID

#define CLD_BAS_APP_VERSION         (1)
#define CLD_BAS_STACK_VERSION       (1)
#define CLD_BAS_HARDWARE_VERSION    (1)
#define CLD_BAS_MANUF_NAME_SIZE     (3)
#define CLD_BAS_MODEL_ID_SIZE       (13)
#define CLD_BAS_DATE_SIZE           (8)
#define CLD_BAS_POWER_SOURCE        E_CLD_BAS_PS_BATTERY
#define CLD_BAS_SW_BUILD_SIZE       (9)

/****************************************************************************/
/*             Identify - Optional Attributes                               */
/*                                                                          */
/* Add the following #define's to your zcl_options.h file to add optional   */
/* attributes to the identify cluster.                                      */
/****************************************************************************/
#define CLD_IDENTIFY_CMD_TRIGGER_EFFECT

/****************************************************************************/
/*             Groups Cluster - Optional Attributes                         */
/*                                                                          */
/* Add the following #define's to your zcl_options.h file to add optional   */
/* attributes to the Groups cluster.                                        */
/****************************************************************************/


/****************************************************************************/
/*             OnOff Cluster - Optional Attributes                          */
/*                                                                          */
/* Add the following #define's to your zcl_options.h file to add optional   */
/* attributes to the OnOff cluster.                                         */
/****************************************************************************/

/****************************************************************************/
/*             Level Control Cluster - Optional Attributes                  */
/*                                                                          */
/* Add the following #define's to your zcl_options.h file to add optional   */
/* attributes to the level control cluster.                                 */
/****************************************************************************/


/****************************************************************************/
/*             Level Control Cluster - Optional Attributes                  */
/*                                                                          */
/* Add the following #define's to your zcl_options.h file to add optional   */
/* attributes to the level control cluster.                                 */
/****************************************************************************/
#define CLD_DOOR_LOCK_ATTR_DOOR_STATE
#define CLD_DOOR_LOCK_ATTR_NUMBER_OF_DOOR_OPEN_EVENTS
#define CLD_DOOR_LOCK_ATTR_NUMBER_OF_DOOR_CLOSED_EVENTS
//#define CLD_DOOR_LOCK_ATTR_NUMBER_OF_MINUTES_DOOR_OPENED
//#define CLD_DOOR_LOCK_ZIGBEE_SECURITY_LEVEL


#define CLD_PWRCFG_ATTR_BATTERY_VOLTAGE
/*
#define CLD_PWRCFG_ATTR_ID_BATTERY_VOLTAGE_THRESHOLD1
#define CLD_PWRCFG_ATTR_BATTERY_PERCENTAGE_REMAINING
#define CLD_PWRCFG_ATTR_BATTERY_VOLTAGE_MIN_THRESHOLD
*/


/****************************************************************************/
/*             Basic Cluster - Optional Commands                            */
/*                                                                          */
/* Add the following #define's to your zcl_options.h file to add optional   */
/* commands to the basic cluster.                                           */
/****************************************************************************/
#define CLD_BAS_CMD_RESET_TO_FACTORY_DEFAULTS

/****************************************************************************/
/***        Type Definitions                                              ***/
/****************************************************************************/

/****************************************************************************/
/***        Exported Functions                                            ***/
/****************************************************************************/


/****************************************************************************/
/***        External Variables                                            ***/
/****************************************************************************/

/****************************************************************************/
/***        END OF FILE                                                   ***/
/****************************************************************************/

#endif /* ZCL_OPTIONS_H */

and have modified the base_device.c and .h can be found in the link below

https://1drv.ms/f/s!AhxjLIoXBiOagqxkntH-14BhMud1lA  

am I missing something here?

0 Kudos