Skip to content

Instantly share code, notes, and snippets.

@dkebler
Last active December 30, 2023 19:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dkebler/aa02d96e696a1858bda998f345a095af to your computer and use it in GitHub Desktop.
Save dkebler/aa02d96e696a1858bda998f345a095af to your computer and use it in GitHub Desktop.
Pine64 RockPro64 Powerup Watchdog

Rockpro64 Power On Watchdog using esp8266 and Tasmota

Problem

Some times after power loss (12v) the rockpro64 will not fully power on when 12v is restored. It will enable 5V but then it will not "power on" which is indicated by pin 1 raising to 3.3v. This is fixed by pushing the power button for 5-8 seconds which for sure forces the rockpro off and then a single push of a second. We can use these facts to "push" the power using a relay powered by a esp8266 running the Tasmota firmware and a simple tasmota rule. Below are the details. You ONLY need to do this is you are using the rockpro64 in an unattended mission critical application (e.g a NAS box running your cloud server).

WARNING WARNING WARNING

I take NO responsibility if you brick/fubar your rockpro64 or wemos boards doing this. Please understand and test first. Don't just connect your watchdog to the rockpro64 rather set up a testbench like I did by using the 3.3v pin on the D1 mini and a switch instead of pin1 on the rockpro to simulate the board coming online or not. On your test bench you can power it with the same usb cable used used to flash it.

2023-12-03_13-29-09

Hardware

Wemos D1 mini with wemos relay shield https://www.wemos.cc/en/latest/d1/d1_mini.html#documentation https://www.wemos.cc/en/latest/d1_mini_shield/relay.html

available from aliexpress or amazon.

Connections

  • GND- 10Kohm resistor - D5
  • D5 - 10Kohm resistor - pin 1 on PI2 connector (3.3v) (resistor has been soldered onto patch wire and covered with heatshrink.
  • 5V - pin 4 on PI2 connector (5V)
  • GND - pin 6 on PI2 connector (GND)
  • Relay NO/Common - two jumper wires - fed to bottom of board and soldered either side of power switch

Firmware

Install tasmota full rules binary. It's available via the webinstaller https://tasmota.github.io/install/ or here https://github.com/Jason2866/Tasmota-specials/releases

get device on your network see tasmota docs https://tasmota.github.io/docs/

Copy paste this template into template on configure other page

Tasmota Template {"NAME":"RockPro64Watchdog","GPIO":[1,1,1,1,1,224,1,1,1,1,160,1,1,1],"FLAG":0,"BASE":18}

Configuration

Options to set (once)

  • SetOption114 1 # detach swithes
  • SetOption65 1 # never recover
  • WifiConfig 5 # always wait for wifi (never go into AP mode)

so copy and paste this line into console.

Backlog SetOption114 1; SetOption65 1; WifiConfig 5

if you have an mqtt broker you can confirure it. Then it's possible to subscribe to

Add Rule

notes:

  • 8 second "holding" power button down to make sure machine has stopped, then a single one second power button "push"
  • checks every 30 sec to make sure board is till powered on (3.3v at pin 1)
  • If you have an MQTT broker running then change the publish and subscribe topics to suit.
  • It's possible then to "hard" reboot the board by publishsing any payload to the subscribe topic

clear rule1 by copy and paste into console.

Rule1 "

Now edit and paste this entire rule set into console. Change mqtt topics to suit

Rule1  
ON power1#boot do power1 0  ENDON
ON power1#boot do backlog status 8; Publish 238/NAS/state "poweron" ; ruletimer1 5; ENDON
ON mqtt#connected DO Subscribe reboot, 238/NAS/reboot ENDON
ON Event#reboot DO backlog Publish 238/NAS/state "manual reboot"; power1 1; ruletimer 3 8  ENDON
ON rules#timer=1 DO backlog Publish 238/NAS/state "checking"; ruletimer2 1; ruletimer1 30 ENDON  
ON rules#timer=2 DO IF (%switch1%==1) Publish 238/NAS/state "started"  ELSE backlog Publish 238/NAS/stat "failed"; power1 1; ruletimer3 8 ENDIF ENDON
ON rules#timer=3 do backlog power1 0; ruletimer4 1 ENDON
ON rules#timer=4 do backlog power1 1; ruletimer5 1 ENDON
ON rules#timer=5 do backlog power1 0; Publish 238/NAS/state "rebooting..."; status 8; ENDON

then turn the rule on

rule1 1

2023-12-02_13-11-31 2023-12-02_13-38-30 2023-12-02_15-33-52 2023-12-02_15-35-02 2023-12-02_15-37-01

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment