This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Reading battery status on Thingy:91 board through ADP536x

Hello there!

At this stage of the product development cycle, we would like to be able just to take simple reading from ADP536x module (to read either battery percentage or current voltage, whatever is simpler). We don't want to change any of the ADP536x parameters at this point. We have a Thingy:91 1.0.0, 2019.34 version of the board.

ADP536x datasheet says that I2C address of ADP536x module is 0x46. I thought to attach ADP536x module to I2C network through nrf9160_pca20035ns.overlay file like:

&i2c2 {

    vl53l0x@29 {
        compatible = "st,vl53l0x";        
        reg = <0x29>;
        label = "VL53L0X";
    };    
	
    adp536x@46 {
        compatible = "nordic,nrf-twim";        
        reg = <0x46>;
        label = "ADP536x";
    };  	
};

Is compatible = "nordic,nrf-twim"; line OK? I could not find adi,adp536x  under zephyr/dts/bindings/sensor folder? When I analyze devicetree_unfixed.h file I can't see ADP536x module is properly included as Devicetree node.

From this thread I found battery_monitor.c and .h files that would perfectly fit our need to just take simple reading from ADP536x module with battery_monitor_read(u8_t *buf) function that returns battery percentage (to the best of my understanding).

However, when I include battery monitoring files and try to compile the project, I get the error on this line in battery_monitor.c file:

#define ADP536X_I2C_DEV_NAME DT_NORDIC_NRF_I2C_I2C_2_LABEL

The error says that DT_NORDIC_NRF_I2C_I2C_2_LABEL is not declared which proves my doubts I did not properly include ADP536x module in Devicetree.

How can I do it, what I missed to do here? Anything else to add to prj.config file? I added

 

CONFIG_BATTERY_MONITOR=y
 

line but to no avail.

Is there any proper Zephyr example showing communication with ADP536x module?

Thank you very much for your time and efforts! It is really appreciated.

Sincerely,

Bojan.

Related