A script to check for battery errors with Mauch Sensor Hub X2 V2

Hi everyone,

for our bigger drone with two batteries, we have been using the Mauch system for some time.
The sensor hub has a warning function if there is more current drawn from one battery than the other, which works via a relay which could power an LED or something.

To integrate it into our systems better, I’ve sat down to use the error output and read it into ArduPilot to communicate it further.

Setup:

  • The COM and NC terminals of the error relay are connected to AUX6 on a Cube Orange (measure it out, the drawing on the Mauch website doesn’t seem to be correct)
  • SERVO14_FUNCTION = -1
  • BTN_ENABLE = 1 (refresh params afterwards)
  • BTN_PIN1 = 55
  • SCR_ENABLE = 1 (I think you need to reboot the Cube afterwards)
  • Copy script to /APM/scripts via MAVFtp

The button could be on any aux port, change the pin definition accordingly.
The script has parameters at the top, each with a comment describing it.
Here’s the script:
batteryError.lua (1.4 KB)

I hope it helps a few people!
If I posted this in the wrong category, feel free to move the topic.
If there are improvements, let me know. Also if you want me to contribute it to the applets and the wiki, let me know.

Good work and thanks for feeding that back to everyone.

As an alternative to LUA scripting, you could feed the warning signal into the ADC pin and set it up as an analog fuel level sensor as per the doco. That would give you a fuel level warning if a battery or connector goes bad.
https://ardupilot.org/copter/docs/common-fuel-sensors.html

1 Like