-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodem_power.sh
More file actions
executable file
·28 lines (25 loc) · 1.18 KB
/
Copy pathmodem_power.sh
File metadata and controls
executable file
·28 lines (25 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
# Toggle SIM7080G HAT power by pulsing the PWRKEY line (BCM GPIO4).
#
# The PWRKEY is wired through an inverting driver:
# GPIO4 LOW = key released (module runs)
# GPIO4 HIGH = key pressed
# A single ~1.5s HIGH pulse = one PWRKEY press, which toggles the module:
# it powers ON if it was off, or OFF if it was on. There is no separate
# "on" / "off" level - the same pulse does both. Check the result with:
# ./modem_at.py "AT" (OK = on, no response = off)
#
# Requires `pinctrl` (ships with Raspberry Pi OS). No sudo needed if your user
# is in the `gpio` group (the default `pi`/first user is).
set -e
GPIO=4
PULSE_SECONDS=1.5
echo "Pulsing PWRKEY (GPIO${GPIO}) high for ${PULSE_SECONDS}s to toggle power..."
pinctrl set "$GPIO" op dl # ensure released (low) to start
sleep 0.3
pinctrl set "$GPIO" dh # press (high)
sleep "$PULSE_SECONDS"
pinctrl set "$GPIO" dl # release (low) - and keep it low so it doesn't float
echo "Done. Wait ~15s for the module to boot, then probe with: ./modem_at.py \"AT\" \"AT\""
echo "NOTE: keep GPIO4 driven low at boot (gpio=4=op,dl in config.txt) or the"
echo " floating pin will power-cycle the module every ~15s."