Gameboy Raspberry Zero Batterymonitoring with MCP3008
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.



Hardware part

  1. Buy a MCP3008 and some resistors suitable for this project, you can calculate resistor value here: voltage divider calculator, Vin = 4.2V and Vout needs to be maximum 3.3V. I used a 2kOhm and a 5,6kOhm resistor.
  2. Wire up the MCP3008 like this mockup: Image of wiring
  3. Measure the voltage of the connecting point of the two resistors and to ground, it should not be over 3.3V
  4. If you want you can wire up LEDs aswell.

Software part

  1. Install Raspidmx (pngview) and compile it by using make
  2. Install this script by running the following command from terminal or ssh: git clone
  3. Navigate into the gbzbatterymonitor folder: cd gbzbatterymonitor
  4. Edit the config by typing nano Here you must edit the battery voltages to suit your needs, add the path to pngview and icons and add the resistor values.
  5. Test the script by running command: python
  6. If the script runs as desired you can close it by pressing Ctrl+C
  7. Add the script to startup by typing sudo nano /etc/rc.local and add python /home/pi/gbzbattery/ & before exit 0
  8. Reboot to test
  9. You can close the script by killing its process id. Find the id by typing ps aux | grep gbzbattery. Then kill <id>


  1. Charge your battery to 100%
  2. Run python to get the exact values from the battery
  3. Let the battery run down to 3.2V
  4. Copy the data to Excel or something simular and calculate the 75%, 50% and 25% values
  5. Edit the file with the newly gattered data to get more accurate batterymeter
Sources and inspiration: