Hi @qiuqiuggl,
How you achieve this depends a bit on what information you need to receive at the topside.
From a hardware perspective, the easiest way to do this would be using one of the Pixhawk AUX pins as an input, or possibly one of the ADC pins. To then get that working in software you can either create a custom version of ArduSub so that it can detect an input and send a suitable MAVLink message (of your choosing), or you can abuse the existing leak detection mechanism by setting the LEAK2_PIN
parameter to AUX 5 (with an appropriate LEAK2_LOGIC
value), in which case you’ll get a “Leak detected” warning when your battery level signal changes on the AUX 5 signal input pin. Note that it’s then not possible to tell the difference between a battery level notification or an actual leak.
Alternatively, if you’re using a Companion computer you could convert the battery level signal down to 3.3V (with a level shifter, or just a voltage divider from two resistors, e.g. 12kΩ and 22kΩ), in which case you could connect it to one of the Raspberry Pi GPIO pins, and run some Python code to monitor it and send a relevant MAVLink message when it changes. You could send regular BATTERY_STATUS
updates, or perhaps just a STATUSTEXT
for QGC to read out, as described here.