Battery Reading

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
dnulty
Date:
Fri Nov 08 10:51:33 2019 +0000
Commit message:
Battery Reading

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Nov 08 10:51:33 2019 +0000
@@ -0,0 +1,23 @@
+#include "mbed.h"
+
+AnalogIn v_bat(PB_1);
+AnalogIn v_5(PC_2);
+AnalogIn v_3(PF_4);
+//A2 and A3 for top and base battery charges respectively
+//cut off voltage at 3.3v or higher - technical max is 4.2v,
+//but there is no built-in hardware cutoff!
+
+//MON_VBATT PB_1
+//MON_5V0   PC_2
+//MON_3V3   PF_4
+
+int main() {
+    Serial pc(USBTX, USBRX);
+    while(1) {
+        float analogue5V = v_5.read();
+        float analogue33V = v_3.read();
+        float analogueValue = v_bat.read();
+        pc.printf("Voltage readings are: VBATT: %f 5V0: %f 3V3: %f\n\r", analogueValue, analogue5V, analogue33V);
+        wait_ms(1000);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Nov 08 10:51:33 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file