Hello! I just received my Weather Carrier Board and the ESP32 MicroMod processor. I have been looking around and I cannot for the life of me figure out a way to test what the battery level is. I have the Sunny Buddy Solar Charger which is connected to the 9W power supply and the 6 Ah LiPo battery. From there I have a USB-C Pigtail plugged into the Carrier Board.
It could be super obvious and I’m just overlooking it, but I would ideally like to monitor voltage of the battery to keep an eye on it, I’m sure it’ll be fine either way, I just like having extra numbers to look at
The cursed MicroMod 20k/10k 3:1 resistive voltage divider is tied to GPI39 of the ESP32. This should be able to allow you to perform an analog measurement of the voltage applied to the USB connector of the Weather Carrier Board with some simple math.
The voltage from the USB connector is applied to a voltage divider that divides it by 3 (20kΩ/10kΩ) so that it can be read by an analog pin, which is typically limited to the range 0-3.3 V.
In this case, it is VIN/3 on the Weather Shield you are interested in, which corresponds to pin 49 on the MicroMod connector. This, in turn, is connected to GPIO 39 on the ESP32.
So if you read the analog voltage on GPIO39 on the ESP32, taking into consideration the necessary math to convert back to the 5V input voltage, you should be able to tell what the voltage is. This voltage divider was not a good design aspect of the early MicroMod products and more recently SparkFun has started using specific ICs to measure the battery voltage instead.
For the code, it might look something like below. It assumes a 3.3V reference voltage and 12-bit ADC.
float voltage = analogRead(BATT_VIN);
voltage *= ((20000.0 + 10000.0) / 10000.0);
voltage *= 3.3;
voltage /= 4096;
Serial.print("voltage: "); Serial.println(voltage);