Hello,
I'm testing a battery with a pi 3 - intention is to run it flat and see how long it will power the pi for.
Is there an easy way to see uptime on the pi AFTER the battery dies and I plug it into the mains again?
-
- Posts: 264
- Joined: Thu Aug 04, 2016 11:02 pm
Re: Battery Uptime
Create a .sh procedure that will append (>>) output of "date" command to a previously created .txt file.
Also, create a crontab entry calling that .sh procedure every 10 minutes or less.
First and last entry into .txt file should be measured time period.
After rebooting you have less than 10 minutes to check file to avoid appending false entry.
Also, create a crontab entry calling that .sh procedure every 10 minutes or less.
First and last entry into .txt file should be measured time period.
After rebooting you have less than 10 minutes to check file to avoid appending false entry.
Šalica malina.
-
- Posts: 14387
- Joined: Fri Mar 09, 2012 7:36 pm
- Location: Vallejo, CA (US)
Re: Battery Uptime
Add a sync command after every file write to be sure that the data goes to storage and doesn't sit around in memory where it will be lost when the power drops.diogen151 wrote: ↑Sun Oct 20, 2019 9:11 pmCreate a .sh procedure that will append (>>) output of "date" command to a previously created .txt file.
Also, create a crontab entry calling that .sh procedure every 10 minutes or less.
First and last entry into .txt file should be measured time period.
After rebooting you have less than 10 minutes to check file to avoid appending false entry.
Re: Battery Uptime
I'd suggest adding output of uptime command along with output from date command, otherwise you may have trouble finding where a reboot has taken place.diogen151 wrote: ↑Sun Oct 20, 2019 9:11 pmCreate a .sh procedure that will append (>>) output of "date" command to a previously created .txt file.
Also, create a crontab entry calling that .sh procedure every 10 minutes or less.
First and last entry into .txt file should be measured time period.
After rebooting you have less than 10 minutes to check file to avoid appending false entry.
If you set this to run every 10 minutes then you could squeeze in a few reboots in those 10 minutes and not be able to see that it happened.
/Mogens
Re: Battery Uptime
uptime.sh
You may have to add a full path to where the log is to be.
Don't select a place that gets wiped at boot.
uptime.log
I don't have a Raspberry Pi here, but you can get help on creating crontab entries here:
https://crontab-generator.org/
/Mogens
Code: Select all
#!/bin/bash
echo $(date) - $(uptime) >> uptime.log
Don't select a place that gets wiped at boot.
uptime.log
Code: Select all
Mon Oct 21 06:32:38 UTC 2019 - 06:32:38 up 9 days, 23:47, 1 user, load average: 1.05, 1.03, 1.05
https://crontab-generator.org/
/Mogens
Re: Battery Uptime
Running battery flat is usually a bad idea (for the battery). Maybe you should get something like https://www.adafruit.com/product/4226 and when you detect (save!) low voltage on the battery side do clean shutdown. Anyway - that's just an ideajondallimore wrote: ↑Sun Oct 20, 2019 8:55 pmHello,
I'm testing a battery with a pi 3 - intention is to run it flat and see how long it will power the pi for.
Is there an easy way to see uptime on the pi AFTER the battery dies and I plug it into the mains again?

-
- Posts: 264
- Joined: Thu Aug 04, 2016 11:02 pm
Re: Battery Uptime
bash script with cronjob works.
running the battery down is fine, it has protection built in.
thanks
running the battery down is fine, it has protection built in.
thanks
- RaTTuS
- Posts: 10741
- Joined: Tue Nov 29, 2011 11:12 am
- Location: North West UK
- Contact: Twitter YouTube
Re: Battery Uptime
sudo apt install uptimed
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV
1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe
WARNING - some parts of this post may be erroneous YMMV
1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe
Re: Battery Uptime
But does your storage device?jondallimore wrote: ↑Mon Oct 21, 2019 10:21 amrunning the battery down is fine, it has protection built in.
E8 85 A2 40 C9 40 81 94 40 81 95 40 89 84 89 96 A3
Still NF Shirls
Still NF Shirls