How to compute resistor value from voltage and current in Python using UliEngineering

You can easily compute the resistor value given voltage and current using Ohm’s law with the UliEngineering Python library:

resistor_by_voltage_and_current.py
from UliEngineering.Electronics.Resistors import *
from UliEngineering.EngineerIO import *

# Compute resistor value for 5V at 5mA
resistor = resistor_by_voltage_and_current("5V", "5mA")
print(f"Resistor for 5V at 5mA: {format_value(resistor, 'Ω')}")

# Compute resistor value for 3.3V at 33mA
resistor = resistor_by_voltage_and_current("3.3V", "33mA")
print(f"Resistor for 3.3V at 33mA: {format_value(resistor, 'Ω')}")

Example output

resistor_by_voltage_and_current_output.txt
Resistor for 5V at 5mA: 1.00 kΩ
Resistor for 3.3V at 33mA: 100 Ω

The resistor value is computed using Ohm’s law: $R = \frac{V}{I}$


Check out similar posts by category: Electronics, Python