That is correct
[GUIDE] Battery icon indicator guide with MCP3008
-
- Posts: 48
- Joined: Fri Sep 30, 2016 12:17 am
- Has thanked: 11 times
- Been thanked: 6 times
Re: [GUIDE] Battery icon indicator guide with MCP3008
Hello everyone.
I'm interested into this battery indicator for a personal project with a raspberry pi3 (but not a game console).
I'm looking at wiring everything, following this picture :

I've got 2 questions :
1/ On this picture, we can see a grey wire connected to #21 on pi gpio, but going nowhere. Do you have an explanation ?
2/ Your white wire is going to CS0 pin, but I can't find it on this GPIO chart ? Does-it correspond to SPI_CE0_N (gpio 8/pin24) ?

Regards !
I'm interested into this battery indicator for a personal project with a raspberry pi3 (but not a game console).
I'm looking at wiring everything, following this picture :

I've got 2 questions :
1/ On this picture, we can see a grey wire connected to #21 on pi gpio, but going nowhere. Do you have an explanation ?
2/ Your white wire is going to CS0 pin, but I can't find it on this GPIO chart ? Does-it correspond to SPI_CE0_N (gpio 8/pin24) ?

Regards !
- jostie94
- Posts: 51
- Joined: Sat Apr 01, 2017 3:34 am
- Location: the netherlands
- Has thanked: 5 times
- Been thanked: 28 times
Re: [GUIDE] Battery icon indicator guide with MCP3008
I do not get any ouput of the battery meter.
Code: Select all
pi@retropie:~/gbzbatterymonitor $ python main.py
Batteries 100% voltage: 4.1
Batteries 75% voltage: 3.76
Batteries 50% voltage: 3.63
Batteries 25% voltage: 3.5
Batteries dangerous voltage: 3.2
ADC 100% value: 937.441786284
ADC 75% value: 859.702711324
ADC 50% value: 829.978947368
ADC 25% value: 800.255183413
ADC dangerous voltage value: 731.661881978
loadpng: can't open file for reading
unable to load /home/pi/gbzbattery/icons/blank.png
pngview: ../common/imageLayer.c:80: createResourceImageLayer: Assertion `result == 0' failed.
ADC value: 0 (0.0 V)
ADC value: 0 (0.0 V)
ADC value: 0 (0.0 V)
^Cpngview: no process found
my GBZ builds:
1) http://www.sudomod.com/forum/viewtopic.php?f=9&t=3197
------------------------------------------------------------------------------------------
1) http://www.sudomod.com/forum/viewtopic.php?f=9&t=3197
------------------------------------------------------------------------------------------
Re: [GUIDE] Battery icon indicator guide with MCP3008
This looks awesome! Does the battery indicator always show, even on top of games? Or is it only shown on the menu? If the latter, is there a way to configure a button combination to display the indicator so I can check how much battery I have left without exiting the game?
In any case, great work. This looks hella rad.
In any case, great work. This looks hella rad.
I've just finished my milk.
Re: [GUIDE] Battery icon indicator guide with MCP3008
Just an editing error, its not supposed to be there in the first place

I don't have a RPi3, so cant answer that, but try googling RPI 3 SPI.
Re: [GUIDE] Battery icon indicator guide with MCP3008
Always on top, even on gamesmuniosi wrote: ↑Fri Jun 09, 2017 6:50 pmThis looks awesome! Does the battery indicator always show, even on top of games? Or is it only shown on the menu? If the latter, is there a way to configure a button combination to display the indicator so I can check how much battery I have left without exiting the game?
In any case, great work. This looks hella rad.

Re: [GUIDE] Battery icon indicator guide with MCP3008
Have you entered the right pin numbers in the config file? Is the mcp connected properly? Is pngview installed?jostie94 wrote: ↑Wed Jun 07, 2017 6:49 amI do not get any ouput of the battery meter.
Code: Select all
pi@retropie:~/gbzbatterymonitor $ python main.py Batteries 100% voltage: 4.1 Batteries 75% voltage: 3.76 Batteries 50% voltage: 3.63 Batteries 25% voltage: 3.5 Batteries dangerous voltage: 3.2 ADC 100% value: 937.441786284 ADC 75% value: 859.702711324 ADC 50% value: 829.978947368 ADC 25% value: 800.255183413 ADC dangerous voltage value: 731.661881978 loadpng: can't open file for reading unable to load /home/pi/gbzbattery/icons/blank.png pngview: ../common/imageLayer.c:80: createResourceImageLayer: Assertion `result == 0' failed. ADC value: 0 (0.0 V) ADC value: 0 (0.0 V) ADC value: 0 (0.0 V) ^Cpngview: no process found
- jostie94
- Posts: 51
- Joined: Sat Apr 01, 2017 3:34 am
- Location: the netherlands
- Has thanked: 5 times
- Been thanked: 28 times
Re: [GUIDE] Battery icon indicator guide with MCP3008
i checked wiring and re installed the battery monitor.
there is a output now:
i can't get the pngview working...
there is a output now:
python main.py outputShow
pi@retropie:~/gbzbatterymonitor $ python main.py
/home/pi/gbzbatterymonitor/mcp3008.py:78: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(SPIMOSI, GPIO.OUT)
/home/pi/gbzbatterymonitor/mcp3008.py:80: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(SPICLK, GPIO.OUT)
/home/pi/gbzbatterymonitor/mcp3008.py:81: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(SPICS, GPIO.OUT)
Batteries 100% voltage: 4.1
Batteries 75% voltage: 3.76
Batteries 50% voltage: 3.63
Batteries 25% voltage: 3.5
Batteries dangerous voltage: 3.2
ADC 100% value: 937.441786284
ADC 75% value: 859.702711324
ADC 50% value: 829.978947368
ADC 25% value: 800.255183413
ADC dangerous voltage value: 731.661881978
ADC value: 314 (1.37331194196 V)
ADC value: 314 (1.37331194196 V)
ADC value: 314 (1.37331194196 V)
^Cpngview: no process found
/home/pi/gbzbatterymonitor/mcp3008.py:78: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(SPIMOSI, GPIO.OUT)
/home/pi/gbzbatterymonitor/mcp3008.py:80: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(SPICLK, GPIO.OUT)
/home/pi/gbzbatterymonitor/mcp3008.py:81: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(SPICS, GPIO.OUT)
Batteries 100% voltage: 4.1
Batteries 75% voltage: 3.76
Batteries 50% voltage: 3.63
Batteries 25% voltage: 3.5
Batteries dangerous voltage: 3.2
ADC 100% value: 937.441786284
ADC 75% value: 859.702711324
ADC 50% value: 829.978947368
ADC 25% value: 800.255183413
ADC dangerous voltage value: 731.661881978
ADC value: 314 (1.37331194196 V)
ADC value: 314 (1.37331194196 V)
ADC value: 314 (1.37331194196 V)
^Cpngview: no process found
my config.py fileShow
"""
" Edit below this line to fit your needs
"""
# Path to pngview (raspidmx) and icons
PNGVIEWPATH = "/home/pi/raspidmx/pngview"
ICONPATH = "/home/pi/gbzbatterymonitor/icons"
# Battery icon, LED or videoclips? Or all of them?
LEDS = 0
ICON = 1
CLIPS = 1
# GPIO (BOARD numbering scheme) pin for good voltage LED
GOODVOLTPIN = 18
LOWVOLTPIN = 17
# Fully charged voltage, voltage at the percentage steps and shutdown voltage. This is where you edit when finetuning the batterymonitor
# by using the monitor.py script.
VOLT100 = 4.1
VOLT75 = 3.76
VOLT50 = 3.63
VOLT25 = 3.5
VOLT0 = 3.2
# Value (in ohms) of the lower resistor from the voltage divider, connected to the ground line (1 if no voltage divider).
# Default value (2000) is for a lipo battery, stepped down to about 3.2V max.
LOWRESVAL = 2000
# Value (in ohms) of the higher resistor from the voltage divider, connected to the positive line (0 if no voltage divider).
# Default value (5600) is for a lipo battery, stepped down to about 3.2V max.
HIGHRESVAL = 5600
# ADC voltage reference (3.3V for Raspberry Pi)
ADCVREF = 3.3
# MCP3008 channel to use (from 0 to 7)
ADCCHANNEL = 0
# Refresh rate (s)
REFRESH_RATE = 2
# Display some debug values when set to 1, and nothing when set to 0
DEBUGMSG = 1
# Voltage value measured by the MCP3008 when batteries are fully charged. It should be near 3.3V due to Raspberry Pi GPIO compatibility)
# Be careful to edit below this line.
SVOLT100 = (VOLT100)*(HIGHRESVAL)/(LOWRESVAL+HIGHRESVAL)
SVOLT75 = (VOLT75)*(HIGHRESVAL)/(LOWRESVAL+HIGHRESVAL)
SVOLT50 = (VOLT50)*(HIGHRESVAL)/(LOWRESVAL+HIGHRESVAL)
SVOLT25 = (VOLT25)*(HIGHRESVAL)/(LOWRESVAL+HIGHRESVAL)
SVOLT0 = (VOLT0)*(HIGHRESVAL)/(LOWRESVAL+HIGHRESVAL)
# MCP3008 scaling
ADC100 = SVOLT100 / (ADCVREF / 1024.0)
ADC75 = SVOLT75 / (ADCVREF / 1024.0)
ADC50 = SVOLT50 / (ADCVREF / 1024.0)
ADC25 = SVOLT25 / (ADCVREF / 1024.0)
ADC0 = SVOLT0 / (ADCVREF / 1024.0)
" Edit below this line to fit your needs
"""
# Path to pngview (raspidmx) and icons
PNGVIEWPATH = "/home/pi/raspidmx/pngview"
ICONPATH = "/home/pi/gbzbatterymonitor/icons"
# Battery icon, LED or videoclips? Or all of them?
LEDS = 0
ICON = 1
CLIPS = 1
# GPIO (BOARD numbering scheme) pin for good voltage LED
GOODVOLTPIN = 18
LOWVOLTPIN = 17
# Fully charged voltage, voltage at the percentage steps and shutdown voltage. This is where you edit when finetuning the batterymonitor
# by using the monitor.py script.
VOLT100 = 4.1
VOLT75 = 3.76
VOLT50 = 3.63
VOLT25 = 3.5
VOLT0 = 3.2
# Value (in ohms) of the lower resistor from the voltage divider, connected to the ground line (1 if no voltage divider).
# Default value (2000) is for a lipo battery, stepped down to about 3.2V max.
LOWRESVAL = 2000
# Value (in ohms) of the higher resistor from the voltage divider, connected to the positive line (0 if no voltage divider).
# Default value (5600) is for a lipo battery, stepped down to about 3.2V max.
HIGHRESVAL = 5600
# ADC voltage reference (3.3V for Raspberry Pi)
ADCVREF = 3.3
# MCP3008 channel to use (from 0 to 7)
ADCCHANNEL = 0
# Refresh rate (s)
REFRESH_RATE = 2
# Display some debug values when set to 1, and nothing when set to 0
DEBUGMSG = 1
# Voltage value measured by the MCP3008 when batteries are fully charged. It should be near 3.3V due to Raspberry Pi GPIO compatibility)
# Be careful to edit below this line.
SVOLT100 = (VOLT100)*(HIGHRESVAL)/(LOWRESVAL+HIGHRESVAL)
SVOLT75 = (VOLT75)*(HIGHRESVAL)/(LOWRESVAL+HIGHRESVAL)
SVOLT50 = (VOLT50)*(HIGHRESVAL)/(LOWRESVAL+HIGHRESVAL)
SVOLT25 = (VOLT25)*(HIGHRESVAL)/(LOWRESVAL+HIGHRESVAL)
SVOLT0 = (VOLT0)*(HIGHRESVAL)/(LOWRESVAL+HIGHRESVAL)
# MCP3008 scaling
ADC100 = SVOLT100 / (ADCVREF / 1024.0)
ADC75 = SVOLT75 / (ADCVREF / 1024.0)
ADC50 = SVOLT50 / (ADCVREF / 1024.0)
ADC25 = SVOLT25 / (ADCVREF / 1024.0)
ADC0 = SVOLT0 / (ADCVREF / 1024.0)
i can't get the pngview working...
Last edited by jostie94 on Wed Jun 14, 2017 3:19 pm, edited 1 time in total.
my GBZ builds:
1) http://www.sudomod.com/forum/viewtopic.php?f=9&t=3197
------------------------------------------------------------------------------------------
1) http://www.sudomod.com/forum/viewtopic.php?f=9&t=3197
------------------------------------------------------------------------------------------
Who is online
Users browsing this forum: No registered users and 1 guest