thomca96
Posts: 9
Joined: Mon Feb 04, 2019 11:11 am

LIPO SIHM for Raspberry Pi Zero

Sun Feb 24, 2019 10:53 am

Hi,
I want to feed my raspberry pi zero with a LiPo battery and i found following product:
https://thepihut.com/products/lipo-shim
If I am going to solder the power supply SIHM on the py, is it afterwards possible to use the GPIO pins of the PI which are connected with the SIHM? For my project i need both I2C pins on the PI therefore i am not sure if I am going to solder the SIHM on the Pi zero if it possible to use the I2C pins without any problem?

Andyroo

Re: LIPO SIHM for Raspberry Pi Zero

Sun Feb 24, 2019 7:38 pm

If you look at the pin out for the shim here you will see that it uses BCM pin 4 (physical pin 7) and power while i2C on the Pi uses BCM pins 0,1,2 and 3 - see here

As long as you do not fry the Pi, melt the plastic or short the shim / Pi out you should get away with it :lol:

You should play double safe though and talk to the folk at The Pi Hut and check what you want to connect will be OK as they are very friendly and knowledgeable.

If you find things do not quite fit you can get extension pins that lift boards up.

Three things to consider:
1) How are you going to charge the battery - this board does not do that?
2) Watch the total current draw - the board is rated for up to 1.5A continuous current - that may be fine for a Pi Zero W but well under a Pi 3 needs at boot.
3) Batteries do not like the cold - I used to work with kit at -16 to -40 deg C and could see the batteries drain as you looked at them... What may last 1 hour in the office / home may last minutes out doors.

thomca96
Posts: 9
Joined: Mon Feb 04, 2019 11:11 am

Re: LIPO SIHM for Raspberry Pi Zero

Sun Feb 24, 2019 9:29 pm

Perfect, thanks for your answer.
Do I need to set the GPIO pin 4 of the SIHM in my code?
Charging the battery and temperature are no problem it is only for a small project for school.
So it should not be a problem to connect a sensor to the I2C pins aftet soldering the SIHM on the Pi.

Andyroo

Re: LIPO SIHM for Raspberry Pi Zero

Sun Feb 24, 2019 9:56 pm

By the look of it, they run a small program in the background (a daemon) to handle the power low condition and all its code can be found here on Github

You could use that to shut down the Pi when the battery runs out or you could do the work in your program.

A quick read of the script (and I am weak in this area) it seems that the pin config is set up by line 62 with raspi-gpio set $trigger_pin ip pu and this toolkit is installed with:

Code: Select all

sudo apt install raspi-gpio
and the help text gives a neat version of:
raspi-gpio help

WARNING! raspi-gpio set writes directly to the GPIO control registers
ignoring whatever else may be using them (such as Linux drivers) -
it is designed as a debug tool, only use it if you know what you
are doing and at your own risk!

The raspi-gpio tool is designed to help hack / debug BCM283x GPIO.
Running raspi-gpio with the help argument prints this help.
raspi-gpio can get and print the state of a GPIO (or all GPIOs)
and can be used to set the function, pulls and value of a GPIO.
raspi-gpio must be run as root.
Use:
raspi-gpio get [GPIO]
OR
raspi-gpio set <GPIO> [options]
OR
raspi-gpio funcs [GPIO]
OR
raspi-gpio raw

GPIO is a comma-separated list of pin numbers or ranges (without spaces),
e.g. 4 or 18-21 or 7,9-11
Note that omitting [GPIO] from raspi-gpio get prints all GPIOs.
raspi-gpio funcs will dump all the possible GPIO alt funcions in CSV format
or if [GPIO] is specified the alternate funcs just for that specific GPIO.
Valid [options] for raspi-gpio set are:
ip set GPIO as input
op set GPIO as output
a0-a5 set GPIO to alternate function alt0-alt5
pu set GPIO in-pad pull up
pd set GPIO pin-pad pull down
pn set GPIO pull none (no pull)
dh set GPIO to drive to high (1) level (only valid if set to be an output)
dl set GPIO to drive low (0) level (only valid if set to be an output)
Examples:
raspi-gpio get Prints state of all GPIOs one per line
raspi-gpio get 20 Prints state of GPIO20
raspi-gpio get 20,21 Prints state of GPIO20 and GPIO21
raspi-gpio set 20 a5 Set GPIO20 to ALT5 function (GPCLK0)
raspi-gpio set 20 pu Enable GPIO20 ~50k in-pad pull up
raspi-gpio set 20 pd Enable GPIO20 ~50k in-pad pull down
raspi-gpio set 20 op Set GPIO20 to be an output
raspi-gpio set 20 dl Set GPIO20 to output low/zero (must already be set as an output)
raspi-gpio set 20 ip pd Set GPIO20 to input with pull down
raspi-gpio set 35 a0 pu Set GPIO35 to ALT0 function (SPI_CE1_N) with pull up
raspi-gpio set 20 op pn dh Set GPIO20 to ouput with no pull and driving high
so the command (raspi-gpio set $trigger_pin ip pu) is:

raspi-gpio set Call the program from the command line to set the state of a pin
$trigger_pin This is pin 4 in this case (defined on line 44 of the script)
ip GPIO as input
pu GPIO internal pull up set on

You could emulate that in your program set-up and trigger a routine if this is pulled down by the shim (I think - still learning).

Please remember a little knowledge is dangerous - therefore I am a danger to your Pi :oops: At worst case you could need the £35 fix :lol: :o

thomca96
Posts: 9
Joined: Mon Feb 04, 2019 11:11 am

Re: LIPO SIHM for Raspberry Pi Zero

Mon Feb 25, 2019 8:54 am

So if I have understod it right, i only need to run the deamon code once before using the pi with the LiPo SIHM. Afterwards I should be able to use the py normally with a LiPo battery whereby it is also possible to use the I2C pins of the 2-3 for my sensor?

Return to “Beginners”