Power & Source of Big Ideas

Mausberry car switch on Android

Moderators: chensy, FATechsupport

Hi, I'm working on a car project to create a digital dash that runs on an app called "Realdash" which runs on android. The problem I'm having at the moment is with the power supply. I have a mausberry car switch from my previous project with raspberry pi car system and this worked really well. The mausberry car switch is a simple device which uses two GPIO pins to communicate to raspberry pi 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 Nanopi M4v2 board. From mausberry car setup there only is one bash script which it uses and the source code for it is here:

If anybody else has any suggestion on how to tell Nanopi to safely shutdown and not turn off immediately after loss of power please advise.
For more info on mausberry circuits: (https://mausberry-circuits.myshopify.co ... ply-switch)

Rapsbian script:

cho '#!/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
jrizing wrote:
Hi, I'm working on a car project to create a digital dash that runs on an app called "Realdash" which runs on android. The problem I'm having at the moment is with the power supply. I have a mausberry car switch from my previous project with raspberry pi car system and this worked really well. The mausberry car switch is a simple device which uses two GPIO pins to communicate to raspberry pi 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 Nanopi M4v2 board. From mausberry car setup there only is one bash script which it uses and the source code for it is here:

You can power the N2 directly off the car 12v supply. In my own in-car system I have an Arduino monitoring the ignition state, and when the ignition is switched on it activates a relay to apply the 12v supply to the N2. When the ignition switches off, it waits 10 minutes then sends a shutdown command via USB to the Odroid, then powers it off and the Arduino goes into sleep mode.

Who is online

In total there are 3 users online :: 0 registered, 0 hidden and 3 guests (based on users active over the past 5 minutes)
Most users ever online was 5185 on Wed Jan 22, 2020 1:44 pm

Users browsing this forum: No registered users and 3 guests