Skip to content

Commit cb3a07b

Browse files
committed
adding ideal diode examples
1 parent 48a837c commit cb3a07b

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed

Ideal_Diode_Examples/Arduino_Ideal_Diode_Monitor/.uno.test.only

Whitespace-only changes.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// SPDX-FileCopyrightText: 2025 Liz Clark for Adafruit Industries
2+
//
3+
// SPDX-License-Identifier: MIT
4+
5+
// LM73100 IMON Current Monitoring
6+
7+
const int IMON_PIN = A0; // IMON connected to analog pin A0
8+
const float RIMON = 1500.0; // RIMON resistor value in ohms (1.5kΩ)
9+
const float GIMON = 2.5; // GIMON typical value in μA/A (from datasheet, typical is 2.5)
10+
const float VREF = 5.0; // Arduino reference voltage (5V for most Arduinos)
11+
const int ADC_RESOLUTION = 1024;
12+
13+
void setup() {
14+
Serial.begin(9600);
15+
pinMode(IMON_PIN, INPUT);
16+
17+
Serial.println("LM73100 Current Monitor Started");
18+
Serial.println("================================");
19+
Serial.print("RIMON: ");
20+
Serial.print(RIMON);
21+
Serial.println(" ohms");
22+
Serial.print("GIMON: ");
23+
Serial.print(GIMON);
24+
Serial.println(" μA/A");
25+
Serial.println("================================\n");
26+
}
27+
28+
void loop() {
29+
int adcValue = analogRead(IMON_PIN);
30+
float vimon = (adcValue * VREF) / ADC_RESOLUTION;
31+
float iout_A = vimon / (RIMON * GIMON);
32+
float iout_mA = iout_A * 1000.0;
33+
34+
Serial.print("ADC Value: ");
35+
Serial.print(adcValue);
36+
Serial.print(" | VIMON: ");
37+
Serial.print(vimon, 3);
38+
Serial.print(" V | Output Current: ");
39+
Serial.print(iout_mA, 2);
40+
Serial.print(" mA (");
41+
Serial.print(iout_A, 3);
42+
Serial.println(" A)");
43+
44+
delay(500); // Read every 500ms
45+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# SPDX-FileCopyrightText: 2025 Liz Clark for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
# LM73100 IMON Current Monitoring
5+
6+
import time
7+
import board
8+
from analogio import AnalogIn
9+
10+
RIMON = 1500.0 # 1.5kΩ
11+
GIMON = 2.5 # μA/A
12+
analog_in = AnalogIn(board.A0)
13+
14+
def get_voltage(pin):
15+
return (pin.value * 3.3) / 65536
16+
17+
print("LM73100 Current Monitor Started")
18+
print("================================")
19+
print(f"RIMON: {RIMON} ohms")
20+
print(f"GIMON: {GIMON} μA/A")
21+
print("================================\n")
22+
23+
while True:
24+
# Read voltage from IMON pin
25+
vimon = get_voltage(analog_in)
26+
27+
# Calculate output current
28+
iout_A = vimon / (RIMON * GIMON)
29+
iout_mA = iout_A * 1000.0
30+
31+
print(f"ADC: {analog_in.value} | VIMON: {vimon:.3f}V | Current: {iout_mA:.2f} mA")
32+
33+
time.sleep(0.5)

0 commit comments

Comments
 (0)