Page 1 of 1


Posted: Sun Nov 15, 2020 5:05 am
by Daitaro
Hello all!

The raspberry pi has a feature where you can set the dtoverlay to initiate a gpio-shutdown command when gpio pin 3 goes to ground, and if you state-change the pin while off, it will boot the device.

Is there a way to set this up for the T4? It's gpio compatible, but I'm not sure there's a way to access the same hardware layers.

Similarly, can anyone think of a way to keep the barrel jack powered, but trigger sleep/wake from an external source? Think a module where there is constant 12v on the jack, but say... a key switch that can also provide 12v. This is similar to how a car would be wired. The radio (for this example) is under constant power, but only turns on when you turn on the key.

I'm not sure how to get gpio to my liking on the T4. I've only done tons of gpio on pi's. Is there no interface inside of the T4's android that allows access to modify gpio? I have to build it from the code?

Re: GPIO-shutdown

Posted: Sun Nov 15, 2020 8:07 am
by v8dave
Hello again.

The T4 GPIO Is easy to use from Android but you do need to ensure that you have user access to it and to do this, you need to add some settings to the .rc file to set the ownership and chmod for access.

To do the power up and down via another GPIO Pin is not so easy but the power button works the way you want it to. I extended this out to a connection with 2 wires so I could fit a front panel switch. By sorting out this connection, I can power up the T4. There is a link on the latest T4 to not power up after applying 12V power until the power button is pressed.

You can also use an open collector transistor to power up the T4 but you'd need to check the polarity to the existing switch. One side is ground and the other is to the PMIC GPIO input.

If you wanted some other fancy control with Android, you'll need to hack the OS for this.

20201115_145548.jpg (116.98 KiB) Viewed 2101 times

Re: GPIO-shutdown

Posted: Sun Nov 15, 2020 8:38 am
by Daitaro
Yeah I built in a header to the board so I have the power switch able to be accessed, but only in "last resort" mode, ideally. Honestly I really needed it to be automated when that 12v "accessory" voltage initiates.

Here's my thought. It's easy enough to use that 12 volts to power a solid state relay. That relay could then close a circuit that essentially would be seen to the OS as a "button press."

If I could use that relay to simulate a button press over gpio (by essentially pulling pin 3 low for instance) then I should be able to read that press and call the key_power command or something similar.

12v off -> relay opens -> gpio pin goes high -> sleep/shutdown

12v on -> relay closes -> gpio pin goes low -> wakeup/some other power control method

I can access the gpio pins easy enough through terminal. echoing out through cat commands gets me what I want. The issue is interfacing with the pins. How, in software, do I go from a pin going low/high to a command being called?

In raspi, we use wiringpi. For the T4 in android.. there seems to be no such wiringpi port. Is there an alternative that doesn't require serious research/OS building? I don't mind a little code, but I'd be asking tons of questions for what seems like the simplest of tasks... open circuit, shut down. That's it, lol.

Any thoughts? They are most appreciated so far.

Re: GPIO-shutdown

Posted: Tue Nov 17, 2020 6:01 am
by v8dave
I did a design to use the T3 (same applied to T4) in a mobile application and used an ATTINY414 to handle the ignition detection and shutdown. The ATTiny was powered by the same 5V that powers the T3.

Scenario 1. Ignition ON : The ATTiny reads the ignition status and if it detects that the input is active, ie the user switch the ignition on, it switches a transistor connected to the power button input (not the ground side) and being open collector, it pulls the input LOW. The device powers up.

Scenario 2. Ignition OFF : The ATTiny detects this and outputs a GPIO pin to HIGH that the T3 is monitoring with a background application. It then commands the system to shutdown. The loss of the 3.3V is detected by the ATTiny and it knows the device is off and goes back to the checking for ON state.

The ATTiny is cheap and doesn't even need a crystal. Prog and debug over the 1-wire debug port.

Your issue is that whilst in power off there is no way to monitor the GPIO without an external micro. The ATTiny in my case draws little power and I actually put it sleep and only wake up every second for about 10ms and then back to sleep.

Re: GPIO-shutdown

Posted: Tue Nov 17, 2020 7:34 am
by Daitaro
Exactly. It seems we've both encountered the same problem. Since I have dozens of little arduino nanos lying around, I've decided to employ one for this application. I had some old laptop chargers that had failed in one way or another, and I decided to go scavenging for some optocouplers off of them. Bingo, found two next to each other.

I'll be utilizing the 12v switching power to (de)activate one of those optocouplers which will be connected to a pin of the arduino, which will use that signal to output high/low to the second optocoupler which will then trigger a power button press to wake/sleep the T4. I'll be fully isolating the T4 to its own system while keeping the arduino isolated, and so forth. Same scenario as you've employed. I CAD'd up a design and 3d-printed a power pack utilizing some old laptop battery cells (fully load tested for capacity and endurance - not new to that game *for sure*) which will keep everything happy, conditioned, and alive to do all of the monitoring. Used a benchtop supply to measure all current consumption and with the T4 in deep sleep, it won't be a problem at all to keep it powered on but sleeping in between uses. Perfect.

Was it really so hard to have some hardware triggers for this? I mean, the T4 is an amazing board with amazing performance, but damn! Give us some options. Lol. It has so many niche connector features, but none of the best stuff. Like with the pi... flipping fantastic board, but it will take an act of God to get a power button put in. :roll: