Network based (remote) radio power on/off

G2 operating system and special app's (e.g. p2app) discussion only--post Thetis and piHPSDR questions in their own sub-forums
K1VL
Posts: 5
Joined: Mon Aug 28, 2023 9:00 pm
Location: Shrewsbury, Vermont

Network based (remote) radio power on/off

Postby K1VL » Thu Sep 21, 2023 12:34 pm

I was wondering if there is a software feature (or a plan for a feature) that would allow for the G2 to be remotely turned on and off. Right now after I apply 12 volts to the radio I have to physically push the power button to turn it on. To turn it off gracefully I have to push the power button once momentarily to allow graceful shutdown of the Pi and then long press again to power off the radio, so there is some logic in the power switch function. As I almost exclusively run my G2 (no front panel) in a rack at a distance from my operating position it would great to have it stay in a lower power standby mode with software on/off capability for the radio and Pi.

I have Flexradio 6000 series radio and there is a graceful remote on/off capability by way of an external relay. I use a web enabled switch to control that function.

Carmine K1VL
Carmine K1VL
User avatar
w-u-2-o
Posts: 5488
Joined: Fri Mar 10, 2017 1:47 pm

Re: Network based (remote) radio power on/off

Postby w-u-2-o » Thu Sep 21, 2023 1:57 pm

Knowing that the G2 uses a CM4 GPIO pin to facilitate safe shutdown, it should be possible to create a script to shut it completely down. However, there is no way to get it to turn back on again because the CM4 is completely shut down and powered off.

The best approach is probably to use the same type of external relay you are using with the Flex. Obviously you'll have to add an external connection across the terminals of the main power switch.
ct1iqi
Posts: 36
Joined: Thu Jul 06, 2023 4:01 pm

Re: Network based (remote) radio power on/off

Postby ct1iqi » Fri Sep 22, 2023 9:18 am

Had same question and came to same conclusion on basis of circuit diagram: no go. Once off but with supply voltage present one cannot switch the G2 on, other than by the button. Am experimenting with this item:
aliexpress.com/item/1005005526322149.html which I happen to use in other applications and is very reliable. It can work from 5-24 V, connects to LAN, and has commands to close a relay for ~1/2 s, or 1, or multiple seconds. It has two relays, so one left for something else.
Software: https://github.com/cryxli/sr201 and https://sr-201-relay.sourceforge.io/
The copper trace distances on the PCB for the two relays are OK for 12V but would not trust it at 230V AC.
The short/long press timing of the power button is depending on RC values, so not very exact. I hope the shortest and fixed 1/2 s relay timing will fall well within the button timing for 'short' press.
ct1iqi
Posts: 36
Joined: Thu Jul 06, 2023 4:01 pm

Re: Network based (remote) radio power on/off

Postby ct1iqi » Fri Sep 22, 2023 3:26 pm

some results:
with the above mentioned 2-relay board one can indeed reliably switch the G2 on.
But when giving the 1/2 second shorting of the power button to turn off, this turns out to be to long. The power is switched off immediately.
The 'short' button press needs to be quite short. For now I'll issue a shutdown command to the CM4 per ssh, prior to operating the relay for 'off'. Alternatively one could use the second relay to signal the CM4, without influencing the power switch circuit itself. The CM4' OS has GPIO26 configured as input and associated with the shutdown command. It is present on pin 37 of the 2x20 header. As I am not using the XLR microphone connector, I used it as feed through for the 2-lead cable to the external relay board, so as for the time being not to have to drill a hole and damage the G2. Also the connection of the relay wire to the switch wiring can be done in a reversible way by preparing two short leads that have on one side a single pin male header connector, and on the other a female, and half-way the relay wire soldered. Now can switch everything on from a bash script that first switches on the power supply, using a Sonoff MQTT mains switch, followed by switching the G2 on via the relay board, followed by starting pihpsdr on the PC. An 'off' script makes pihpsdr on the PC do an exit, storing its settings, followed by a ssh command to the G2 to shutdown ( sudo /sbin/shutdown now' ), followed by the relay board powering off the G2, followed by powering off the power supply per Sonoff switch. To prevent ssh having to login per password, the PC's RSA public certificate is put in a 'authorized_keys' file in /home/pi/.ssh

Return to “G2 Operating System & Applications”