File tree Expand file tree Collapse file tree 3 files changed +47
-0
lines changed
Arduino_PiCowbell_Doubler_Battery_Monitor
CircuitPython_PiCowbell_Doubler_Battery_Monitor Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Original file line number Diff line number Diff line change 1+ // SPDX-FileCopyrightText: 2024 Limor Fried for Adafruit Industries
2+ //
3+ // SPDX-License-Identifier: MIT
4+
5+ #define LED LED_BUILTIN
6+
7+ void setup () {
8+ Serial.begin (115200 );
9+ // while (!Serial) delay(1); // wait for serial port
10+ pinMode (LED, OUTPUT);
11+ delay (100 );
12+ Serial.println (" PiCowbell Doubler Battery Monitor" );
13+
14+ }
15+
16+ void loop () {
17+ digitalWrite (LED, HIGH);
18+ // get the on-board voltage
19+ float vsys = analogRead (A3) * 3 * 3.3 / 1023.0 ;
20+ Serial.printf (" Vsys: %0.1f V" , vsys);
21+ Serial.println ();
22+
23+ digitalWrite (LED, LOW);
24+ delay (5000 );
25+ }
Original file line number Diff line number Diff line change 1+ # SPDX-FileCopyrightText: 2024 ladyada for Adafruit Industries
2+ #
3+ # SPDX-License-Identifier: MIT
4+
5+ import time
6+ import board
7+ from analogio import AnalogIn
8+ from digitalio import DigitalInOut , Direction
9+
10+ led = DigitalInOut (board .LED )
11+ led .direction = Direction .OUTPUT
12+
13+ analog_in = AnalogIn (board .A3 )
14+
15+ def get_vsys (pin ):
16+ return ((pin .value * 3 ) * 3.3 ) / 65536
17+
18+ while True :
19+ led .value = True
20+ print (f"The battery level is: { get_vsys (analog_in ):.1f} V" )
21+ led .value = False
22+ time .sleep (5 )
You can’t perform that action at this time.
0 commit comments