App GpioShutdownService for C2 / N2 / C4 / XU

User avatar
joerg
Posts: 1144
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 55 times
Been thanked: 126 times
Contact:

App GpioShutdownService for C2 / N2 / C4 / XU

Post by joerg »

I was asked if my app GpioShutdownService also works on C2. The old version for C1 not, but this updated version, yes.
[edited]
New version 1.11.0
-Bug 'Wrong device' on N2 64bit fixed.
-Bug 'Gpio WPI 0 (pin 11) not working' fixed.
-Added permissions dialog.
GpioShutdownService-1.11.0.apk.zip
Version 1.11.0
(1.83 MiB) Downloaded 36 times
[edited]
New version 1.10.1
-new shutdown progress as notification, can be switched on/off in preferences | only Android >= O
-preferences edited, now show actual settings in summary, or summary as before if no setting
Screenshot_20200519-181410_ShutdownService.png
Screenshot_20200519-181410_ShutdownService.png (39.13 KiB) Viewed 1285 times
Screenshot_20200519-182705_Trebuchet.png
Screenshot_20200519-182705_Trebuchet.png (940.67 KiB) Viewed 1285 times
[edited]
New Version 1.10.0
-added support for Odroid C4
-corrected bug "Holdpower pin stays active if shutdown from system"

[edited]
New Version 1.9.1
-added device detection string 'odroid-xu'

[edited]
New Version 1.9.0
-added support for Odroid N2
-used newest wiringPi version

[edited]
New Version 1.8.0
-added intents to set and send gpio states
-you can find more information here: viewtopic.php?f=137&t=21386&p=226038#p226038
GpioShutdownService-1.8.0.apk.zip
Version 1.8.0
(1.28 MiB) Downloaded 78 times
[edited]
New Version 1.6.0
-added 4 extra actions
-input type for preferences now AutoComplete (to make live easier)
Version 1.6.1
-compiled with android.injected.testOnly = false in gradle.settings


[edited]
New version 1.5.1
-new actions can be executed:
-On Start Service
-On Shutdown
-On Cancel Shutdown
-On Extra1 Gpio
-On Extra2 Gpio
-actions are these commands you can give at command line as input keyevent 24 or intent as am startservice -a com.maxmpz.audioplayer.API_COMMAND --ei cmd 2


You will find this launcher icon after installation:


This preferences activity will be opened after touching the icon. After done the settings, need to touch the back button in the upper left corner. This will start or restart the service with new settings.
[attachment=2]device-2017-06-12-210640.png[/attac

[edited]
New version 1.4.0
-GPIO access via wiringPi /dev/gpiomem
-New preferences activity, easier to handle
-GPIO numbering now as wiringPi#, e.g 24 = pin35
-Not tested with C1 old Kitkat Version, where is no /dev/gpiomem, please use version 1.3.2 instead.
-Tested with C1 4.4.4. V3.4, C1 5.1.1 V1.4, C2 6.0.1 V2.4


For description see old thread in C1 forum: http://forum.odroid.com/viewtopic.php?f ... own#p80443
[edited]
Version 1.3.2
-Bugfix: Holdpower returns to high if shutdown process takes long time and shutdown pin returns to high
Last edited by joerg on Mon Jun 01, 2020 10:44 pm, edited 20 times in total.
These users thanked the author joerg for the post:
trycatch (Tue Jun 30, 2020 1:04 pm)

User avatar
odroid
Site Admin
Posts: 34947
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 960 times
Been thanked: 775 times
Contact:

Re: App GpioShutdownService for C2

Post by odroid »

Thank you for the useful Service app. :D

GPIO-number and Pin-number are not clearly matched for beginners.
Could you please make a simple diagram of switch connection for beginners or lazy people like me?

User avatar
joerg
Posts: 1144
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 55 times
Been thanked: 126 times
Contact:

Re: App GpioShutdownService for C2

Post by joerg »

Of course, I was already thinking of that. And I will create also a small circuit for a on-off switch, but it takes a little time.

The preset in file settings.c2:

Code: Select all

Gpio.Restart=218
Gpio.Shutdown=214
Time.Shutdown=60000
Gpio.Heartbeat=
Time.Heartbeat=
Gpio.HoldPower=239
Gpio.RemotePiSequence=
Where to find file settings.c2:
Folder.png
(12.27 KiB) Downloaded 5227 times
An example:
Example.png
(6.06 KiB) Downloaded 5227 times
For the laziest:
Header.png
(72.25 KiB) Downloaded 5227 times
Give this command at adb shell, if not, it will never autostart:

Code: Select all

am startservice com.jw.shutdownservice/.GpioShutdownService
Last, you need to give root access.

Vasya Pupkin
Posts: 50
Joined: Mon Mar 09, 2015 12:23 am
languages_spoken: russian, english
ODROIDs: odroid C1 С2
RPi3
Has thanked: 0
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2

Post by Vasya Pupkin »

I have a scheme to enable or disable ODROID, to be installed in the car, if it's interesting, I will provide it with an explanation.

P.S.
Joerg you really cool guy, my respect and reverence!

User avatar
joerg
Posts: 1144
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 55 times
Been thanked: 126 times
Contact:

Re: App GpioShutdownService for C2

Post by joerg »

Yes it would be great if you publish. I have my C1 already 2 years in my car, no need to redesign, but other new user would help your scheme.
And thanks for the flowers.

User avatar
joerg
Posts: 1144
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 55 times
Been thanked: 126 times
Contact:

Re: App GpioShutdownService for C2

Post by joerg »

Here is a circuit I made just now, stripped on a breadboard.
It function is to have a 2 states on-off switch, that safely shut down the Odroid C2. I need it for my Android based All-In-One-PC, so that I don't need any more initiate shutdown and plug out the supply cable. Needed components are two npn universal transistors and 5 resistors, a breadboard, a switch. And header J4 need to be equipped with pins.
In junction with these settings for the ShutdownService:

Code: Select all

Gpio.Restart=218
Gpio.Shutdown=214
Time.Shutdown=1000
Gpio.Heartbeat=
Time.Heartbeat=
Gpio.HoldPower=234
Gpio.RemotePiSequence=
Circuit:
on-off-switch.png
on-off-switch.png (14.13 KiB) Viewed 16163 times
Function:
If switched on, transistor Q1 on, level for EN goes low -> Odroid boots up.
GpioShutdownService controls Gpio234, transistor Q2 on -> holds level for EN low.
If switched off, level on Gpio214 goes low -> Odroid shuts down.
When shut down complete, both transistors off -> level at EN high, voltages on C2 switched off.
Ready to switch on again.
Last edited by joerg on Fri Mar 23, 2018 11:36 pm, edited 1 time in total.

Vasya Pupkin
Posts: 50
Joined: Mon Mar 09, 2015 12:23 am
languages_spoken: russian, english
ODROIDs: odroid C1 С2
RPi3
Has thanked: 0
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2

Post by Vasya Pupkin »

Moderator delete this message please.
Last edited by Vasya Pupkin on Mon May 23, 2016 2:28 pm, edited 4 times in total.

Squal75fr
Posts: 38
Joined: Fri Jul 10, 2015 5:33 am
languages_spoken: English, French
ODROIDs: Odroid U3 & C2
Location: France - Paris
Has thanked: 0
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2

Post by Squal75fr »

Hi
I have the same project to implement my C2 on my car.
I'm completely newbies on GPIO.
Please correct me if I'm wrong about your first sheme:
- 5V on pin 35 will shutdown the C2
- 5V on pin 36 will power on the C2
- Pin 39 should be connected permanently to the ground of the car
is it correct?

About switch is it a on/off model or a pulse one?
Thanks

[EDIT) I forgot the pin 13, I don't understand "holdpower" - does it mean it always connected to +5V? Does it mean that power is supplied directly via GPIO and we don't need the normal power cable (or micro USB) ?

Vasya Pupkin
Posts: 50
Joined: Mon Mar 09, 2015 12:23 am
languages_spoken: russian, english
ODROIDs: odroid C1 С2
RPi3
Has thanked: 0
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2

Post by Vasya Pupkin »

Squal75fr wrote:Hi
I have the same project to implement my C2 on my car.
I'm completely newbies on GPIO.
Please correct me if I'm wrong about your first sheme:
- 5V on pin 35 will shutdown the C2
- 5V on pin 36 will power on the C2
- Pin 39 should be connected permanently to the ground of the car
is it correct?

About switch is it a on/off model or a pulse one?
Thanks

[EDIT) I forgot the pin 13, I don't understand "holdpower" - does it mean it always connected to +5V? Does it mean that power is supplied directly via GPIO and we don't need the normal power cable (or micro USB) ?
gpio only as a contact on off no connection with the ground of the car there.

User avatar
joerg
Posts: 1144
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 55 times
Been thanked: 126 times
Contact:

Re: App GpioShutdownService for C2

Post by joerg »

@Squal75fr
You mean my schemes or from Vasya?
My first scheme is only a example how to use the app. Two push buttons (pulse), one for initiate shut down, one for reboot. Holdpower doesn't has function in this example, pin 13 is not connected. The C2 is always powered via it's power plug. You can't power the C2 over a gpio pin. You can't use this scheme for car, you need something different.
My second scheme is for my All-In-One-PC http://forum.odroid.com/viewtopic.php?f ... 30#p126955. Also it's not for car use. It has a switch, not a pulse one, as long the switch is on, the C2 is on. Here also the C2 is powered by it's power plug. The control of J4 means that the voltages in the C2 can be switched on and off. With J4.1 high, the voltages in the C2 are switched off, the red led is also off. With J4.1 low, the C2 boots up.
The function of Holdpower: As long the system is running, this gpio pin is high. It is a output! After shutting down, it turns to low. This is the moment the power can be switched off save. In the second scheme it controls the Q2. The switch controls Q1. If both transistors off, the J4.1 turns high and the C2 voltages and red led turn off.

Be aware, the J4 should never jumped when system is running. It immediately turns off the C2 and the file system can be corrupted.

For car use refer to the scheme from Vasya. But there is also other solution thinkable. In my car I don't have connected the C1 to the continuous plus, but to the plus that is switched off if the key is off. To bridge this power off, the C1 is supplied by a li-po cell. With car off the shut down is delayed 1 minute. I am thinking to make the delay 10 minutes, because if I am e.g. at patrol station, now the C1 boots up again, I have to wait and I have to program the navigation again.

The other functions.
Heartbeat: It's a output. Alternating with the frequency you give. One user asked me to integrate. He wanted to program a Atiny to have a watchdog.
RemotePiSequence: It's a output. Gives a pulse when shut down is initiated by the soft button in Android screen. It controls the gpio pin for 0.125s high, for 0.2s low, for 0.4s high, and then low. One user asked me to integrate this. I never got a feedback if it is working with the RemotePi-Board: http://www.msldigital.com/products/remotepi-board

Squal75fr
Posts: 38
Joined: Fri Jul 10, 2015 5:33 am
languages_spoken: English, French
ODROIDs: Odroid U3 & C2
Location: France - Paris
Has thanked: 0
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2

Post by Squal75fr »

Thanks joerg for all those clear explanations.
I made some testing: shutdown and reboot work well :-)
I have a concern about holdpower, gpio is always high even if shutting down.
Any idea?
Thanks

