A simple example for analog input and EPD usage.
Dependencies: GDEP015OC1 acn_nrf52_saadc aconno_bsp
Fork of acd52832_Car_battery_ch by
Revision 11:6c6bebdfff06, committed 2017-10-09
- Comitter:
- jurica238814
- Date:
- Mon Oct 09 11:15:18 2017 +0000
- Parent:
- 10:8a9eb611624e
- Commit message:
- Diff inputs adc works ok.; Problem with this version: to high input voltage on single input (>3V3). Has to be sold in hardware.
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 8a9eb611624e -r 6c6bebdfff06 main.cpp --- a/main.cpp Fri Oct 06 14:33:57 2017 +0000 +++ b/main.cpp Mon Oct 09 11:15:18 2017 +0000 @@ -1,4 +1,5 @@ -/* Copyright (c) 2017 Aconno. All Rights Reserved. +/* + * Copyright (c) 2017 Aconno. All Rights Reserved. * * Licensees are granted free, non-transferable use of the information. NO * WARRANTY of ANY KIND is provided. This heading must NOT be removed from @@ -104,8 +105,8 @@ /* Change NUM_OF_DIFF_ADCs in the header */ diffADCs[0] = new NRF52_SAADC(ANALOG_PIN_P, ANALOG_PIN_N); - NRF52_SAADC usb1(7); // P29, AIN5 - NRF52_SAADC usb2(6); // p30, AIN6 + //NRF52_SAADC usb1(7); // P29, AIN5 + //NRF52_SAADC usb2(6); // p30, AIN6 char low_string[25] = "LOW"; char quick_string[25] = "QUICK"; @@ -132,8 +133,8 @@ while(true){ adc1_mean += diffADCs[0]->read(); - adc2_mean += usb1.read(); - adc3_mean += usb2.read(); + adc2_mean += 1; //usb1.read(); + adc3_mean += 1; //usb2.read(); count ++; if (count == NUM_OF_MEASUREMENTS){ @@ -144,8 +145,8 @@ count = 0; //voltage[i] = ((float)(diffADCs[i]->read()))*(3.3f/8192.0); // Convert raw data into voltage - //battery_voltage = ((float)(diffADCs[0]->read()*(3.3f/8192.0)*VOLTAGE_DIVIDER_RATION)); battery_voltage = ((float)(diffADCs[0]->read()*(3.3f/8192.0))); + //battery_voltage = ((float)(diffADCs[0]->read()*(3.3f/8192.0))); //battery_voltage = adc1_mean*(ADC_REF_VOLTAGE/ADC_MAX_VALUE); usb1_current = (adc2_mean*(ADC_REF_VOLTAGE/(ADC_MAX_VALUE*2))) * CURRENT_FACTOR; usb2_current = (adc3_mean*(ADC_REF_VOLTAGE/(ADC_MAX_VALUE*2))) * CURRENT_FACTOR;