This code will not run on a Raspberry Pi single board computer since Pi SBCs do not have an analog input.
It's easy to use the LM73100 Ideal Diode with CircuitPython, and the analogio core module. This module allows you to easily write Python code to read analog input data from the LM73100 IMON pin.
CircuitPython Microcontroller Wiring
First wire up the breakout to your board exactly as follows. The following is the breakout wired to a Feather RP2040 with the breakout inline with a lipo battery:
- LiPo battery positive to ideal diode VIN (red wire)
- LiPo battery negative to ideal diode GND (black wire)
- Ideal diode OUT to Feather JST-PH positive (red wire)
- Ideal diode GND to Feather JST-PH negative (black wire)
- Ideal diode IMON to Feather pin A0 (yellow wire)
Note that when you connect the Feather via USB for serial monitoring, the battery goes into charge mode and as a result isn't drawing any current through the battery. You can use an additional Feather or microcontroller to get current readings for this demo:
- LiPo battery positive to ideal diode VIN (red wire)
- LiPo battery negative to ideal diode GND (black wire)
- Ideal diode OUT to Feather 1 JST-PH positive (red wire)
- Ideal diode GND to Feather 1 JST-PH negative (black wire)
- Feather 1 GND to Feather 2 GND (black wire)
- Ideal diode IMON to Feather 2 pin A0 (yellow wire)
In practice, for a battery powered IoT project for example, you would likely be reading the current from the battery connected to the target Feather in code or logging wirelessly.
CircuitPython Usage
To use with CircuitPython, you need to update code.py with the example script.
Thankfully, we can do this in one go. In the example below, click the Download Project Bundle button below to download the necessary libraries and the code.py file in a zip file. Extract the contents of the zip file, and copy the code.py file to your CIRCUITPY drive.
Your CIRCUITPY/lib folder will be empty since the example is only using core modules that are built into the CIRCUITPY drive.
The /lib folder will be empty since the example is only using core modules.
Example Code
Once everything is saved to the CIRCUITPY drive, connect to the serial console to see the data printed out!
# SPDX-FileCopyrightText: 2025 Liz Clark for Adafruit Industries
#
# SPDX-License-Identifier: MIT
# LM73100 IMON Current Monitoring
import time
import board
from analogio import AnalogIn
RIMON = 1500.0 # 1.5kΩ
GIMON = 2.5 # μA/A
analog_in = AnalogIn(board.A0)
def get_voltage(pin):
return (pin.value * 3.3) / 65536
print("LM73100 Current Monitor Started")
print("================================")
print(f"RIMON: {RIMON} ohms")
print(f"GIMON: {GIMON} μA/A")
print("================================\n")
while True:
# Read voltage from IMON pin
vimon = get_voltage(analog_in)
# Calculate output current
iout_A = vimon / (RIMON * GIMON)
iout_mA = iout_A * 1000.0
print(f"ADC: {analog_in.value} | VIMON: {vimon:.3f}V | Current: {iout_mA:.2f} mA")
time.sleep(0.5)
You'll see the raw analog reading, the IMON voltage reading and the current draw from the IMON pin printed out to the serial console. The code uses the formula from the datasheet (page 20, section 7.3.5 "Analog Load Current Monitor Output"):
Iout (A) = (Vimon(V) × 10^-6) / (Rimon(Ω) × Gimon(μA/A))
to calculate the current from the voltage output from the IMON pin as an analog reading.
Page last edited July 15, 2025
Text editor powered by tinymce.