Read nRF51822(BLE Chip) VDD voltage and return 100 to 0% charging level

Dependents:   BLE_Temp_Vdd_via_UART_TY BLE_EddystoneBeacon_w_ACC_TY51822 BLE_LoopbackUART_low_pwr_w_RTC1 BLE_Paired_Server ... more

Embed: (wiki syntax)

« Back to documentation index

nRF51_Vdd Class Reference

nRF51_Vdd Class Reference

Read nRF51822 VDD volatage and return 0 to 100% charging level. More...

#include <nRF51_Vdd.h>

Public Member Functions

 nRF51_Vdd (float vdd100percent, float vddzeropercent, uint8_t adc_use)
 Configure data pin.
 nRF51_Vdd (float vdd100percent, float vddzeropercent)
 Configure data pin.
 nRF51_Vdd (void)
 Configure data pin (with other devices on I2C line)
uint8_t read (void)
 Read Voltage value (percentage)
float read_real_value (void)
 Read Voltage value (real voltage)

Detailed Description

Read nRF51822 VDD volatage and return 0 to 100% charging level.

 #include "mbed.h"
 #include "nRF51_Vdd.h"

 nRF51_Vdd vdd(3.6f, 1.8f);
 // or follows if you don't use ADC function (more low current)
 // nRF51_Vdd vdd(3.6f, 1.8f, ONLY4VDD);

 int main() {
 uint8_t batteryLevel;
 float batt;

   while(true){
      wait(1.0);
      batteryLevel = vdd.read();
      batt = vdd.read_real_value();
   }
 }

Definition at line 50 of file nRF51_Vdd.h.


Constructor & Destructor Documentation

nRF51_Vdd ( float  vdd100percent,
float  vddzeropercent,
uint8_t  adc_use 
)

Configure data pin.

Parameters:
100%voltage reference value
0%voltage reference value
LOWPOWER MODE (none zero) Use PWR_DWN or USE_ADC

Definition at line 22 of file nRF51_Vdd.cpp.

nRF51_Vdd ( float  vdd100percent,
float  vddzeropercent 
)

Configure data pin.

Parameters:
100%voltage reference value
0%voltage reference value

Definition at line 28 of file nRF51_Vdd.cpp.

nRF51_Vdd ( void   )

Configure data pin (with other devices on I2C line)

Parameters:
none

Definition at line 34 of file nRF51_Vdd.cpp.


Member Function Documentation

uint8_t read ( void   )

Read Voltage value (percentage)

Parameters:
none
Returns:
0 to 100%

Definition at line 77 of file nRF51_Vdd.cpp.

float read_real_value ( void   )

Read Voltage value (real voltage)

Parameters:
none
Returns:
real voltage (example 3.30V)

Definition at line 40 of file nRF51_Vdd.cpp.