sandeepmistry / arduino-BLEPeripheral

An Arduino library for creating custom BLE peripherals with Nordic Semiconductor's nRF8001 or nR51822.
MIT License
463 stars 180 forks source link

Power consumption #240

Open webfrank opened 6 years ago

webfrank commented 6 years ago

Hi, I'm using a Waveshare BLE400 board and I noticed an abnormal power usage compiling with arduino.

I'm using the blue thermometer example and I got a 4mA if compiling with arduino but a similar example with mbed compiled with platformio uses about 100uA with the same tx power and advertising period.

Why?

TamojitSaha commented 6 years ago

@webfrank

Hi, I'm using a Waveshare BLE400 board and I noticed an abnormal power usage compiling with arduino.

I'm using the blue thermometer example and I got a 4mA if compiling with arduino but a similar example with mbed compiled with platformio uses about 100uA with the same tx power and advertising period.

Why?

I was facing a similar issue. I had to declare the following after blePeripheral.begin(). Code snippet:

void setupBLE(){
//...other stuffs

blePeriph.begin();
sd_ble_gap_tx_power_set(-16);

// 100ms; in multiples of 0.625ms.   
blePeriph.setAdvertisingInterval(160);
//... other stuffs
}

See the following lines for understanding: https://github.com/sandeepmistry/arduino-BLEPeripheral/blob/161a4163f565be3cd5b62bbc59f0c2b522d82b02/src/nRF51822.cpp#L188-L196

Hope it helps you! 😃