Getting blebat to work

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

cross mob
Anonymous
Not applicable

Hi,

I'm currently trying to get battery monitoring with blebat on the BCM20732S to work similar to what hello_sensor is doing.

Right now I'm not able to see anything on the HCI UART when I switch on the power and then the UART interface (trying to keep RXD low). The module seems to go into deep sleep instead drawing only 3uA.

My assumption was that the GPIO pin wasn't the right one, my config currently looks like the following:

const BLE_PROFILE_GPIO_CFG xyz_gpio_cfg = {

/*.gpio_pin =*/

        {GPIO_PIN_BATTERY, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 // GPIOs are not used

        },

        /*.gpio_flag =*/

        {GPIO_SETTINGS_BATTERY, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } };

I hope you can tell me what to expect from blebat and whether it could work on the module at all.

Regards,

Kilian

0 Likes
1 Solution
Anonymous
Not applicable
7 Replies
Anonymous
Not applicable
Anonymous
Not applicable

I wasn't certain whether I really had to move the blebat.{c|h} into my application. Now I'm using the following code to

measure the voltage:

xyz_create() {

...

adc_config();

...

}

and called from the timer callback:

void xyz_batt_check(void) {

    uint32_t newMeasurement;

    adc_SetInputRange(ADC_RANGE_0_3P6V);

    newMeasurement  = adc_readVoltage(ADC_INPUT_P15);

    ble_trace1("Battery Voltage [mV]: %u\n", newMeasurement);

}

From this I get:

...

Battery Voltage [mV]: 511

which surprises me since this should be 3060 mV.

Regards,

Kilian

0 Likes
Anonymous
Not applicable

For my application, I had to use gpio_configurePin for it to read values correctly.

For example, to use P14 for some ADC readings for my application, I used:
gpio_configurePin(0, 14&0x0F, GPIO_INPUT_ENABLE |  GPIO_PULL_UP_DOWN_NONE, GPIO_PIN_OUTPUT_LOW);

See if that works

0 Likes
Anonymous
Not applicable

Thanks for your help, I'll give that a shot.

I posted a new question since I'm suspecting that P15 isn't connected to the supply voltage in the BCM20732S. Did you connect the Pin for battery measurements externally?

Regards,

Kilian

0 Likes
Anonymous
Not applicable

My application does, yes.

Anonymous
Not applicable

This didn't change anything for me. My assumption that P15 is connected to the supply voltage is probbaly wrong.

0 Likes
Anonymous
Not applicable

From the datasheet it reads

GPIO: P15
Default direction: Input.

After POR state: Input floating.

Alternate functions:

• A/D converter input

• IR_RX

• 60 Hz_main


The lack of indication that whether this pin is connected to the battery may suggest that it isnt.