Battery level readout


#1

Thought people might be interested in this. I’ve recently gotten more into my Cardputer at length and have found that I’d like to know how the battery is doing. Per the back of the device, GPIO 10 is connected to a voltage divider which will scale the battery voltage for the 12-bit ADC. Putting that math together (against a max ADC voltage of 3300):

(defun bat nil 
  (princ
    (concatenate
      'string
      (string
        (*
          100
          (/ (analogread 10) 3300)))
      "%"))
  nothing)

Output:

> (bat)
98.2%

Relevant part of the schematic:


#2

Awesome! I saw that pin 10 was something to do the battery but I couldn’t figure out what to do with the value