Code Monkey home page Code Monkey logo

lifepo4wered-pi's Introduction

LiFePO4wered-Pi

Access library, command line tool and daemon for the LiFePO4wered/Pi+ and legacy LiFePO4wered/Pi and LiFePO4wered/Pi3 modules

Installation

Starting from a fresh Raspbian image, first install the build-essential, git and the systemd support library packages:

sudo apt-get -y install build-essential git libsystemd-dev

In a directory where you keep source code, clone the LiFePO4wered-Pi repository from GitHub:

git clone https://github.com/xorbit/LiFePO4wered-Pi.git

Get in to the source code directory:

cd LiFePO4wered-Pi/

Build the code:

make all

And install it:

sudo make user-install

That's it! You may need to restart for some configuration changes (such as enabling the I2C device) to take effect.

Legacy build scripts

The build and install commands were changed from what they originally were. To prevent confusion for people not reading this but following installation instructions in older manuals, build.py and INSTALL.sh are provided that just call the make commands above for legacy compatibility.

Daemon

The installation command installs a background program (lifepo4wered-daemon), along with scripts to start it. You can also start the daemon manually, it will by default run in the background, but you can force it to run in the foreground by adding the -f argument.

The daemon supports startup via systemd, including its notification and keepalive features. See man systemd.service for details.

If you do not want to include systemd support in the daemon, you can build the code with:

make all USE_SYSTEMD=0

CLI

The lifepo4wered-cli tool provides convenient access to the LiFePO4wered device's I2C registers. Run it without parameters to get help information:

lifepo4wered-cli

To get a full dump of all register values, try:

lifepo4wered-cli get

To get the current battery voltage in millivolts, try:

lifepo4wered-cli get vbat

To set the wake up time to an hour, run:

lifepo4wered-cli set wake_time 60

To set the auto-boot flag to make the Pi run whenever there is power to do so, but still be able to turn the Pi off with the button or from software, run:

lifepo4wered-cli set auto_boot 2

To make this change permanent by saving it to flash, run:

lifepo4wered-cli set cfg_write 0x46

The 0x46 value is a magic key to allow config flash writes.

Adjusting some of the register values can cause problems such as not being able to turn on the system using the touch button. To prevent permanently bricking the LiFePO4wered device, always test your changes thoroughly before writing them to flash. If you made a change that makes your LiFePO4wered device not work correctly, and it is not written to flash, you can undo it by unplugging the LiFePO4wered device and removing the LiFePO4 cell from the battery holder for a couple of minutes. The LiFePO4wered device should revert to its previous last saved state when you put the battery back.

Check out the product brief for the LiFePO4wered/Pi+ or legacy LiFePO4wered/Pi or LiFePO4wered/Pi3 devices for a complete list of registers and valid values and options available in each product. Alternatively, running lifepo4wered-cli get returns a dump with all valid registers for the connected device.

Permissions

The user running the lifepo4wered-cli tool needs to have sufficient privileges to access the I2C bus. On Raspbian, the pi user by default can access the bus because it is in the i2c group. If you run as a different user, you either need to add this user to the i2c group or run the tool with sudo. On other distributions, a different group name may be used. You can check the owner and group of the I2C device with:

ls -l /dev/i2c-1

The command line tool returns the following negative values to indicate error conditions:

Return value Condition
-1 Could not access the LiFePO4wered device to perform the specified operation. Usually this condition is caused by insufficient privileges when trying to access the I2C bus. Trying to run the command as root or with sudo to fix the problem. When writing settings, this value is also returned if a register is not writable.
-2 The I2C bus could be accessed and the operation is valid, but communication with the LiFePO4wered device failed. After trying several times (20 by default), the I2C bus transaction could not be completed successfully. This happens if the LiFePO4wered device is not physically present or if something (possibly another HAT) is preventing the I2C bus from operating correctly.

Balena

The included Dockerfile can be used to compile the daemon as a Balena compatible service. Typically this would be used in a multicontainer setup where the LiFePO4wered service would be separate from your application container(s). The Dockerfile uses the USE_BALENA=1 make parameter to alter the shutdown command to send a shutdown request to the Balena supervisor container and runs the daemon code in foreground mode using the -f flag.

The included Dockerfile uses a 64-bit Raspberry Pi 4 base image, if you are using a different Pi or 32-bit Balena base OS, you need to alter the base image in both ("build" and "run") FROM lines.

A docker-compose.yml file such as the one below should be created to include the LiFePO4wered service in your application, make it privileged (to access the I2C bus and set system time), and give it access to the supervisor API:

version: '2'
services:
  your-own-application-service:
    build: ./balena-node-hello-world
    ports:
      - "80:80"
  lifepo4wered-pi:
    build: ./LiFePO4wered-Pi
    privileged: true
    labels:
      io.balena.features.supervisor-api: '1'

If your application needs access to the LiFePO4wered device, the easiest approach may be to include the lifepo4wered-cli or liblifepo4wered.so with language bindings in your application's container, building it using the multistage approach demonstrated in our Dockerfile. Make sure you then also give your own application access to the I2C bus.

lifepo4wered-pi's People

Contributors

dixon1e avatar jookia avatar mmirate avatar smurfix avatar xorbit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lifepo4wered-pi's Issues

Nice, but it would be nice to have loss of external power logged

The main daemon only does something when the battery expires and the system needs to be shutdown. It would be nice if there was some way of signalling that external power was lost and we are now running on battery: i.e. something more akin to the level of information you get from something like a APC UPS

Connecting a 12 V PSU to the VIN pads

Since the LiFePO4wered/Pi+ can be powered from a wide input voltage range of 5V to 20V, I've soldered a 2-pin terminal block on VIN and hooked up a 12 V power supply.
Unfortunately just doing this seems to have broken my LiFePO4wered/Pi+.
And I've tried twice with the same results.

I know that the VIN pads are supposed to be directly connected to the micro USB connector pins, but trying to put 12 V from the same power supply directly through the micro USB connector seems to work perfectly.

Discharging faster than charging

All of a sudden, my unit is no longer charging/powering my device sufficiently. It will charge while it's powered off, but when on, the rate of discharge is higher than the rate of charge, and my Pi4 keeps shutting down.

I know enough to know I don't know enough to diagnose the issue myself. I have eliminated any extra USB power draws that aren't necessary, to the point that the only thing enable at this point are the ethernet connection, and the USB cable going to my 3D printer.

14500 model not using all the available power

Hi, need your help again :)

Im using Pi3 B+ and 14500 Battery model.
Today I powered LiFePO4wered from my new power source and it turned out LiFePO4wered is limiting input current to 1 amp to 0.4 amp, so the Pi will not boot until battery is charged well.
Isn't it supposed to take at least 2 amps? (my pi consumes 1.4 amps)

image

You may probably ask why im using 14500 and not 18650 as manual suggests. Because after using LiFePO4wered for more than 1 year only now I found out there is a small line in manual that states 14500 does not support 3B+ models.
I buy shields from crowd supply and had no idea about that. Please fix the description!

image
Its not only capacity difference but also Pi model itself
For UPS I decided small battery is enough.

Compilation problems

Hi, I'm on a Rpi with Debian 3.18.5-1~exp1+rpi19 (2015-08-08) armv7l GNU/Linux.
When I first tried to compile the code I have got a bunch of errors like:
storage size of ts' isn't knownand undefined reference to le32toh'.

The first I solved by adding the string
#define _POSIX_C_SOURCE 199309Lat the beginning of to the lifepo4wered-daemon.c
see: http://gcc-help.gcc.gnu.narkive.com/8xCaKI6r/problem-with-struct-timespec-and-c99-standard

The second was solved by exchanging the line:
#define _DEFAULT_SOURCE to #define _BSD_SOURCE.
see https://stackoverflow.com/questions/26713198/undefined-reference-to-htole32

You may add this somewhere in the README for example to help others on the same issues.
Best regards.

Taking less power from charging USB port than the base Pi does.

I just got my LiFePO4wered/Pi+ today, mostly to absorb peaks in power draw.
However, currently, it seems to discharge faster than it charges on a power supply that should be able to handle it fine.
While my Pi3B by itself can run on this port unthrottled and without voltage warnings, while sustaining a high CPU and I/O load and having HDMI and USB devices running, if I run through the LiFePO4wered/Pi+, it discharges faster than it can charge even while manually throttling (600MHz), idle, no HDMI and no USB devices. Same cable and everything.

Looking at the lifepo4wered-cli output, I see vbat slowly dropping, while vin sits at 4858, and vout at around 5000.

Could it be the LiFePO4wered/Pi+ is not taking advantage of the full capacity of this USB port, whereas the "bare" Pi3B is?
The port in question is the special USB charging port on the nuc6i5syh, I'm unsure of the exact specifications of this port, all I know is that it was capable of driving this Pi3B unthrottled with a lot more load fine.

I should be getting the official Pi charger tomorrow, I assume everything will be fine with that charger, but I would expect it to work fine with this charge port as well, since it's, as far as I can tell, more than powerful enough for the bare Pi3B.

Feature Request - Amps usage measurement

I am very much looking forward to the new 2A module! Hope you are ready soon, you got one buyer for sure ๐Ÿ‘
Could you add a Amps usage measurement to your cli software as well? That would be a very valuable feature to see how much each board/usb etc is chewing up. Or how else could I quickly see the A usage?

shut down for unknown reason

Hi,
I got a restart of my raspberry and I am struggling to understand why. looking at the code, it seems to be PI_RUNNING was at 0.
here is the (only) log I found
Dec 2 04:06:51 paris LiFePO4wered[374]: Signal from LiFePO4wered module to shut down
Dec 2 04:06:52 paris LiFePO4wered[374]: Signaling LiFePO4wered module that system is shutting down
Dec 2 04:06:52 paris LiFePO4wered[374]: Triggering system shutdown
Can you shed some light on how it could happen ?
Thanks

Question: Voltage across VIN pins?

A quick question for you @xorbit ... I am measuring the voltage out of my solar panel at around 6.5v but when I measure across the VIN pins, I only get around 4.6v. Should I expect to get the same voltage there? and if so I am guessing that indicates I may need some better wiring between my panel and the board. I haven't yet soldered the resistor we spoke about in #52, so I also wondered if that could be related?

From the software I noticed my VIN sits around 4.6v and VOUT at around 4.9v-5v, so my battery is never getting topped off enough to sustain the Pi longer term.

Needs 3A

This is the solution I have been looking for, but Raspberry Pi 4 needs 3A.

Any plans to beef up output?

Can I update the firmware?

I have in my possession a LiFePO4wered/Pi3 unit I bought in 2017 and does not have the fancy new 2018 release firmware.

I'm hoping there is a not-so-difficult way to update the firmware on it!

Mainly I want to have the new 10-second hold to turn off functionality, because once you power on a pi that's been physically attached to the LiFePO4wered unit, if it has no SD card (or isn't set up) it's not really possible to shut it down without draining the cell, which seems far from ideal (although I know these cells are quite robust).

I was also thinking that as a fallback the LiFePO4wered unit could attempt to use the default login (pi/raspberry) to use the shell on uart to implement the shutoff on a system that does not have the software installed yet.

Thank you.

Register corruption causing shutdown and no-boot

I am experiencing issues nearly identical to #48. There is nothing on the GPIO headers except the LiFePO4wered/Pi3. I am running Raspberry Pi OS 2022-04-04, fully patched.

I am running lifepo4wered-cli get every 60 seconds to log statistics to Home Assistant. But when I run lifepo4wered-cli get over and over, things get corrupted. Here is what happened last night:

  • WAKE_TIME started at 0 then went to 255 (0x00FF) at 19:36, then to 65415 (0xFF87) at 21:04.
  • TOUCH_STATE went from 0 to 15 (0x0F) at 03:13, likely causing the service to shut down the Pi. The button was not actually touched.
  • PI_RUNNING went from 1 to 135 (0x87) at 14:36, then to 255 (0xFF) at 21:04, then back to 135 (0x87) at 21:07, and finally to 0 at 3:13.

All the measured voltages also started reporting garbage at 01:50 this morning:

  • image
  • image
  • image

I don't believe any of those voltages actually changed, as the battery can't jump 1.3 volts in 1 minute, so it is likely the calibration/offset getting corrupted.

If just the daemon is run, the problem doesn't appear to show up (at least not quickly). But when gathering stats, within a day things corrupt and the Pi turns off. And due to WAKE_TIME getting set stupid high, I have to remove the battery to reset the MCU before I can turn the Pi back on.

Feature Request: Power-on Timeout

Currently, if the device is turned on, without a pi connected, you have to pull the battery to turn the thing "off"

I'd like to suggest a timeout setting where you can specify that if the device does not receive a "powered on" signal within 30 seconds to a minute or so (make adjustable?) then do a hard power-off of the device.

Build on Raspbian PIXEL

On a brand new Raspbian PIXEL install on RPI3, i get the following while trying to build from github?

pi@dev:~/LiFePO4wered-Pi $ ./build.py

gcc -c lifepo4wered-access.c -o build/DAEMON/lifepo4wered-access.o -std=c99 -Wall -O2

In file included from lifepo4wered-access.c:10:0:
/usr/include/linux/i2c-dev.h:37:8: error: redefinition of โ€˜struct i2c_msgโ€™
struct i2c_msg {
^

In file included from lifepo4wered-access.c:9:0:
/usr/include/linux/i2c.h:68:8: note: originally defined here
struct i2c_msg {
^

In file included from lifepo4wered-access.c:10:0:
/usr/include/linux/i2c-dev.h:89:7: error: redefinition of โ€˜union i2c_smbus_dataโ€™
union i2c_smbus_data {
^

In file included from lifepo4wered-access.c:9:0:
/usr/include/linux/i2c.h:128:7: note: originally defined here
union i2c_smbus_data {
^

lifepo4wered-access.c: In function โ€˜read_lifepo4wered_dataโ€™:
lifepo4wered-access.c:59:16: warning: pointer targets in assignment differ in signedness [-Wpointer-sign]
dread[0].buf = ยฎ
^

lifepo4wered-access.c:64:16: warning: pointer targets in assignment differ in signedness [-Wpointer-sign]
dread[1].buf = data;
^

lifepo4wered-access.c: In function โ€˜write_lifepo4wered_dataโ€™:
lifepo4wered-access.c:98:14: warning: pointer targets in assignment differ in signedness [-Wpointer-sign]
dwrite.buf = payload;
^

fabricate: 'gcc' exited with status 1
pi@dev:~/LiFePO4wered-Pi $

Obviously, i haven't yet tried the install script.

RFE: More meaningful output when not cli not run with correct permissions

Hi,

First of all, thanks for making the amazing hardware and the great UI in software for it! I just got two LiFePO4wered/PI+ modules (18650 and 14500) for powering a pi3 b+ and a zero. These are FAR superior to anything else I have tried.

I was just reading through the product brief to configure the UPS (LiFePO4wered/PI+) for my DIY openVPN server at my parents house (it's easier to play tech support when I can actually access their hardware...) and encountered a brief moment of confusion:

I was reading through the manual and tried to execute the example command:

lifepo4weredยญ-cli get vbat

and a value of -1 was returned. Eventually I realized that I was being foolish, and this is an error code that was caused by lack of root privileges. I have 3 suggestions to improve the UX and clarity of using the CLI tool:

  1. Have the CLI tools print a diagnostic message when it is run without root privs and should have been run as root.
  2. Document that the CLI tool should be run as root in the product brief. A change as simple as adding a leading ampersand before the example lifepo4wered-cli commands to indicate that they are being run as the root user would be helpful.
  3. Document the error return code.

Before I realized my mistake, since the LiFePO4wered module is connected to wall power, I had assumed that this -1 code returned by get vbat was an indication of a defective battery.

Anyway, many thanks once again!

Cannot Auto-shutdown?

$ lifepo4wered-cli set AUTO_SHDN_TIME 0
0
$ lifepo4wered-cli set AUTO_SHDN_TIME 1
1
$ date
Sun Apr  9 22:56:18 HST 2017
$ date
Sun Apr  9 22:57:23 HST 2017

So, I seem to be able to set a shutdown time... but I'm not sure why it doesn't shut down?

Edit: Well, it looks like if I power it off by hand using the touch sensor, the wake timer seems to work, which is nice :)

Do I need to have the device plugged in and then disconnect it for the auto shutdown timer to work?

Edit 2:
Actually... once the device booted back up, it shut down after a minute.... That was weird...

lifepo4wered-daemon with openrc functions (Gentoo-Player)

Hi Patrick,
I would like to use the Gentoo-Player linux Gentoo distribution. This is working without Systemd so running make as su and changing
USE_SYSTEMD ?= 0 instead of 1 in Makefile is finishing the build process as it seems. Also defaulting and restarting the service seems to work after edit;

enable-init-0: # sysvinit
        ##update-rc.d lifepo4wered-daemon defaults
        /sbin/rc-update add lifepo4wered-daemon default
        ##service lifepo4wered-daemon restart
        /etc/init.d/lifepo4wered-daemon restart

However the daemon uses /lib/lsb/init-funtions but supposedly I need to use openrc (https://github.com/OpenRC/openrc/blob/master/service-script-guide.md)
Do you by any change have experience with Gentoo and could you rewrite this to use the openrc method (if I understand it correctly)?

Best configuration?

I have an arcade box that I built that runs off a rpi3. The kids keep just shutting off the power and can't seem to grasp the concept of shutting down the system first. I discovered the LiFePo4wered and the clouds parted. I've installed it and set the auto_boot to 1. But when the power gets cut the rpi will still run for a while before shutting down. What's the best way to configure this to automatically shutdown a few seconds after power has been cut?

Best way to uninstall?

Hi,

This is great. But after giving it a try on an RPi2, then deciding the power requirements on that particular machine exceed what LiFePO4wered-Pi can handle, removed it. What's the best way to "uninstall" the software component? Just delete these & reboot?

/usr/local/sbin/lifepo4wered-daemon
/usr/local/bin/lifepo4wered-cli
/run/systemd/generator.late/lifepo4wered-daemon.service
/run/systemd/generator.late/runlevel5.target.wants/lifepo4wered-daemon.service
/run/systemd/generator.late/runlevel4.target.wants/lifepo4wered-daemon.service
/run/systemd/generator.late/runlevel3.target.wants/lifepo4wered-daemon.service
/run/systemd/generator.late/runlevel2.target.wants/lifepo4wered-daemon.service
/etc/init.d/lifepo4wered-daemon

Multiple batteries?

Fantastic product, I plan on buying one in the near future. Would this kind of circuit be able to handle multiple 18650s wired in parallel for increased capacity?

LiFePO4wered/Pi+ device will not power up

After starting with a base Raspberry Pi OS, I followed the GitHub instructions on the code screen to download and install the software. I have made no changes to any default settings. After physically installing the LiFePO4wered/Pi+ header with 18650 battery, and only powering the LiFePO4wered device (not the PI) , it seems pushing the physical button for 2 seconds does not do anything. The battery does have 3.4 volts. Did I do something wrong or miss a step somewhere ?

AUTO_BOOT_VIN_SMART2 if system shutdown by shell?

Hey.

First, this product is awesome! Keep up the good work!

How is AUTO_BOOT_VIN_SMART2 behaving when I type shutdown -h now inside a shell? I thought, if I power cycle the main input, it will come back up, but it does nothing. is user-requested shutdown only via button press?

Thanks in advance!

Pi3 quesstion

My application will use other Pi HAT's and a touch screen. Both receive their power from the GPIO pins. Will the LiFePO4wered/Pi3 actually cut off power to the GPIO pins so that the HAT and touch screen don't consume battery power while the Pi is shut down?

No power provided

Hi there XORBIT,

Iยดm using 2 LiFePo4+, one of them works great, the other one is not working properly. My register dump is:

I2C_REG_VER = 7
I2C_ADDRESS = 67
LED_STATE = 1
TOUCH_STATE = 0
TOUCH_CAP_CYCLES = 0
TOUCH_THRESHOLD = 12
TOUCH_HYSTERESIS = 2
DCO_RSEL = 14
DCO_DCOMOD = 156
VIN = 5091
VBAT = 3323
VOUT = 5004
IOUT = 141
VBAT_MIN = 2850
VBAT_SHDN = 2950
VBAT_BOOT = 3150
VOUT_MAX = 3500
VIN_THRESHOLD = 4250
IOUT_SHDN_THRESHOLD = 0
VBAT_OFFSET = 59
VOUT_OFFSET = 41
VIN_OFFSET = 50
IOUT_OFFSET = 0
AUTO_BOOT = 0
WAKE_TIME = 0
SHDN_DELAY = 40
AUTO_SHDN_TIME = 65535
PI_BOOT_TO = 300
PI_SHDN_TO = 120
RTC_TIME = 458
RTC_WAKE_TIME = 0
WATCHDOG_CFG = 0
WATCHDOG_GRACE = 20
WATCHDOG_TIMER = 20
PI_RUNNING = 1
CFG_WRITE = 0

Problem description:

  • PI (Zero) starts & runs when power is supplied via LiFePo4+-USB
  • battery is charged endless... (battery works, tested with the second LiFePo4+)
  • if LiFePo4+-USB power is removed, PI loses power suddenly...

It seems there is no power supply from battery to PI. Any recommendations what tests or measurements I should try?

Kind regards!
Jo

Solar panel question

I am working on a little project with my LiFePO4wered-Pi board and noticed in the documentation a resistor is recommended to customise the MPP setting for the panel:

RMPP = 51815 / (VMPP โ€“ 4.66)

I contacted the panel manufacturer and they came back with a value of Vmmp: 7.38V. I just wanted to check that the recommendation is a: 19049 ohm / 19 kohm resistor on these pads.

I only have a 20k resistor to hand, would that still be suitable or should I find something a little closer?

LiFePO4wered does not react

Hi, im using several of your boards and i like it!
However there are two beards that does strange things: not matter what i do it never does anything.

here is comparison of good and bad boards:
first board works as expected, the second one not. Do you have any Ideas?
https://www.youtube.com/watch?v=ia9m3pTtxas

If I plug power directly into raspberry (3b+) I can communicated with board
pi@Golf:~ $ lifepo4wered-cli get
I2C_REG_VER = 7
I2C_ADDRESS = 67
LED_STATE = 1
TOUCH_STATE = 0
TOUCH_CAP_CYCLES = 0
TOUCH_THRESHOLD = 12
TOUCH_HYSTERESIS = 2
DCO_RSEL = 14
DCO_DCOMOD = 171
VIN = 0
VBAT = 0
VOUT = 0
IOUT = 0
VBAT_MIN = 2850
VBAT_SHDN = 2950
VBAT_BOOT = 3150
VOUT_MAX = 3500
VIN_THRESHOLD = 4498
IOUT_SHDN_THRESHOLD = 0
VBAT_OFFSET = 49
VOUT_OFFSET = 26
VIN_OFFSET = 25
IOUT_OFFSET = 0
AUTO_BOOT = 3
WAKE_TIME = 0
SHDN_DELAY = 40
AUTO_SHDN_TIME = 0
PI_BOOT_TO = 300
PI_SHDN_TO = 10
RTC_TIME = 0
RTC_WAKE_TIME = 0
WATCHDOG_CFG = 0
WATCHDOG_GRACE = 20
WATCHDOG_TIMER = 0
PI_RUNNING = 1
CFG_WRITE = 70

Fail to install

Raspberry Pi 4 running latest buster
$ sudo ./INSTALL.sh
install: strip process terminated abnormally
install: strip process terminated abnormally

Upgrade request: 2A or more

I have recently received my LiFe and I really like it! Well done, impressive. I am using my Pi3 with 2 USB devices (one a 2nd Wifi, the other a gphoto2 image/video transfer) and a raspicam and 4 cores running quite a bit. I have tested a few UPS HATs now and one request I have is whether LiFe could pump out 2A or more, ideally 2.4A at peak. Is this possible?

Detecting source power state

Is is possible to detect/query the voltage on USB charge connector? I need just to safely power down RPi when source (=charging?) power is disconnected LiFePO4wered-Pi. I could not find this in the docs.

Question: Why avoid_warnings=2?

Enabling turbo in low voltage condition may lead to data corruption, which runs counter to the purpose of a UPS.

Curious about the reasoning.

Newly (re-)installed daemon fails to start

I needed to rebuild the Pi 3B my LifePO4wered-Pi+ is connected to.

I followed the same installation instructions as before, but lifepo4wered-daemon.service fails to start.

If I can get in quickly, then I can start it manually using sudo systemctl start lifepo4wered-daemon
(Not sure if it's relevant, but although I've changed PI_BOOT_TO to 600s, it still gives up after a couple of minutes)

In case it's a timing problem, I've tried changing the service file to introduce an ExecPreStart of 30s but it makes no difference.

The unit file looks like:

[Unit]
Description=emonHub data multiplexer
# The config file lives in /etc/emonhub/emonhub.conf
# The log file lives in /var/log/emonhub/emonhub.log
#Requires=var-log.mount
#After=var-log.mount network.target
After=network.target

[Service]
Type=exec
ExecStart=/usr/local/bin/emonhub/emonhub.py --config-file=/etc/emonhub/emonhub.conf --logfile=/var/log/emonhub/emonhub.log
User=pi
Environment='USER=pi'
Environment='LOG_PATH=/var/log/emonhub'
PermissionsStartOnly=true
ExecStartPre=/bin/mkdir -p ${LOG_PATH}
ExecStartPre=/bin/chown ${USER} ${LOG_PATH}

Restart=always
RestartSec=5

SyslogIdentifier=emonhub

[Install]
WantedBy=multi-user.target

Note: I had to edit out the Requires for var-log.mount because detain bullseye doesn't have that mount
systemctl show emonhub shows

Type=exec
Restart=always
NotifyAccess=none
RestartUSec=5s
TimeoutStartUSec=1min 30s
TimeoutStopUSec=1min 30s
TimeoutAbortUSec=1min 30s
TimeoutStartFailureMode=terminate
TimeoutStopFailureMode=terminate
RuntimeMaxUSec=infinity
WatchdogUSec=0
WatchdogTimestampMonotonic=0
RootDirectoryStartOnly=no
RemainAfterExit=no
GuessMainPID=yes
MainPID=0
ControlPID=0
FileDescriptorStoreMax=0
NFileDescriptorStore=0
StatusErrno=0
Result=exit-code
ReloadResult=success
CleanResult=success
UID=[not set]
GID=[not set]
NRestarts=97
OOMPolicy=stop
ExecMainStartTimestampMonotonic=0
ExecMainExitTimestampMonotonic=0
ExecMainPID=0
ExecMainCode=0
ExecMainStatus=0
ExecStartPre={ path=/bin/mkdir ; argv[]=/bin/mkdir -p ${LOG_PATH} ; ignore_errors=no ; start_time=[Sun 2023-08-27 12:24:13 BST] ; stop_time=[Sun 2023-08-27 12:24:13 BST] ; pid=2220 ; code=exited ; status=217 }
ExecStartPre={ path=/bin/chown ; argv[]=/bin/chown ${USER} ${LOG_PATH} ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }
ExecStartPreEx={ path=/bin/mkdir ; argv[]=/bin/mkdir -p ${LOG_PATH} ; flags= ; start_time=[Sun 2023-08-27 12:24:13 BST] ; stop_time=[Sun 2023-08-27 12:24:13 BST] ; pid=2220 ; code=exited ; status=217 }
ExecStartPreEx={ path=/bin/chown ; argv[]=/bin/chown ${USER} ${LOG_PATH} ; flags= ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }
ExecStart={ path=/usr/local/bin/emonhub/emonhub.py ; argv[]=/usr/local/bin/emonhub/emonhub.py --config-file=/etc/emonhub/emonhub.conf --logfile=/var/log/emonhub/emonhub.log ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }
ExecStartEx={ path=/usr/local/bin/emonhub/emonhub.py ; argv[]=/usr/local/bin/emonhub/emonhub.py --config-file=/etc/emonhub/emonhub.conf --logfile=/var/log/emonhub/emonhub.log ; flags= ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }
Slice=system.slice
MemoryCurrent=[not set]
CPUUsageNSec=0
EffectiveCPUs=
EffectiveMemoryNodes=
TasksCurrent=[not set]
IPIngressBytes=[no data]
IPIngressPackets=[no data]
IPEgressBytes=[no data]
IPEgressPackets=[no data]
IOReadBytes=18446744073709551615
IOReadOperations=18446744073709551615
IOWriteBytes=18446744073709551615
IOWriteOperations=18446744073709551615
Delegate=no
CPUAccounting=yes
CPUWeight=[not set]
StartupCPUWeight=[not set]
CPUShares=[not set]
StartupCPUShares=[not set]
CPUQuotaPerSecUSec=infinity
CPUQuotaPeriodUSec=infinity
AllowedCPUs=
AllowedMemoryNodes=
IOAccounting=no
IOWeight=[not set]
StartupIOWeight=[not set]
BlockIOAccounting=no
BlockIOWeight=[not set]
StartupBlockIOWeight=[not set]
MemoryAccounting=yes
DefaultMemoryLow=0
DefaultMemoryMin=0
MemoryMin=0
MemoryLow=0
MemoryHigh=infinity
MemoryMax=infinity
MemorySwapMax=infinity
MemoryLimit=infinity
DevicePolicy=auto
TasksAccounting=yes
TasksMax=1595
IPAccounting=no
ManagedOOMSwap=auto
ManagedOOMMemoryPressure=auto
ManagedOOMMemoryPressureLimitPercent=0%
Environment=USER=pi LOG_PATH=/var/log/emonhub
UMask=0022
LimitCPU=infinity
LimitCPUSoft=infinity
LimitFSIZE=infinity
LimitFSIZESoft=infinity
LimitDATA=infinity
LimitDATASoft=infinity
LimitSTACK=infinity
LimitSTACKSoft=8388608
LimitCORE=infinity
LimitCORESoft=0
LimitRSS=infinity
LimitRSSSoft=infinity
LimitNOFILE=524288
LimitNOFILESoft=1024
LimitAS=infinity
LimitASSoft=infinity
LimitNPROC=5319
LimitNPROCSoft=5319
LimitMEMLOCK=8388608
LimitMEMLOCKSoft=8388608
LimitLOCKS=infinity
LimitLOCKSSoft=infinity
LimitSIGPENDING=5319
LimitSIGPENDINGSoft=5319
LimitMSGQUEUE=819200
LimitMSGQUEUESoft=819200
LimitNICE=0
LimitNICESoft=0
LimitRTPRIO=0
LimitRTPRIOSoft=0
LimitRTTIME=infinity
LimitRTTIMESoft=infinity
RootHashSignature=
OOMScoreAdjust=0
CoredumpFilter=0x33
Nice=0
IOSchedulingClass=0
IOSchedulingPriority=0
CPUSchedulingPolicy=0
CPUSchedulingPriority=0
CPUAffinity=
CPUAffinityFromNUMA=no
NUMAPolicy=n/a
NUMAMask=
TimerSlackNSec=50000
CPUSchedulingResetOnFork=no
NonBlocking=no
StandardInput=null
StandardInputData=
StandardOutput=journal
StandardError=inherit
TTYReset=no
TTYVHangup=no
TTYVTDisallocate=no
SyslogPriority=30
SyslogIdentifier=emonhub
SyslogLevelPrefix=yes
SyslogLevel=6
SyslogFacility=3
LogLevelMax=-1
LogRateLimitIntervalUSec=0
LogRateLimitBurst=0
SecureBits=0
CapabilityBoundingSet=cap_chown cap_dac_override cap_dac_read_search cap_fowner cap_fsetid cap_kill cap_setgid cap_setuid cap_setpcap cap_linux_immutable cap_net_bind_service cap_net_broadcast cap_net_admin cap_net_raw cap_ipc_lock cap_ipc_owner cap_sys_module cap_sys_rawio cap_sys_chroot cap_sys_ptrace cap_sys_pacct cap_sys_admin cap_sys_boot cap_sys_nice cap_sys_resource cap_sys_time cap_sys_tty_config cap_mknod cap_lease cap_audit_write cap_audit_control cap_setfcap cap_mac_override cap_mac_admin cap_syslog cap_wake_alarm cap_block_suspend cap_audit_read cap_perfmon cap_bpf cap_checkpoint_restore
AmbientCapabilities=
User=root\nEnvironment="USER=root"
DynamicUser=no
RemoveIPC=no
MountFlags=
PrivateTmp=no
PrivateDevices=no
ProtectClock=no
ProtectKernelTunables=no
ProtectKernelModules=no
ProtectKernelLogs=no
ProtectControlGroups=no
PrivateNetwork=no
PrivateUsers=no
PrivateMounts=no
ProtectHome=no
ProtectSystem=no
SameProcessGroup=no
UtmpMode=init
IgnoreSIGPIPE=yes
NoNewPrivileges=no
SystemCallErrorNumber=2147483646
LockPersonality=no
RuntimeDirectoryPreserve=no
RuntimeDirectoryMode=0755
StateDirectoryMode=0755
CacheDirectoryMode=0755
LogsDirectoryMode=0755
ConfigurationDirectoryMode=0755
TimeoutCleanUSec=infinity
MemoryDenyWriteExecute=no
RestrictRealtime=no
RestrictSUIDSGID=no
RestrictNamespaces=no
MountAPIVFS=no
KeyringMode=private
ProtectProc=default
ProcSubset=all
ProtectHostname=no
KillMode=control-group
KillSignal=15
RestartKillSignal=15
FinalKillSignal=9
SendSIGKILL=yes
SendSIGHUP=no
WatchdogSignal=6
Id=emonhub.service
Names=emonhub.service
Requires=system.slice sysinit.target
WantedBy=multi-user.target
Conflicts=shutdown.target
Before=multi-user.target shutdown.target
After=basic.target network.target sysinit.target system.slice systemd-journald.socket
Description=emonHub data multiplexer
LoadState=loaded
ActiveState=activating
FreezerState=running
SubState=auto-restart
FragmentPath=/etc/systemd/system/emonhub.service
DropInPaths=/usr/lib/systemd/system/emonhub.service.d/emonhub.conf
UnitFileState=enabled
UnitFilePreset=enabled
StateChangeTimestamp=Sun 2023-08-27 12:24:13 BST
StateChangeTimestampMonotonic=1324758725
InactiveExitTimestamp=Sun 2023-08-27 12:24:13 BST
InactiveExitTimestampMonotonic=1324758725
ActiveEnterTimestampMonotonic=0
ActiveExitTimestampMonotonic=0
InactiveEnterTimestamp=Sun 2023-08-27 12:24:13 BST
InactiveEnterTimestampMonotonic=1324754732
CanStart=yes
CanStop=yes
CanReload=no
CanIsolate=no
CanFreeze=yes
StopWhenUnneeded=no
RefuseManualStart=no
RefuseManualStop=no
AllowIsolate=no
DefaultDependencies=yes
OnFailureJobMode=replace
IgnoreOnIsolate=no
NeedDaemonReload=no
JobTimeoutUSec=infinity
JobRunningTimeoutUSec=infinity
JobTimeoutAction=none
ConditionResult=yes
AssertResult=yes
ConditionTimestamp=Sun 2023-08-27 12:24:13 BST
ConditionTimestampMonotonic=1324660354
AssertTimestamp=Sun 2023-08-27 12:24:13 BST
AssertTimestampMonotonic=1324660370
Transient=no
Perpetual=no
StartLimitIntervalUSec=10s
StartLimitBurst=5
StartLimitAction=none
FailureAction=none
SuccessAction=none
InvocationID=dbaec0c683af4addaa22d008a84cc681
CollectMode=inactive

and the journal shows

Aug 27 12:26:08 docker4 systemd[1]: Starting emonHub data multiplexer...
โ–‘โ–‘ Subject: A start job for unit emonhub.service has begun execution
โ–‘โ–‘ Defined-By: systemd
โ–‘โ–‘ Support: https://www.debian.org/support
โ–‘โ–‘ 
โ–‘โ–‘ A start job for unit emonhub.service has begun execution.
โ–‘โ–‘ 
โ–‘โ–‘ The job identifier is 9748.
Aug 27 12:26:08 docker4 systemd[1]: emonhub.service: Control process exited, code=exited, status=217/USER
โ–‘โ–‘ Subject: Unit process exited
โ–‘โ–‘ Defined-By: systemd
โ–‘โ–‘ Support: https://www.debian.org/support
โ–‘โ–‘ 
โ–‘โ–‘ An ExecStartPre= process belonging to unit emonhub.service has exited.
โ–‘โ–‘ 
โ–‘โ–‘ The process' exit code is 'exited' and its exit status is 217.
Aug 27 12:26:08 docker4 systemd[1]: emonhub.service: Failed with result 'exit-code'.
โ–‘โ–‘ Subject: Unit failed
โ–‘โ–‘ Defined-By: systemd
โ–‘โ–‘ Support: https://www.debian.org/support
โ–‘โ–‘ 
โ–‘โ–‘ The unit emonhub.service has entered the 'failed' state with result 'exit-code'.
Aug 27 12:26:08 docker4 systemd[1]: Failed to start emonHub data multiplexer.
โ–‘โ–‘ Subject: A start job for unit emonhub.service has failed
โ–‘โ–‘ Defined-By: systemd
โ–‘โ–‘ Support: https://www.debian.org/support
โ–‘โ–‘ 
โ–‘โ–‘ A start job for unit emonhub.service has finished with a failure.
โ–‘โ–‘ 
โ–‘โ–‘ The job identifier is 9748 and the job result is failed.

It fails with status=217/USER but I fail to see why. the user pi exists and I can run the code manually.

Any ideas?

REQ: Autoshutdown

I'd like the ability to perform auto shutdown of Pi if incoming power is disconnected. e.g. shutdown after x delay when incoming power in not present.

Clarity of doc around use of UART

I see now that the installer ensures enable_uart=1 so that it turns on so it can be used to communicate the shutdown state.

In various comments you mention only the TX is used.

It was unclear for me until I did some digging: The LiFePO4wered-Pi does NOT do any actual "reading" on the TX. It only checks if it is high. Yes you have stated this, but I was worried about it upon first seeing this.

Now that I know that the installer only sets enable_uart=1, I know my software will be completely unaffected by the presence of the LiFePO4wered-Pi also being attached to the pin. Maybe you can add a sentence in the product brief that clarifies this.

logging support

This may run as expected lifepo4wered-cli get >> file.log, but put it in file.sh and call it via cron, then it may not. Is this a code change or a script issue?

CLI doesn't seem to work

Here's what I get

$ lifepo4wered-cli get vbat
-1
$ lifepo4wered-cli get vout
-1
$ lifepo4wered-cli get VBAT
-1
$ lifepo4wered-cli get vin
-1

But I know the install must've been successful since I can now power on and shutdown my pi with the touch button just fine, The LED changes state when in bootup and shutdown process accordingly.

Any help would be greatly appreciated. Thanks!

Edit: More info

$ lifepo4wered-cli get meh
ERROR: Invalid variable name

Available variables for READ:
        I2C_REG_VER
$ lifepo4wered-cli get i2c_reg_ver
-2

Start operations times out

Just received my device and I am having issues getting it to work with my Pi 3 b+.
Running YoDeck software via their Raspbian Buster 10 image with custom packages.

Looking at the logs I see.

lifepo4wered-daemon.service: Start operation timed out. Terminating.

Which is exactly what I assumed the issue was due to the green power light always flashing and never stopping until the Pi Powers off. Everything is running fine while it's attempting to boot. I have tried a fresh install with no luck.

Temperature compensated RTC

Hi there, just got my LiFePO4wered/Pi+. Looks amazing and is working great so far.

I was wondering if you are planning on supporting a temperature compensated RTC. I live in Canada and am planning on using it outdoors. This means there are wide fluctuations in temperature which can affect clock accuracy. I know of a whitepaper from TI that demonstrates how to make an RTC that is extremely accurate across a wide temperature range using the ADC, and Timer_A in an MSP430:

http://www.ti.com/lit/ml/slap107/slap107.pdf

If there is no plan for this, is there any plan to release the firmware so that it can be modified to add features? I realize that may be a challenging request however. Is it even possible to flash the MSP430 once it has been shipped to the customer?

Thanks again!

LiFePO4wered Pi+ doesn't power on?

I've been running the board for a while, and I'm having an extremely difficult time booting and shutting down the board. I've changed PI_SHDN_TO and PI_BOOT_TO to 0 since I'm using a system without the daemon and it was turning off automatically, but now it just doesn't turn on, pressing the button does nothing. When it did previously I couldn't turn it off, the green light just blinked as I held the button.

I spent some time testing voltages and connections. The battery is at 3.46 volts, the charging works, the power button is connected to the MSP430G2, the MSP430 has power and I assume a working clock, but the MSP430 doesn't output the ENABLE or PWR LED signals.

Reboot of the RPI blocked with the LiFePO4wered/Pi+ abd CLI

hello,

I have a issue with the LiFePO4wered/Pi+ and the programm, when I send a reboot command the system just shutdown and do not comme up.
Does I have a setting to chagne for that ?

Issue :
1 : Send Reboot command
2 : The system power off
3 : The RPI never power on, need to press the button to power on again.

Replace battery?

Hi,

could I replace the battery on the LiFePO4wered/Pi3 with a bigger capacity one, say a Panasonic NCR18650B?

Pi doesn't seem to shutdown seems to be in loop

[ ~ ]$ lifepo4wered-cli get AUTO_BOOT     
4
[~ ]$ lifepo4wered-cli get AUTO_SHDN_TIME
0

When I unplug from the powersource the PWR LED pulses and I can see the activity LED on the Pi show like its in its shutdown phase but the power LED never shuts off and the activity LED continues to blink. The PWR LED never stops pulsing. No SSH access until I plug the power supply back in. The fan I have connected to the VOUT pads also continues to run. Holding down the switch for 10 seconds does shut off the pi.

Is there anything I'm missing that might create an issue? The scenario I'd like to have is that when main power is removed, then the pi is gracefully shutdown, on main power return the pi is booted back up.

Raspberry Pi 3 B+ running Raspbian Stretch.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.