Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for X708 UPS HAT #3087

Merged
merged 1 commit into from
Sep 28, 2022
Merged

Conversation

HiLivin
Copy link
Contributor

@HiLivin HiLivin commented May 3, 2022

This adds a possibility to install X708 scripts with blitz.ups.sh on x708.

Succesfully tested the code on the dev branch with Raspberry Pi 4B+ and X708 v1.2 UPS HAT.

  • The blitz.shutdown.sh is executed before cutting off the power to the Raspberry Pi

  • The I2C is being enabled to allow getting data from the on-board battery management chip. I haven't found any issues as referenced by i2c /dev entries driver #1058

  • The battery voltage and AC state are correctly fetched by _background.scan.sh and later displayed on the status window

  • Still, I'd like to know if it's alright to link to my repo for downloading the scripts or maybe it would be better to pack them and put somewhere along with other RaspiBlitz code.

@rootzoll rootzoll added this to the 1.8.2 Release milestone May 12, 2022
@rootzoll
Copy link
Collaborator

Thats an interesting integration. I see if I can get a hands on those boards to test your integration. I added it to the v1.8.2 milestone for possible merge .. a bit up the line because v1.8.0 & 1.8.1 wil be very WebUI focused.

Still, I'd like to know if it's alright to link to my repo for downloading the scripts or maybe it would be better to pack them and put somewhere along with other RaspiBlitz code.

You can keep things in your repo and install it on demand, but then after cloning the repo within RaspiBlitz script it should checkout to a certain commit hash for security reasons.

@HiLivin HiLivin force-pushed the feature-x708-support branch from d88bbc1 to 7fe1c6e Compare May 12, 2022 18:03
@HiLivin
Copy link
Contributor Author

HiLivin commented May 12, 2022

It would be great to have someone double-check the whole thing.

  • I've added the git checkout with a proper hash to the install script and squashed the commits

@rootzoll rootzoll modified the milestones: 1.8.2 Release, 1.8.1 Release May 18, 2022
@rootzoll
Copy link
Collaborator

Progress looks great. If you think you have everything in there you can remove [WIP] from title and mark it with the tag final testing. Targeting here for release with 1.8.1

@HiLivin HiLivin changed the title [WIP] Add support for X708 UPS HAT Add support for X708 UPS HAT May 19, 2022
@HiLivin
Copy link
Contributor Author

HiLivin commented May 19, 2022

Done changing title. I think only repo maintainers can add tags/labels.

@rootzoll rootzoll added the final testing was fixed - needs testing label May 20, 2022
@HiLivin HiLivin force-pushed the feature-x708-support branch from 7fe1c6e to 9c3fe41 Compare June 3, 2022 20:47
@HiLivin
Copy link
Contributor Author

HiLivin commented Jun 3, 2022

Bumped the repo version to checkout. A major improvement was added.

Normally the x708 board waits only for ~50 seconds for the Pi to shutdown. If Pi shutdowns later than that, then the UPS hat doesn't turn itself off and the power to the Pi isn't cut. In case of power loss it wouldn't be a much problem - the board would eventually turn off because of low battery.

Now, to do it right, when the x708 starts waiting for Pi to shutdown a background loop is started with a specific timeout after which the UPS is triggered to wait for Pi shutdown again. This way the RaspiBlitz shutdown script can take very long and the hat will properly cut off the power afterwards.

@HiLivin HiLivin force-pushed the feature-x708-support branch from 9c3fe41 to 5f1d671 Compare June 4, 2022 13:54
@HiLivin
Copy link
Contributor Author

HiLivin commented Jun 4, 2022

Bumped again.
The install script now uses patch on 00mainMenu.sh instead of changing code lines with sed - this will improve compatibility with future versions of menu script.

The functionality seems fully developed. It would be nice to get some feedback from others using this UPS board with the scripts.

@rootzoll
Copy link
Collaborator

rootzoll commented Jun 6, 2022

@HiLivin if you prepare a tweet asking for broader feedback on this feature (Call for Testers) .. I am happy to share.

@holgern
Copy link
Contributor

holgern commented Jun 9, 2022

I have installed the X708 V2.0 and I have applied this PR to 1.7.2. After reboot, it is doing now every time a shutdown.
I have two 18650 (connected in parallel with the holder) and I power the x708 board through USB.

I will wait what will happen when the battery are fully loaded. (They are now at 25%)

@holgern
Copy link
Contributor

holgern commented Jun 9, 2022

After reaching MIN_VOLTAGE = 4.0, my raspi could start.
sudo ./config.scripts/blitz.ups.sh status returns now:
upsStatus='ONLINE'
upsBattery='4.22V'

@HiLivin
Copy link
Contributor Author

HiLivin commented Jun 9, 2022

Great! So that's a new board.

The automatic shutdown should be called when battery voltage is low AND AC power loss is detected (PLD pin high).
There could possibly be some hardware issues with PLD when batteries are low and the power supply is inefficient - high voltage drop might be recognized as AC power fail.

@HiLivin HiLivin force-pushed the feature-x708-support branch from 5f1d671 to 7782c19 Compare August 22, 2022 18:54
@smamamo
Copy link

smamamo commented Sep 23, 2022

I have installed the X708 V2.0 on my raspiblitz V. 018.0 and all works .
Auto start - Start when power cam back works as well
many thanks

rootzoll added a commit that referenced this pull request Sep 28, 2022
@rootzoll
Copy link
Collaborator

Perfect - so I am merging to be included in v1.8.1 release.

@rootzoll rootzoll merged commit 6aea40a into raspiblitz:dev Sep 28, 2022
@rootzoll rootzoll removed the final testing was fixed - needs testing label Sep 28, 2022
@smamamo
Copy link

smamamo commented Sep 29, 2022

A suggestion would be the integration of a simple monitoring of the battery charge. - x708.info.py
And a simple adjustment of the fan speed. - x708.fan.py -

My battery setting

MIN_VOLTAGE = 3.7 # (volts) shutdown when voltage drops below this value

I optimised my fans at

HIGH_THRESHOLD = 56 # (degrees Celsius) Fan running at high speed at this temperature.
LOW_THRESHOLD = 50 # (degrees Celsius) Fan running at low speed at this temperature.
SLEEP_INTERVAL = 5 # (seconds) How often do we check the core temperature.

@rootzoll
Copy link
Collaborator

@smamamo if you like to add furthe rimprovements, it best to start a new PR on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants