Raspberry Pi herunterfahren (shutdown)

Tinker

Member
Hallo,

erst einmal möchte ich dir @EinEinfach meine Hochachtung zu der tollen Leistung aussprechen, die du durch die Erstellung der Cassandra SW erbracht hast!
Ich plane meinen Ardumower mit Cassandra zu versehen und setzte auf einen Raspberry Pi mit USB Anbindung zur Sunray Firmware. Einen Raspberry 4B konnte ich schon mit Cassandra versehen.
Meine Frage bezieht sich auf den Shutdown des Rpi: In Cassandra habe ich keine Möglichkeit gefunden den Raspberry kontrolliert herunterzufahren. Habe ich etwas übersehen? Wie macht ihr das? Ich möchte nicht jedes Mal über SSH den Shutdown auslösen. Bisher „ziehe ich einfach den Stecker“ bei meinen Tests. Das ist eigentlich nicht die Methode der Wahl und führt, so denke ich, früher oder später zu Problemen. Also, gibt es eine einfache Möglichkeit den Raspberry herunterzufahren?

Ciao
Mario
 
Ich habe da was zusammengeschrieben, kann aber aktuell nicht testen. Wenn du testen kannst/willst, sag Bescheid, dann pushe ich es hoch
 
Danke für die schnelle Reaktion!
Habe auf V0.101 upgedated aber keine Option für einen RPi shutdown gefunden, wo ist die versteckt? Betreibe aber auch gerade den Raspberry standalone ohne Mower Anbindung. Liegt es vielleicht daran?
 
Es sind im log eigentlich nur diese Zeilen:
2024-02-27 17:08:44 INFO TX: AT+V,0x16
2024-02-27 17:08:44 INFO Connecting...
2024-02-27 17:08:40 WARNING HTTP-Connection to the rover lost or not possible. Trying to reconnect
 
Du musst schon in UART Mode sein, sonst ist das Herunterfahren nicht aktiv, weil es eig. keinen Sinn macht das in den anderen Modis zu aktivieren
 
Ja, mit UART Verbindung klappt auch das Runterfahren des RPi! Vielen Dank!
(Btw: Ich fände ja durchaus ein Runterfahren ohne Sunray auch sinnvoll, aber das ist nicht so wichtig!)
 
@EinEinfach
I have change some part in the sunray firmware to do that correctly and wait 20 second between the shutdown command and the effective power off of the PCB.
Did you manage the correct PI shutdown without changing sunray firmware ??
 
Did you manage the correct PI shutdown without changing sunray firmware ??
Not really. My way is to connect rpi to P16 on PCB (this connector is always powered on). The problem is here this connector is not undervoltage protected as for example P17. I tried also P17 but here is the problem the AGM4/Due can not be flashed OTA via rpi. Before the new binary to be uploaded to AGM the batterySwitch goes to low for a short time and P17 isn't powered on anymore. Therefore I leave rpi connected on P16 in this case no modifications are needed on sunray fw.
 
Grundsätzlich ist es auch möglich, den RPI per Permanent-Power (P16) zu versorgen und per P17 den Shutdown auszulösen und auch per P17 das Wakeup einzuleiten. Das hatte ich so mal in einem anderen Projekt gemacht. Die Schaltung habe ich sogar noch. Nur finde ich den Schaltplan nicht mehr. Sie ist für 9V-36V geeignet.
Theoretisch sollte es dann auch gehen, dass man den Shutdown verzögert ausführt und ganz unterdrückt, wenn die Spannung in der Zwischenzeit wiederkehrt. Letzteres hatte ich aber nur in den Schaltungen zur Steuerung größerer Computer integriert. Wenn ich den Plan wiederfinde, hänge ich ihn hier mal rein. Es müsste hier eigentlich genauso praktisch funktionieren wie im Fahrzeug.
 
Not really. My way is to connect rpi to P16 on PCB (this connector is always powered on). The problem is here this connector is not undervoltage protected as for example P17. I tried also P17 but here is the problem the AGM4/Due can not be flashed OTA via rpi. Before the new binary to be uploaded to AGM the batterySwitch goes to low for a short time and P17 isn't powered on anymore. Therefore I leave rpi connected on P16 in this case no modifications are needed on sunray fw.
It's ok on P17 to flash ACGM4, but you need the extra capacitor.

Now you need to read the AT+Y3 command feedback on cassandra for the undervoltage protection or send it to power off

Simply change sunray as follow :

Into amrobotdriver.cpp add a 30 second delay before power off to leave time to raspberry pi to shutdown correctly
Code:
void AmBatteryDriver::keepPowerOn(bool flag){
 if (!flag){ //power off need a delay to leave raspberry pi poweroff also
      String s = F("Y3");
      CONSOLE.println(s); //i don't know why but no feedback when sunray app send poweroff, so i add it here
      for (int i = 0; i < 30; i++)
      {
      delay(1000);
      watchdogReset();
      CONSOLE.print("Countdown before Power OFF : ");
      CONSOLE.println(i);
      }
  }
    
  digitalWrite(pinBatterySwitch, flag);
}

@EastSoft No need hardware change simply use P17 and the start button to power on the PCB and sunray app or "cassandra" to shutdown
 
No need hardware change simply use P17 and the start button to power on the PCB and sunray app or "cassandra" to shutdown
If I shutdown the mower by sunray app, the mower will turn off the power without shutting down the Pi before.
I need something that tells the Pi to shutdown (perhaps the pi power button solution). Then it will work in every case including shut down by mower power button. How do you tell the pi to shutdown before switching off the power?
 
If I shutdown the mower by sunray app, the mower will turn off the power without shutting down the Pi before.
I need something that tells the Pi to shutdown (perhaps the pi power button solution). Then it will work in every case including shut down by mower power button. How do you tell the pi to shutdown before switching off the power?
When a command is send to sunray firmware (Over BT by sunray app or UART by Pi) one answer is send as feedback by sunray firmware

So PI need to read and decode the feedback Y3, sentense (it's power off request)
BUT in the original firmware when Sunray app send AT+Y3 the PCB immediatly power off , so pi can't receive the answer.
It's the reason why you need to add the change i suggest to have a 30 second delay between the AT+Y3 send by sunray app and the real power off the pcb.


By this way When a power off is initiate by Sunray App or Pi , or undervoltage ,Pi receive "Y3," sentence and have 30 second to power off correctly before the PCB shutdown.

If you need i can make a simple video of the shutdown process of PiSunray,so you can see the console result
 
Oben