User avatar
joerg
Posts: 1144
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 55 times
Been thanked: 126 times
Contact:

Re: App GpioShutdownService for C2

Post by joerg »

I changed the Holdpower to gpio234 (pin33) in second example, because of that. Some gpio are predefined high or low.

Squal75fr
Posts: 38
Joined: Fri Jul 10, 2015 5:33 am
languages_spoken: English, French
ODROIDs: Odroid U3 & C2
Location: France - Paris
Has thanked: 0
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2

Post by Squal75fr »

ok I changeg settings.C2 file with

Code: Select all

Gpio.HoldPower=234
(was fixed to 239).
During starting GPIO is low and become high when I guess service is enable.
Then I shutted down C2. GPIO is still high on pin33.
Same issue as gpio239 (pin13).
Are they any command to check if everything is ok?
Thanks.

Adamouky
Posts: 42
Joined: Tue Apr 05, 2016 3:49 am
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2

Post by Adamouky »

Hi,
Nice work Joerg !!!
I need your help on something because I can't do it myself...
I have a mausberry 3A car power supply/switch and I want to make it work with my C2 on my car with GpioShutdownService.
I don't know if you are familiar to this car power supply so here is what I have noticed:
Car power supply have 5 cables to connect and 2 usb ports to power up devises.
Black wire to ground, yellow wire to constant +12V/battery source, red wire to ignitition/accessory/switched +12V source and pins IN - OUT go toC2 gpio pins.
When ignition is on C2 is taking power from power supply usb then the p.s. to work properly needs a 3.3v from C2 to pin IN and when ignition is off p.s. gives 2.3v to pin OUT to shutdown C2.
And finely when C2 is off pins IN - OUT have no power and power supply turns off until the next ignition.
I don't know how nothing about programming so it is difficult for me to fix this alone...please help...

p.s.
I had the power switch working on a raspberry pi and I have the switch.sh file if it helps.
Thank you
Image

User avatar
odroid
Site Admin
Posts: 34947
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 960 times
Been thanked: 775 times
Contact:

Re: App GpioShutdownService for C2

Post by odroid »

Very useful thread for many different embedded Android applications.
So I've changed it to STICKY. :D

User avatar
joerg
Posts: 1144
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 55 times
Been thanked: 126 times
Contact:

Re: App GpioShutdownService for C2

Post by joerg »

@odroid
Thank you.

@Adamouky
You don't have a data sheet or a connection scheme of this nice adapter? But at least you could upload this script.

@Squal75fr
Maybe I missed a small change in the app to upload here. I will check when I am back from work.

Vasya Pupkin
Posts: 50
Joined: Mon Mar 09, 2015 12:23 am
languages_spoken: russian, english
ODROIDs: odroid C1 С2
RPi3
Has thanked: 0
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2

Post by Vasya Pupkin »

Held the power button for 6-7 seconds to start the system.
Disabling the system is by pressing the power button or turning off the ignition key.
Off from the ignition key is configurable by setting the timeout in the settings file "Time.Shutdown=100".
If a system shutdown from the ignition key not required this option is set "Time.Shutdown=600" in this case, the system is driven only by power button or from the system.

P.S.
Launch control via USB, chose as the easiest.
In a state of "off" the circuit is completely de-energized and consumes no power.

Sorry if the description is not clear, willing to answer any questions.

Link to the schematic diagram.

A small video how it works.
https://youtu.be/_MXjJxj8rtQ
Last edited by Vasya Pupkin on Fri May 12, 2017 8:21 pm, edited 4 times in total.

User avatar
joerg
Posts: 1144
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 55 times
Been thanked: 126 times
Contact:

Re: App GpioShutdownService for C2

Post by joerg »

Thank you, Vasya. I didn't knew that is the same adapter that you use. I hope all is clear for Adamouky now.

User avatar
odroid
Site Admin
Posts: 34947
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 960 times
Been thanked: 775 times
Contact:

Re: App GpioShutdownService for C2

Post by odroid »

Very clear and understandable schematics for Car application. The video is also very helpful to know why/how it works. :D

Vasya Pupkin
Posts: 50
Joined: Mon Mar 09, 2015 12:23 am
languages_spoken: russian, english
ODROIDs: odroid C1 С2
RPi3
Has thanked: 0
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2

Post by Vasya Pupkin »

If someone is interested in this device I give the project in Proteus.

Adamouky
Posts: 42
Joined: Tue Apr 05, 2016 3:49 am
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2

Post by Adamouky »

Vasya, Thank you for your help !!!
When my kids let me I'll give it a try...

User avatar
joerg
Posts: 1144
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 55 times
Been thanked: 126 times
Contact:

Re: App GpioShutdownService for C2

Post by joerg »

I uploaded the last version. Hope it fixes the Holdpower function.

Squal75fr
Posts: 38
Joined: Fri Jul 10, 2015 5:33 am
languages_spoken: English, French
ODROIDs: Odroid U3 & C2
Location: France - Paris
Has thanked: 0
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2

Post by Squal75fr »

Thanks a lot joerg.
I will try and I let you know.

Squal75fr
Posts: 38
Joined: Fri Jul 10, 2015 5:33 am
languages_spoken: English, French
ODROIDs: Odroid U3 & C2
Location: France - Paris
Has thanked: 0
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2

Post by Squal75fr »

hi joerg,
Test is failed. Pin 33 is still high even if C2 is shuted down.
But don't take more time on it - In fact I found other method to completely switch off the C2.
thanks

Squal75fr
Posts: 38
Joined: Fri Jul 10, 2015 5:33 am
languages_spoken: English, French
ODROIDs: Odroid U3 & C2
Location: France - Paris
Has thanked: 0
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2

Post by Squal75fr »

Hi guys,
I was thinking about one new evolution.
Is it possible to have a functionnality to turn off the screen on the C2 using GPIO?

As a reminder I will install my C2 on my car.
I would like to have the possibility to turn off the C2 csreen depending of some evens I will control (open the door, close the car ...)
We have this functionnaly on the U3 with the push button.

Thanks for your help.

Schumy
Posts: 9
Joined: Thu Apr 07, 2016 3:25 pm
languages_spoken: english
Has thanked: 0
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2

Post by Schumy »

joerg wrote:@Squal75fr
You mean my schemes or from Vasya?
My first scheme is only a example how to use the app. Two push buttons (pulse), one for initiate shut down, one for reboot. Holdpower doesn't has function in this example, pin 13 is not connected. The C2 is always powered via it's power plug. You can't power the C2 over a gpio pin. You can't use this scheme for car, you need something different.
My second scheme is for my All-In-One-PC http://forum.odroid.com/viewtopic.php?f ... 30#p126955. Also it's not for car use. It has a switch, not a pulse one, as long the switch is on, the C2 is on. Here also the C2 is powered by it's power plug. The control of J4 means that the voltages in the C2 can be switched on and off. With J4.1 high, the voltages in the C2 are switched off, the red led is also off. With J4.1 low, the C2 boots up.
The function of Holdpower: As long the system is running, this gpio pin is high. It is a output! After shutting down, it turns to low. This is the moment the power can be switched off save. In the second scheme it controls the Q2. The switch controls Q1. If both transistors off, the J4.1 turns high and the C2 voltages and red led turn off.

Be aware, the J4 should never jumped when system is running. It immediately turns off the C2 and the file system can be corrupted.

For car use refer to the scheme from Vasya. But there is also other solution thinkable. In my car I don't have connected the C1 to the continuous plus, but to the plus that is switched off if the key is off. To bridge this power off, the C1 is supplied by a li-po cell. With car off the shut down is delayed 1 minute. I am thinking to make the delay 10 minutes, because if I am e.g. at patrol station, now the C1 boots up again, I have to wait and I have to program the navigation again.

The other functions.
Heartbeat: It's a output. Alternating with the frequency you give. One user asked me to integrate. He wanted to program a Atiny to have a watchdog.
RemotePiSequence: It's a output. Gives a pulse when shut down is initiated by the soft button in Android screen. It controls the gpio pin for 0.125s high, for 0.2s low, for 0.4s high, and then low. One user asked me to integrate this. I never got a feedback if it is working with the RemotePi-Board: http://www.msldigital.com/products/remotepi-board
What battery are you using for the C1?

I really love this solution and I was wondering about how to implement it because I'm using a 12V to 5V converter and I would like also to disconnect it from the battery to avoid drain. Do you know any solution for that?

User avatar
joerg
Posts: 1144
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 55 times
Been thanked: 126 times
Contact:

Re: App GpioShutdownService for C2

Post by joerg »

Hi Schumy,
here I updated the circuit, I once published in another thread: http://forum.odroid.com/viewtopic.php?f ... ost#p85180
ups.png
I soldered everything to a bread board. You can see in this thread:http://forum.odroid.com/viewtopic.php?f ... 100#p84938

Here again the parts (the links are old):
Adafruit PowerBoost1000 (U2) from german supplier: http://www.exp-tech.de/adafruit-powerbo ... -from-1-8v

NoName charging module (U1), bought from german supplier in ebay http://www.ebay.de/itm/321302021261
But also available from AliExpress for some cents.
Bildschirmfoto vom 2019-05-27 13-17-30.png
Bildschirmfoto vom 2019-05-27 13-17-30.png (112.78 KiB) Viewed 7709 times
LiPo cell 950mAH from same german supplier: http://www.ebay.de/itm/321508458468
Or any other that has integrated protection.

2 diodes 3A, e.g, RGP30A.
1 diode e.g. 1N4148
2 universal npn, e.g. BC550C
1 universal pnp, e.g BC560C
1 suppressor diode 1N5908
3 resistors 4k7
1 resistor 3k3

12V to 5V 3A adapter from AliExpress: http://www.aliexpress.com/snapshot/6280893422.html (this I cannot recommend anymore, too much trouble)
instead this is good alternative: https://de.aliexpress.com/item/32796268 ... Title=true
Screenshot_2019-05-27 € 0 47 7% OFF WAVGAT Mini DC DC 12 24V To 5V 3A Step Down Power Supply Module Voltage Buck Converter [...].png
Screenshot_2019-05-27 € 0 47 7% OFF WAVGAT Mini DC DC 12 24V To 5V 3A Step Down Power Supply Module Voltage Buck Converter [...].png (163.81 KiB) Viewed 7709 times
Last edited by joerg on Tue May 28, 2019 7:48 pm, edited 2 times in total.
These users thanked the author joerg for the post:
Richfilth (Tue May 28, 2019 8:25 pm)

TrippleAAA
Posts: 237
Joined: Mon Jun 13, 2016 4:57 am
languages_spoken: english
Has thanked: 0
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2

Post by TrippleAAA »

Why this complicated hardware solution?

You can send the command "reboot -p" (power down) to the console with:

Process mProcess = Runtime.getRuntime().exec("su");
os = new DataOutputStream(mProcess.getOutputStream());
os.writeBytes("reboot -p\n");

...in your android app.

And with the USB Power on... to switch it on.

User avatar
joerg
Posts: 1144
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 55 times
Been thanked: 126 times
Contact:

Re: App GpioShutdownService for C2

Post by joerg »

I don't want to drain the cars battery, so I don't take the power from steady plus, but from switched.
Odroid shall stay some minutes under power even if the car is off, so I need a ups.
Filesystem should not become corrupted when power goes off, so I need a ups.
After delay the Odroid is shut downed with 'reboot -p' and the PowerBoost is turned off, then the LiPo is drained only with some µA.
When car is switched on, the Odroid boots again up.
This works since two years in my car.
If you think you can make it without an ups, then try it. You are welcome to post your solution here.

TrippleAAA
Posts: 237
Joined: Mon Jun 13, 2016 4:57 am
languages_spoken: english
Has thanked: 0
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2

Post by TrippleAAA »

I think... 100 mA drains a "Car" battery (65-120Ah) not enough. You have to leave the car for 20 days to get an empty car battery.

When I would use a delay... then I would use a ready to use device like this:
http://www.ebay.com/itm/12V-Digital-Tim ... 1525599301

Soulsavior
Posts: 11
Joined: Sun May 01, 2016 1:55 am
languages_spoken: english
ODROIDs: Odroid C2
Has thanked: 0
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2

Post by Soulsavior »

Hello everyone!
As i saw this thread, i wanted to join and ask Joerg for his help using the GPIO:
I tried your app and i must say it work perfectly! But i also want to light up a LED at startup using the GPIO. I know (thanks to our PM) that it is possible via your app and using Pin 33, but if possible i would want to have a different app specially made for that purpose...
I don't like having a one-for-all app...
As i'm using Android and you know how to write an app, i would ask if that would be difficult for you to write that, and if it is not, could you write it and provide us with it...

Many thanks in advance for your help!

PS: Sorry if i don't speak english perfectly, as it's not my native tongue. I'm french, and hope that what i'm writing is clear for you all :mrgreen:

