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

This is only for nRF51822.

You don't need any hardware circuit. Just read internal Vdd voltage using ADC function inside of the chip.

Revision:
3:faf2e448c15b
Parent:
2:9b1e219a7695
--- a/nRF51_Vdd.cpp	Sun May 29 00:54:11 2016 +0000
+++ b/nRF51_Vdd.cpp	Sat Apr 14 04:55:32 2018 +0000
@@ -3,11 +3,11 @@
  *  Read nRF51822 VDD volatage and return 100 to 0% charging level
  *      https://www.nordicsemi.com/eng/Products/Bluetooth-Smart-Bluetooth-low-energy/nRF51822
  *
- * Copyright (c) 2016 Kenji Arai / JH1PJL
+ * Copyright (c) 2016,'18 Kenji Arai / JH1PJL
  *  http://www.page.sannet.ne.jp/kenjia/index.html
- *  http://mbed.org/users/kenjiArai/
+ *  https://os.mbed.com/users/kenjiArai/
  *      Created:    January   23rd, 2016
- *      Revised:    May       29th, 2016
+ *      Revised:    April     14th, 2018
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
@@ -71,7 +71,7 @@
         NRF_ADC->POWER       = 0;
         nrf_delay_us(5);
     }
-    return ((float)wrk / 1024 * 1.2 * 3.0);            
+    return ((float)wrk / 1024.0f * 1.2f * 3.0f);            
 }
 
 uint8_t nRF51_Vdd::read(void){