Using the Proto Tripler PiCowbell with Arduino to monitor and display the voltage of an attached lipoly battery involves plugging a Pico or Pico W board into the PiCowbell, attaching a compatible battery to the JST 2-PH port, attaching an EYESPI display to the EYESPI connector 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 Tripler PiCowbell exactly as shown below. Then, plug in a supported lipoly battery to the PiCowbell JST 2-PH port. Finally, attach an EYESPI display to the EYESPI connector. Here's an example of connecting a Pico to the PiCowbell with a lipoly battery.
Connect the Pico with plug headers into the Proto Tripler PiCowbell. It should be plugged in with the Pico USB port pointing towards the STEMMA QT port.
Then, plug in a lipoly battery with matching polarity to the JST 2-PH port on the PiCowbell.
Finally, attach the EYESPI display to the EYESPI connector with an EYESPI cable. For reference on plugging in an EYESPI cable, you can follow along with this Learn Guide page.
Library Installation
You can install the Adafruit ST7735 and ST7789 library for Arduino using the Library Manager in the Arduino IDE.
Click the Manage Libraries ... menu item, search for Adafruit_ST7789, and select the Adafruit ST7735 and ST7789 library:
If asked about dependencies, click "Install all".
If the "Dependencies" window does not come up, then you already have the dependencies installed.
If the dependencies are already installed, you must make sure you update them through the Arduino Library Manager before loading the example!
Then, search for Adafruit NeoPixel, and select the Adafruit NeoPixel library. This library has no additional dependencies.
The NeoPixel library has no additional dependencies.
// SPDX-FileCopyrightText: 2024 Liz Clark for Adafruit Industries // // SPDX-License-Identifier: MIT #include <Adafruit_NeoPixel.h> #include <Adafruit_GFX.h> // Core graphics library #include <Adafruit_ST7789.h> // Hardware-specific library for ST7789 #include <SPI.h> #include <Fonts/FreeSansBold24pt7b.h> #define LED LED_BUILTIN #define TFT_CS 21 #define TFT_RST -1 #define TFT_DC 20 #define NEO_PIN A2 uint32_t Wheel(byte WheelPos); Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST); Adafruit_NeoPixel pixel = Adafruit_NeoPixel(1, NEO_PIN, NEO_GRB + NEO_KHZ800); unsigned long lastMillis = 0; uint8_t j = 0; void setup() { Serial.begin(115200); //while (!Serial) delay(1); // wait for serial port tft.init(240, 240); pinMode(LED, OUTPUT); delay (100); Serial.println("PiCowbell Tripler Demo"); tft.setFont(&FreeSansBold24pt7b); pixel.begin(); pixel.setBrightness(50); pixel.show(); // Initialize all pixels to 'off' lastMillis = millis(); } void loop() { if (millis() > (lastMillis + 5000)) { 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); tft.fillScreen(ST77XX_BLACK); tft.setCursor(240 / 4, 240 / 2); tft.setTextColor(ST77XX_WHITE); tft.printf("%0.1f V", vsys); lastMillis = millis(); } pixel.setPixelColor(0, Wheel(j++)); pixel.show(); delay(20); } uint32_t Wheel(byte WheelPos) { WheelPos = 255 - WheelPos; if(WheelPos < 85) { return pixel.Color(255 - WheelPos * 3, 0, WheelPos * 3); } if(WheelPos < 170) { WheelPos -= 85; return pixel.Color(0, WheelPos * 3, 255 - WheelPos * 3); } WheelPos -= 170; return pixel.Color(WheelPos * 3, 255 - WheelPos * 3, 0); }
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, the reading shows 4.8V from the USB power. Then, a battery was plugged in and was providing a reading of approximately 4.6V.
The display will show the voltage reading as well and will update every 5 seconds. The onboard NeoPixel will show a rainbow swirl animation.
Page last edited January 21, 2025
Text editor powered by tinymce.