User avatar
joerg
Posts: 1144
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 55 times
Been thanked: 126 times
Contact:

Re: App GpioShutdownService for C2

Post by joerg »

Writing an app only to control a LED? Alternativly you could rename the LED to 'ShutdownService active' ;)

TrippleAAA
Posts: 237
Joined: Mon Jun 13, 2016 4:57 am
languages_spoken: english
Has thanked: 0
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2

Post by TrippleAAA »


User avatar
joerg
Posts: 1144
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 55 times
Been thanked: 126 times
Contact:

Re: App GpioShutdownService for C2

Post by joerg »

OK, this comes nearer to the needs of a CarPC. Maybe I take it into account if I decide to change my C1 to C2. Maybe user Schumy can use it. Someone need to confirm that this can be placed on the C2 with its heatsink. But he asked me about my solution I found. Also if it is to complicated for you, two and half year ago there was no ready solution on market. I made it to fit onto the 40p header and as small as it should be for a CarPC. Even for less money and more fun to create my own solution.
By the way, with all devices connected (usb 4G, usb BT, usb GPS, 7"lcd + touch) the current consumtion in running state is 1.2A, in shutdown state 250mA@12V. Could be that this causes user Schumy to search other solution.

TrippleAAA
Posts: 237
Joined: Mon Jun 13, 2016 4:57 am
languages_spoken: english
Has thanked: 0
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2

Post by TrippleAAA »

You can remove the heatsink if you need it... I removed the heatsink with 1 Mhz, and all is working fine at 38°C, graphics is also smooth.

I would use a small Relais-Board with On/Off pins (https://www.amazon.com/SainSmart-101-70 ... B0057OC6D8), connected to the USV... to power of all devices over a powered USB Hub, when it fall into Off state. I did it with the Network switch, and is working perfect.

Soulsavior
Posts: 11
Joined: Sun May 01, 2016 1:55 am
languages_spoken: english
ODROIDs: Odroid C2
Has thanked: 0
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2

Post by Soulsavior »

joerg wrote:Writing an app only to control a LED? Alternativly you could rename the LED to 'ShutdownService active' ;)
Sorry, but i don't understand what you mean by that (maybe because i'm french)... How can you rename a LED :? You perhaps mean renaming your application to 'ShutdownService active' just to control the LED activity, that's it?
If so then that could work i think...
I'll take a look at that possibility.

Soulsavior
Posts: 11
Joined: Sun May 01, 2016 1:55 am
languages_spoken: english
ODROIDs: Odroid C2
Has thanked: 0
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2

Post by Soulsavior »

Well, finally forget it, i soldered a LED on the USB extension cord i had, using the red and black wires and a 65 Ohms resistor... Worked like a charm, and no need to have an application for that!
Thanks anyway, guys!

danhans42
Posts: 19
Joined: Thu Jun 30, 2016 4:38 am
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2

Post by danhans42 »

@joerg

Great work. Just wondering if there was a way to make this work with the Mausberry Pi PSU that was posted above? I am wanting to upgrade my RaspberryPi/OpenELEC Car PC to the C2 that I have?

There isnt a datasheet for the Mausberry Pi PSU, but this is the bash script that I use with OpenELEC..

Code: Select all

#!/bin/sh
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=$(cat /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' > /storage/.config/switch.sh
echo '#!/bin/bash
(
/storage/.config/switch.sh
)&' > /storage/.config/autostart.sh
chmod 777 /storage/.config/autostart.sh
chmod 777 /storage/.config/switch.sh
Would it be easy to get this to work with your code?

Thanks

Dan

User avatar
joerg
Posts: 1144
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 55 times
Been thanked: 126 times
Contact:

Re: App GpioShutdownService for C2

Post by joerg »

It should work.

danhans42
Posts: 19
Joined: Thu Jun 30, 2016 4:38 am
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2

Post by danhans42 »

Thanks for the reply. What pins do I connect from the Mausberry Pi In/OUT pins to C2?

Thanks

User avatar
joerg
Posts: 1144
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 55 times
Been thanked: 126 times
Contact:

Re: App GpioShutdownService for C2

Post by joerg »

Hello Dan,
in the morning I hadn't time for a detailed answer.
As I read the script, connect the pin2 to gpio234, pin33. The setting for that is Gpio.HoldPower=234. Then the pin turns to high when service is started and to low when shutdown is completed.
The other pin1 should be connected to gpio214 pin35. The setting is Gpio.Shutdown=-214. When this pin turns to high the shutdown process is started. Depending on Time.Shutdown, with a delay time.
I hope it works like this.

danhans42
Posts: 19
Joined: Thu Jun 30, 2016 4:38 am
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2

Post by danhans42 »

Thanks for your help.

I have tried wiring up the power supply as suggested. The PSU seems to cut the power to the C2 after approximately a minute so I don't think it's gettingredients it's getting the correct signal it needs.

I'll have a fiddle with it but will probably give up and build one of yours from the schematics

LordadmiralDrake
Posts: 82
Joined: Wed Mar 30, 2016 6:24 pm
languages_spoken: english
ODROIDs: Odroid C2
Has thanked: 0
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2

Post by LordadmiralDrake »

@joerg:

I looked at your last schematic and it seems pretty straightforward, but: How is power on/off actually controlled when using this circuit?

User avatar
joerg
Posts: 1144
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 55 times
Been thanked: 126 times
Contact:

Re: App GpioShutdownService for C2

Post by joerg »

@LordadmiralDrake
There is missing an input for shutdown in this circuit. I will update the circuit when I am back home. There is one resistor 4k7 from 5V to gpio214 and one resistor 10k from gpio214 to ground. This devides the 5V to about 3.3V. I don't like to test if the inputs are 5V-tolerant.
The power on happens by switching on the 5V, over Q1, D4 and Q3 the pin Enable of the PowerBoost becomes high.

LordadmiralDrake
Posts: 82
Joined: Wed Mar 30, 2016 6:24 pm
languages_spoken: english
ODROIDs: Odroid C2
Has thanked: 0
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2

Post by LordadmiralDrake »

There are 5V tolerant IOs. They are used for the HDMI connector though

danhans42
Posts: 19
Joined: Thu Jun 30, 2016 4:38 am
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2

Post by danhans42 »

@joerg

Just wanted to say thank you for this great piece of work!! I have now got it working perfectly in my Audi.. I have used a Arduino, MCP2515 and a relay and have used the ignition key switch position from the vehicle CAN comfort bus!
I will do a write up in the projects section once its all finished.

Thanks again!

Dan

User avatar
joerg
Posts: 1144
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 55 times
Been thanked: 126 times
Contact:

Re: App GpioShutdownService for C2

Post by joerg »

Fine, that you managed it. Yes, please post it, so other users can learn from. Specially the CAN thing. If you are getting messages from CAN bus, you are a lucky one. With my Volvo car I wanted to integrate the media buttons from the steering wheel. But after a lot of work, making my own CAN sniffer with some laying around SAM7x board, I found that all media in my Volvo is communicating via fibre optic MediaBus.

LordadmiralDrake
Posts: 82
Joined: Wed Mar 30, 2016 6:24 pm
languages_spoken: english
ODROIDs: Odroid C2
Has thanked: 0
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2

Post by LordadmiralDrake »

In my Mazda the steering wheel remote is just a resistor ladder. All I need is the ADC ^^

danhans42
Posts: 19
Joined: Thu Jun 30, 2016 4:38 am
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2

Post by danhans42 »

In the Audi I am pretty lucky. I have the steering controls as well as some of the buttons and the dial on the sat nav for controles. The same arduino gets the can messages and uses an Arduino USBHID library to send them as key presses. Works pretty slick.

danhans42
Posts: 19
Joined: Thu Jun 30, 2016 4:38 am
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: App GpioShutdownService for C2

Post by danhans42 »

@joerg Does the shutdownservice work with the Android 2.0 update? Just anted to check prior to updating as I have misplaces my emmc SD adapted.

Thanks

Post Reply

Return to “Android”

Who is online

Users browsing this forum: No registered users and 2 guests