How to Write your own Flight Controller Software — Part 6

LiPo Battery Monitoring using a scheduler.

David Such
13 min readFeb 12, 2022

All of our drone prototypes use LiPo batteries to provide power. These are a good choice in terms of current delivery, size, weight and capacity. However, you don’t want to over discharge them or you can impact battery life. To help prevent this we developed a library which can be used to regularly check the battery voltage, allowing us to take action if it gets too low.

We have motor shields which suit the Arduino UNO, Mega 2560, and the Nano 33 IoT. Our Magpie drone can use the Nano 33 BLE, Nano 33 IoT and the Portenta H7. Ideally we want a scheduling library which is suitable for all the Arduino boards.

Although this library was originally for scheduling battery readings, we found that it has much wider application. The examples folder of the library contains the following sketches:

  • nonBlockingBlink: An implementation of the classic blink sketch using ReefwingTimer.
  • batteryCheck: An example of a scheduled task, in this case checking the battery voltage every second.
  • serialTimeout: Stops waiting for a serial connection after 5 seconds.
  • userTimeout: Stops waiting for user input after a set period.
  • debounceTimer: How to use ElapsedMillis as a switch debounce timer.
  • multipleTimers: A simple multitasking example.

--

--

David Such

Reefwing Software · Embedded Systems Engineer · iOS & AI Development · Robotics · Drones · Arduino · Raspberry Pi · Flight Control