Page 3 of 5
Re: [GUIDE] Battery icon indicator guide with MCP3008
Posted: Sun Apr 16, 2017 4:39 am
by activex
jostie94 wrote: ↑Sun Apr 16, 2017 4:33 am
The battery connects directly to the MCP3008 and directly to the power boost?
That is correct
Re: [GUIDE] Battery icon indicator guide with MCP3008
Posted: Mon Apr 17, 2017 9:48 am
by Barbosik
jostie94 wrote: ↑Sun Apr 16, 2017 4:33 am
The battery connects directly to the MCP3008 and directly to the power boost?
That's what i have been looking for.
Thanks
Re: [GUIDE] Battery icon indicator guide with MCP3008
Posted: Sun Apr 23, 2017 9:23 pm
by Cyborg_delta1
Voltage calculator website is down
Re: [GUIDE] Battery icon indicator guide with MCP3008
Posted: Wed Jun 07, 2017 1:20 am
by krevett
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 !
Re: [GUIDE] Battery icon indicator guide with MCP3008
Posted: Wed Jun 07, 2017 6:49 am
by jostie94
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
Re: [GUIDE] Battery icon indicator guide with MCP3008
Posted: Fri Jun 09, 2017 6:50 pm
by muniosi
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.
Re: [GUIDE] Battery icon indicator guide with MCP3008
Posted: Sat Jun 10, 2017 2:05 am
by activex
krevett wrote: ↑Wed Jun 07, 2017 1:20 am
1/ On this picture, we can see a grey wire connected to #21 on pi gpio, but going nowhere. Do you have an explanation?
Just an editing error, its not supposed to be there in the first place
krevett wrote: ↑Wed Jun 07, 2017 1:20 am
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) ?
I don't have a RPi3, so cant answer that, but try googling RPI 3 SPI.
Re: [GUIDE] Battery icon indicator guide with MCP3008
Posted: Sat Jun 10, 2017 2:05 am
by activex
muniosi wrote: ↑Fri Jun 09, 2017 6:50 pm
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.
Always on top, even on games
Re: [GUIDE] Battery icon indicator guide with MCP3008
Posted: Sat Jun 10, 2017 2:07 am
by activex
jostie94 wrote: ↑Wed Jun 07, 2017 6:49 am
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
Have you entered the right pin numbers in the config file? Is the mcp connected properly? Is pngview installed?
Re: [GUIDE] Battery icon indicator guide with MCP3008
Posted: Mon Jun 12, 2017 4:02 pm
by jostie94
i checked wiring and re installed the battery monitor.
there is a output now:
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
"""
" 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...