Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mausberry car switch on Android
#1
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:

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
Reply
#2
Hi Welo78
I'm actually in process of doing the same thing. The Mausberry board uses the 2 pins in different ways.
GPIOpin1 = Output to the board to trigger shutdown
GPIOpin2 = Set by the board so that it knows to continue supplying power from the Battery.

My Initial thoughts are to create a power driver in the kernel for it that sets GPIOpin2 to 1 on startup, and monitors GPIOpin1. When Pin1 is brought high, then run 'reboot -p' in the shell. This shuts down the Tinker, and shortly after cuts power from the battery.

When you start the car again, ACC power comes on, providing power to the Tinker, booting it and setting Pin2 high, ready again for turn off.
Reply
#3
Hi, I made good experience with this change in dts:
       
Code:
gpio-leds {
   compatible = "gpio-leds";
...
   os-led {
                      gpios=<&gpio5 GPIO_B6 GPIO_ACTIVE_HIGH>;
                      linux,default-trigger="default-on";
   };
This lets the physical pin 13 go to high when board is started and go to low when board is ready with shut down and could be used for the GPIOpin2. Note that it need to be a gpio pin that is low right after power on, like the pin 13.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)