12-07-2017, 03:27 PM
Hello I am working on a car project featuring all the goodies of a basic car android system (gps, telemtry .. so on)
the problem however is the power supply. I do have a mausberry car switch from my previous project with raspberry car system, but that one lacked proper SW for gps (using navit is pain in the ass). The mausberry car switch is a simple device which uses two GPIO pins to communicate to raspberry (now hopefully with tinker board) and tell it when to softly shut down when power is lost on ignition cable. There are 3 available scripts, for Raspbian/debian for OpenElec and for Arch.
My question is, whether it is possible to make it work on tinker board. From mausberry car setup there only is one bash script which it uses and the source code for it is here:
P.S.: If anybody elese has any suggestion on how to tell TinkerBoard to safely shutdown and not turn off immediately after loss of power (sort of like ups) I am all ears !
P.S.2: For more info on mausberry circuits: http://mausberrycircuits.com/pages/car-setup
Rapsbian script:
the problem however is the power supply. I do have a mausberry car switch from my previous project with raspberry car system, but that one lacked proper SW for gps (using navit is pain in the ass). The mausberry car switch is a simple device which uses two GPIO pins to communicate to raspberry (now hopefully with tinker board) and tell it when to softly shut down when power is lost on ignition cable. There are 3 available scripts, for Raspbian/debian for OpenElec and for Arch.
My question is, whether it is possible to make it work on tinker board. From mausberry car setup there only is one bash script which it uses and the source code for it is here:
P.S.: If anybody elese has any suggestion on how to tell TinkerBoard to safely shutdown and not turn off immediately after loss of power (sort of like ups) I am all ears !
P.S.2: For more info on mausberry circuits: http://mausberrycircuits.com/pages/car-setup
Rapsbian script:
Code:
echo '#!/bin/bash
#this is the GPIO pin connected to the lead on switch labeled OUT
GPIOpin1=23
#this is the GPIO pin connected to the lead on switch labeled IN
GPIOpin2=24
#Enter the shutdown delay in minutes
delay=0
echo "$GPIOpin1" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio$GPIOpin1/direction
echo "$GPIOpin2" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio$GPIOpin2/direction
echo "1" > /sys/class/gpio/gpio$GPIOpin2/value
let minute=$delay*60
SD=0
SS=0
SS2=0
while [ 1 = 1 ]; do
power=$(cat /sys/class/gpio/gpio$GPIOpin1/value)
uptime=$(</proc/uptime)
uptime=${uptime%%.*}
current=$uptime
if [ $power = 1 ] && [ $SD = 0 ]
then
SD=1
SS=${uptime%%.*}
fi
if [ $power = 1 ] && [ $SD = 1 ]
then
SS2=${uptime%%.*}
fi
if [ "$((uptime - SS))" -gt "$minute" ] && [ $SD = 1 ] && [ $power = 1 ]
then
poweroff
SD=3
fi
if [ "$((uptime - SS2))" -gt '20' ] && [ $SD = 1 ]
then
SD=0
fi
sleep 1
done' > /etc/switch.sh
sudo chmod 777 /etc/switch.sh
sudo sed -i '$ i /etc/switch.sh &' /etc/rc.local