meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
sensor:ina_moduls [2026/03/28 20:20] – [INA238 Arduino example code] vamsansensor:ina_moduls [2026/03/28 21:26] (current) – [INA260: high-precision digital power monitor] vamsan
Line 368: Line 368:
 </code> </code>
  
-==== INA238: Ultra-precise digital power monitor 16-bit delta-sigma ADC ====+==== INA238: Ultra-precise digital power monitor 16-bit delta-sigma ADC with I²C communication ====
 {{anchor:ina238}} {{anchor:ina238}}
 {{ :sensor:ina238_2.png?140|INA238}} {{ :sensor:ina238_2.png?140|INA238}}
Line 448: Line 448:
   * **I²C Address:** If you have changed the A0/A1 jumpers, pass the address to the begin function: //ina238.begin(0x41)//.   * **I²C Address:** If you have changed the A0/A1 jumpers, pass the address to the begin function: //ina238.begin(0x41)//.
   * **Alert Pin:** You can use the library to set high/low thresholds that trigger the physical Alert pin on the chip for over-current protection.   * **Alert Pin:** You can use the library to set high/low thresholds that trigger the physical Alert pin on the chip for over-current protection.
 +
 +==== INA260: high-precision digital power monitor with I²C communication ====
 +{{anchor:ina260}}
 +{{ :sensor:ina260_2.png?140|INA260}}
 +The INA260 is a high-precision digital power monitor that stands out for its integrated precision shunt resistor. This makes it a //"one-stop"// solution for measuring current, voltage, and power without an external sense resistor. 
 +
 +**Key Specifications**
 +
 +  * **Integrated Shunt:** Features a 2 mΩ resistor with 0.1% tolerance.
 +  * **Current Range:** Can handle up to ±15A continuous current.
 +  * **Bus Voltage:** Senses from 0V to 36V, independent of its own supply voltage.
 +  * **Supply Voltage:** Operates on 2.7V to 5.5V.
 +  * **Accuracy:** Offers a maximum system gain error of 0.15% and a 16-bit ADC for high-resolution data.
 +  * **Interface:** I²C/SMBus compatible with 16 programmable addresses via A0 and A1 pins. 
 +
 +=== INA260 Pin Description ===
 +{{anchor:ina260}}
 +Although the chip features 16 pins, many breakout boards simplify this layout. The original chip pinout includes several high-current pins, which help ensure low resistance and better heat dissipation. 
 +
 +^Pin No.^Name^Type^Description|
 +^1, 2, 3|IN+|Analog Input|Positive Current Path: Connect to the supply for high-side sensing.|
 +^4|A1|Digital Input|Address Pin: Connect to GND, VS, SDA, or SCL to set the I²C address.|
 +^5|A0|Digital Input|Address Pin: Used with A1 to configure 1 of 16 addresses.|
 +^6, 11|GND|Power|Ground: Common ground for analog and digital circuits.|
 +^7|ALERT|Digital Output|Alert Pin: Open-drain output for over-limit or conversion-ready signals.|
 +^8|SDA|Digital I/O|Serial Data: Bidirectional I²C data line.|
 +^9|SCL|Digital I/O|Serial Clock: I²C clock input.|
 +^10|VS|Power|Supply Voltage: 2.7V to 5.5V to power the sensor logic.|
 +^12|VBUS|Analog Input|Bus Voltage Sense: Measures the actual voltage of the line (0V to 36V).|
 +^14, 15, 16|IN–|Analog Input|Negative Current Path: Connect to the load for high-side sensing.|
 +
 +=== INA260 Arduino example code ===
 +This sketch initializes the sensor and prints Voltage, Current, and Power to the Serial Monitor at 115200 baud
 +
 +<code c>
 +#include <Adafruit_INA260.h>
 +
 +// Create the sensor object
 +Adafruit_INA260 ina260 = Adafruit_INA260();
 +
 +void setup() {
 +  Serial.begin(115200);
 +  while (!Serial) delay(10); // Wait for Serial Monitor to open
 +
 +  Serial.println("Adafruit INA260 Test");
 +
 +  // Default I2C address is 0x40
 +  if (!ina260.begin()) {
 +    Serial.println("Couldn't find INA260 chip. Check wiring!");
 +    while (1);
 +  }
 +
 +  Serial.println("Found INA260!");
 +}
 +
 +void loop() {
 +  // Read and print Voltage (mV)
 +  Serial.print("Voltage: ");
 +  Serial.print(ina260.readBusVoltage());
 +  Serial.println(" mV");
 +
 +  // Read and print Current (mA)
 +  Serial.print("Current: ");
 +  Serial.print(ina260.readCurrent());
 +  Serial.println(" mA");
 +
 +  // Read and print Power (mW)
 +  Serial.print("Power:   ");
 +  Serial.print(ina260.readPower());
 +  Serial.println(" mW");
 +
 +  Serial.println("");
 +  delay(1000);
 +}
 +</code>
 +
 +**Pro Tips for INA260**
 +
 +  * **No Calibration Needed:** Unlike the INA219 or INA226, you do not need to call a setShunt function because the resistor is built-in and factory-calibrated.
 +  * **Averaging:** If your readings are "jumpy," you can add //ina260.setAveragingCount(INA260_AVG_16)//; in //setup()// to smooth out the data.
 +  * **High Current:** Since the INA260 handles up to 15A, ensure your wiring (the wires going to IN+ and IN-) is thick enough to handle the load without overheating.
 +
 +==== INA3221: current and bus voltage monitor with 3 channels I²C communication ====
 +{{anchor:ina3221}}
 +{{ :sensor:ina3221_1.png?160|INA3221}}
 +The INA3221 is a high-side current and bus voltage monitor with three independent channels and an I²C-compatible interface. It is essentially a triple-channel version of the popular INA219, allowing you to monitor three separate power rails with a single chip.
 +
 +**Key Specifications**
 +
 +  * **Channels:** 3 independent monitoring channels.
 +  * **Bus Voltage Range:** Senses from 0V to 26V.
 +  * **Supply Voltage:** Operates on a single 2.7V to 5.5V supply.
 +  * **Resolution:** Integrated 13-bit ADC.
 +  * **Current Sensing:** Measures current by detecting the voltage drop across an external shunt resistor (up to ±163.8 mV).
 +  * **Power Consumption:** Low typical supply current of 350 µA.
 +  * **Interface:** I²C/SMBUS with 4 programmable addresses (0x40 to 0x43) via the A0 pin.
 +
 +=== INA3221 Pin Description ===
 +The INA3221 features several specialized alert pins not found on simpler monitors. 
 +{{ :sensor:ina3221_2.png?220|INA3221}}
 +^Pin Name^Type^Description|
 +^IN+ [1, 2, 3]|Analog Input|Positive Shunt Input: Connect to the supply side of the shunt resistor for each channel.|
 +^IN- [1, 2, 3]|Analog Input|Negative Shunt Input: Connect to the load side. Bus voltage is also measured here.|
 +^VS|Power|Supply Voltage: 2.7V to 5.5V.|
 +^GND|Power|Ground: All loads and the supply must share this common ground.|
 +^SCL/SDA|Digital I/O|I²C Interface: Clock and data lines for communication.|
 +^A0|Digital Input|Address Select: Tie to GND, VS, SDA, or SCL to set the I²C address.|
 +^Critical|Digital Output|Critical Alert: Triggers immediately when a programmed current limit is exceeded.|
 +^Warning|Digital Output|Warning Alert: Triggers based on an averaged current value to avoid false alarms.|
 +^PV (Power Valid)|Digital Output|Goes high once all enabled channels reach a predefined voltage (default 10V).|
 +^TC (Timing Control)|Digital Output|Monitors power-supply sequencing at power-up.|
 +
 +**Important Usage Notes**
 +
 +  * **Common Ground:** All monitored loads and the INA3221 must share the same ground reference. 
 +  * **High-Side Sensing:** Intended for high-side sensing (resistor between supply and load), though low-side sensing is possible but less typical for this chip. 
 +  * **Standard Breakout Performance:** Most modules feature 0.1Ω shunts, enabling measurements of up to approximately 1.6A per channel with a resolution of 40µV.
 +
 +=== INA3221 I2C Address Map ===
 +
 +^A0 Pin Connection^Hex Address^Decimal|
 +^GND (Ground)|0x40|64|
 +^VS (VCC)|0x41|65|
 +^SDA|0x42|66|
 +^SCL|0x43|67|
 +
 +**Wiring Reminder**
 +
 +The INA3221 is primarily for high-side sensing. Connect your power source to IN+ and your load to IN- for each channel you wish to monitor.
 +
 +=== INA3221 Arduino example code ===
 +To use the INA3221 with an Arduino, the Adafruit INA3221 Library is highly recommended for its ease of use and support for all three channels. 
 +
 +This sketch initializes the sensor and prints the voltage and current for all three channels to the Serial Monitor at 115200 baud.
 +
 +<code c>
 +#include <Adafruit_INA3221.h>
 +
 +// Initialize sensor (Default address 0x40)
 +Adafruit_INA3221 ina3221;
 +
 +void setup() {
 +  Serial.begin(115200);
 +  while (!Serial) delay(10); // Wait for Serial Monitor
 +
 +  Serial.println("Adafruit INA3221 Test");
 +
 +  if (!ina3221.begin()) {
 +    Serial.println("Failed to find INA3221 chip. Check wiring!");
 +    while (1) delay(10);
 +  }
 +
 +  // Set shunt resistance for all channels (Standard modules use 0.1 or 0.05 Ohms)
 +  // For 0.1 Ohm shunts:
 +  for (uint8_t i = 0; i < 3; i++) {
 +    ina3221.setShuntResistance(i, 0.1); 
 +  }
 +
 +  Serial.println("INA3221 Initialized.");
 +}
 +
 +void loop() {
 +  for (uint8_t i = 0; i < 3; i++) {
 +    float voltage = ina3221.getBusVoltage(i);
 +    float current_mA = ina3221.getCurrentAmps(i) * 1000.0; // Convert to mA
 +
 +    Serial.print("Channel "); Serial.print(i + 1);
 +    Serial.print(": "); Serial.print(voltage, 2); Serial.print(" V, ");
 +    Serial.print(current_mA, 2); Serial.println(" mA");
 +  }
 +  Serial.println("---------------------------------");
 +  delay(2000); // Update every 2 seconds
 +}
 +</code>
 +
 +**Key Functions**
 +
 +  * **setShuntResistance(channel, ohms):** Configures the library with your actual shunt resistor value (default is often 0.1Ω or 0.05Ω).
 +  * **getBusVoltage(channel):** Returns the measured voltage on the specified channel (0, 1, or 2).
 +  * **getCurrentAmps(channel):** Returns the calculated current in Amperes based on the shunt resistance.
 +  * **setAveragingMode(mode):** Can be used to reduce noise by averaging multiple samples (e.g., //INA3221_AVG_16_SAMPLES//).
 +
 +
 +
 +
 ===== I²C topics on lamaPLC ===== ===== I²C topics on lamaPLC =====
 {{topic>i2c}} {{topic>i2c}}