In my Raspberry Pi tablet, I use very low frequency PWM to measure the battery voltage. One half of a dual voltage comparator was set up as a sawtooth oscillator operating at approximately 100Hz. The output of this was compared against a divided-down version of the battery voltage by the other half. The output of that in turn was tied into a GPIO pin.
The PiCheckVoltage project may be stale for a reason. It strikes me as a bit over-complicated for the situation you've described. However, parts of the code may be useful. Here are some alternatives to consider:
1. Use "protected" 18650 batteries?
18650 batteries can be bought in a "self-protected" configuration.. You probably knew this ...
Why not go for a dedicate i2c monitor / controller - the boards are available for a few pounds on Ali et al and not much more at end user prices?
The INA219 will measure voltage and current, cope with up to 25+ volts and come on boards ready built.
One option would be to use an MCP3002 ADC (2 channel analogue to digital converter).
Use a voltage divider circuit (2 resistors) to convert your battery voltage to a voltage range upto 3.3V. Feed this into one of the analogue channels on the MCP3002.
Both voltages are tolerated by the Raspberry Pi 3B, but official documentation actually suggests 5.1V.
Higher voltages usually mean more power if the amperage is the same. Also a higher voltage might give a little more heat output, but 0.1V is very negligible.
I suggest using the 5.2V as some of it will be lost to the inefficiencies of cabling.
Source: Power ...
No, the GPIO pins can not be used to drive a DC motor.
They can only supply a few milliamps of current at 3V3 which will not be enough. In addition driving any inductive load direct from a GPIO is likely to destroy the GPIO and the Pi. An inductive load is such as a DC motor or a relay coil.
You need a motor driver board or chip or discrete components (e.g. ...