Using the Proto Doubler PiCowbell with Arduino to monitor the voltage of an attached lipoly battery involves plugging a Pico or Pico W board into the PiCowbell, attaching a compatible battery to the JST2-PH port and running the provided example code.
Raspberry Pi Pico ADC3 and VSYS
The Raspberry Pi Pico can use its internal ADC3 pin (GPIO29) to monitor the voltage on VSYS. As a result, you can read the voltage currently being supplied to VSYS (aka the voltage from your battery) with this calculation in Arduino:
((ADC3 value * 3) * 3.3) / 1023.0
Wiring
Plug a Pico or Pico W into your Proto Doubler PiCowbell exactly as shown below. Then, plug in a supported lipoly battery to the PiCowbell JST 2-PH port. Here's an example of connecting a Pico to the PiCowbell with a lipoly battery.
Connect the Pico with plug headers into the Proto Doubler PiCowbell. It should be plugged in with the Pico USB port pointing towards the STEMMA QT port and the USB text on the PiCowbell board silk.
Then, plug in a lipoly battery with matching polarity to the JST 2-PH port on the PiCowbell.
// SPDX-FileCopyrightText: 2024 Limor Fried for Adafruit Industries // // SPDX-License-Identifier: MIT #define LED LED_BUILTIN void setup() { Serial.begin(115200); // while (!Serial) delay(1); // wait for serial port pinMode(LED, OUTPUT); delay (100); Serial.println("PiCowbell Doubler Battery Monitor"); } void loop() { digitalWrite(LED, HIGH); // get the on-board voltage float vsys = analogRead(A3) * 3 * 3.3 / 1023.0; Serial.printf("Vsys: %0.1f V", vsys); Serial.println(); digitalWrite(LED, LOW); delay(5000); }
Upload the sketch to your board and open up the Serial Monitor (Tools -> Serial Monitor) at 115200 baud. You'll see the voltage calculation printed to the monitor. In the screenshot below, a battery was plugged in and was providing a reading of approximately 4.4V. After the battery was unplugged, the reading changed to 4.9V from the USB power.
Page last edited January 22, 2025
Text editor powered by tinymce.