TIP: Click on subject to list as thread! ANSI
echo: rberrypi
to: CHRIS GREEN
from: SIMPLE SIMON
date: 2021-01-12 12:50:00
subject: Re: Battery Powered Proje

Chris Green wrote:
> Simple Simon  wrote:
>> I am working on a battery powered car and want the Pi to shut down
>> automatically if the battery starts to go flat to try to prevent SD card
>> corruption. I am a beginner to bash scripts! I will run this via crontab...
>>
>> #!/bin/bash
>> powerstatus=$(vcgencmd get_throttled)
>> if [ $powerstatus="throttled=0x1" ]
>> then
>> echo Under Voltage Detected - Shutting Down
>> sudo halt
>> else
>> echo Voltage Normal
>> fi
>>
>> Obviously it is not working!! Could someone correct and explain for me
>> please.
>
> You need spaces in the test:-
>
>      if [ $powerstatus = "throttled=0x1" ]
>
> Without the spaces you are just testing if '$powerstatus="throttled=0x1"'
> is not an empty string, and it never will be an empty string.
>
>
Brilliant - many thanks - works a treat - I was almost there!!

--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)

SOURCE: echomail via QWK@docsplace.org

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.