Arm Cortex-M based STMicroelectronics board reports own power consumption and Li-ion battery state of charge, detected by I2C serial connected current sensor and charged by a solar power manager.
This project uses the NUCLEO-F401RE’s IDD module, a header that allows for the measurement of the board’s power consumption. With a jumper removed, a current sensor can be attached. The voltage output by the sensor is proportional to the current through the IDD module, and that output is sent to an analog input on the board for reading.
The project also explores the board’s external power options, in particular its external 5V (E5V) ability, although it may also take an external 3.3v source, or a 7-12v source (VIN). A solar power management board generates electricity from panels to run the board, current sensor, and to charge a battery. Together these elements--energy generation, storage, and self-monitoring--are essential capabilities of an autonomous power system.
The INA3221 is a three-channel current and voltage. It provides the present reading of voltage up to 26 volts, and current, or smooths data by averaging its inputs over time. It has programmable warning triggers, and an optional input for a reference power supply for comparison to the sensor channels. The three channel was selected for the possibility of monitoring battery charge and consumption of other peripherals. The solar power manager, however, provided a header pin for battery voltage. A single-channel current sensor, the INA219, could have been used instead. The current sensor is connected to the IDD module by two wires, V+ and V-. If the IDD jumper is removed and no sensor is connected, the board will not be powered. The current sensor communicates with the Nucleo by four wire IIC serial.
The solar power management board, produced by DFRobot, is capable of providing 5V, 1A, from solar power, USB in, or rechargeable batteries. It has 3 5V header pins and 1 USB out for powering peripherals. A voltage regulated solar panel and LiPo rechargeable battery are used for generation and storage. This board serves as the sole power supply for all the components of the prototype. Power over USB is disabled, and E5V on the Nucleo board by moving JP5 to cover pins 2 and 3. The 5V supply form the DFRobot board is connected to the E5V header pin. The INA3221 is also powered from a 5V pin on the DFRobot board. The battery pin is connected to an analog input on the Nucleo for monitoring its charge level. An power switch controlling the 5V pins (EN) is required to be connected when using the battery voltage pin, and vice versa. In this case it is connected to a digital input, and the switch can be turned off by driving the pin low.
The INA3221 is driven by library written by Sven Lack for the mbed platform. Libraries targeting early version of mbed are plentiful, but are error prone when used with mbed 6, this project’s development platform. Although Lack’s library predates mbed 6, only a few small changes were required to make the code conform to the current mbed API. The main program creates a connection to the current sensor over IIC serial ports, sets a required shunt voltage parameter (by default 40uV) and optional warning limits, then display the voltage and current through the Nucleo on the console.
The battery readings from the DFRobot ssolar power manager are made with an mbed API AnalogIn object. The read_voltage() method returns the voltage applied to the analog port, up to a given reference voltage (in this case 3.3v). The value returned is a floating point value, which is slow and power-intensive when performing arithmetic, and not-well supported for serial transmission, especially in the context of a microcontroller, so it is converted to a byte representation. The battery voltage can also be read as a percent of the system voltage by calling read() on the AnalogIn object. Care should be taken in interpreting this value, because, for example, a battery at 60% of system voltage is not adequate to power the system. It is not a linear measure of battery charge because batteries behave differently depending on where they are in their charge cycle. These measurements provide a rough estimate of battery charge only. Another method of measuring the battery charge that could be performed with this prototype (with some rewiring) is coulomb counting, using current sensors to measure the difference between the charges flowing in and out of the battery over time.
https://youtu.be/khUuH4kUXx8