meta data for this page
Differences
This shows you the differences between two versions of the page.
| sensor:ina219 [2026/02/13 15:19] – created - external edit 127.0.0.1 | sensor:ina219 [2026/02/13 15:58] (current) – [I²C topics on lamaPLC] vamsan | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== LamaPLC: CJMCU-219/ | + | ====== LamaPLC: CJMCU-219/ |
| - | The CJMCU-219 is a breakout board featuring the INA219 IC, a zero-drift, bidirectional current and power monitor with an I2C interface. | + | {{ : |
| + | The **CJMCU-219** is a //breakout board// featuring the **INA219** //IC//, a zero-drift, bidirectional current and power monitor with an [[com: | ||
| - | Core Technical Specifications | + | **Core Technical Specifications** |
| - | Voltage Measurement: | + | * **Voltage Measurement: |
| - | Current Range: Measures up to ±3.2A bidirectionally using its built-in 0.1 ohm shunt resistor. | + | * **Current Range:** Measures |
| - | Supply Voltage: Operates on +3.0V to +5.5V. | + | * **Supply Voltage:** Operates on **+3.0V to +5.5V**. |
| - | Precision: Features a 12-bit ADC with a maximum error accuracy of 1% over -40°C to +85°C. | + | * **Precision:** Features a 12-bit ADC with a maximum error accuracy of 1% over -40°C to +85°C. |
| - | Interface: Uses I2C communication (standard 100kHz or high-speed 400kHz/ | + | * **Interface:** Uses I²C communication (standard 100kHz or high-speed 400kHz/ |
| - | Key Features | + | **Key Features** |
| - | High-Side Sensing: Unlike many sensors, it can measure current on the high side (between the power source and the load), | + | * **High-Side Sensing:** Unlike many sensors, it can measure current on the high side (between the power source and the load), |
| - | Multi-Function Reporting: It calculates and reports bus voltage, shunt voltage drop, current, and total power (W) directly. | + | * **Multi-Function Reporting:** It calculates and reports bus voltage, shunt voltage drop, current, and total power (W) directly. |
| - | Programmability: | + | * **Programmability: |
| - | Daisy-Chaining: | + | * **Daisy-Chaining: |
| - | Safety & Limitations | + | **Safety & Limitations** |
| - | Voltage Limit: The chip may be damaged if bus voltage exceeds its absolute hardware limit of 26V. | + | * **Voltage Limit:** The chip may be damaged if bus voltage exceeds its absolute hardware limit of 26V. |
| - | Inductive Loads: Users should be cautious with large motors, as " | + | * **Inductive Loads:** Users should be cautious with large motors, as //" |
| - | ===== Arduino | + | ====== |
| + | {{ : | ||
| + | **Logic and Power Pins** | ||
| + | |||
| + | These pins connect to your microcontroller (e.g., Arduino or Raspberry Pi) to power the sensor and transmit data. | ||
| + | |||
| + | * **VCC:** Supply voltage for the module (**3.0V to 5.5V**). | ||
| + | * **GND:** Common ground for both power and logic. | ||
| + | * **SCL:** I²C serial clock line. | ||
| + | * **SDA:** I²C serial data line. | ||
| + | |||
| + | **Measurement (Load) Pins** | ||
| + | |||
| + | These pins are placed in series with the positive side (high-side) of the circuit you want to monitor. | ||
| + | |||
| + | * **Vin+:** Connect to the positive terminal of your power source (e.g., battery). | ||
| + | * **Vin-:** Connect to the positive terminal of your load (the device being powered). | ||
| + | |||
| + | **I²C addressing Pins (A0 & A1)** | ||
| + | |||
| + | Some versions of the CJMCU-219 include solder pads labeled **A0** and **A1**. By default, these are connected to GND, setting the I2C address to **0x40**. | ||
| + | |||
| + | Bridging these pads to VCC allows you to set the address to any of 16 values (**0x4F**), enabling multiple sensors on the same I²C bus. | ||
| + | |||
| + | <color red> | ||
| ==== Arduino wiring ==== | ==== Arduino wiring ==== | ||
| - | * SCL: A5 | + | * VCC → Arduino 5V (o 3.3V). |
| - | * GND: GND | + | * GND → Arduino |
| - | * SDA: A4 | + | * SCL → Arduino SCL (A5 on Uno/ |
| - | * Vdd: 5V | + | * SDA → Arduino |
| + | * Vin+ → Positive side of your power supply. | ||
| + | * Vin- → Positive side of your load (the device being powered). | ||
| ==== Arduino code ==== | ==== Arduino code ==== | ||
| + | To begin using the CJMCU-219 with Arduino, the easiest approach is to use the **Adafruit INA219** library. | ||
| + | This example code sets up the sensor and outputs voltage, current, and power readings to the Serial Monitor at **115200 baud**. | ||
| + | |||
| + | A simple example with the Adafruit_INA219 library involves initializing the sensor and repeatedly reading and displaying bus voltage, shunt voltage, load voltage, current, and power. The complete code is available in the provided source document. | ||
| <code c> | <code c> | ||
| - | sample | + | #include < |
| + | #include < | ||
| + | |||
| + | Adafruit_INA219 ina219; | ||
| + | |||
| + | void setup(void) { | ||
| + | Serial.begin(115200); | ||
| + | while (!Serial) { delay(1); } // Wait for serial port to connect | ||
| + | |||
| + | // Initialize the INA219 (default address 0x40) | ||
| + | if (!ina219.begin()) { | ||
| + | Serial.println(" | ||
| + | while (1) { delay(10); } | ||
| + | } | ||
| + | |||
| + | // Optional: Set calibration for higher precision | ||
| + | // Default is 32V, 2A. Alternatives: | ||
| + | // ina219.setCalibration_32V_1A(); | ||
| + | // ina219.setCalibration_16V_400mA(); | ||
| + | |||
| + | Serial.println(" | ||
| + | } | ||
| + | |||
| + | void loop(void) { | ||
| + | float shuntvoltage = 0; | ||
| + | float busvoltage = 0; | ||
| + | float current_mA = 0; | ||
| + | float loadvoltage = 0; | ||
| + | float power_mW = 0; | ||
| + | |||
| + | // Read data from sensor | ||
| + | shuntvoltage = ina219.getShuntVoltage_mV(); | ||
| + | busvoltage = ina219.getBusVoltage_V(); | ||
| + | current_mA = ina219.getCurrent_mA(); | ||
| + | power_mW = ina219.getPower_mW(); | ||
| + | loadvoltage = busvoltage + (shuntvoltage / 1000); | ||
| + | |||
| + | // Print results | ||
| + | Serial.print(" | ||
| + | Serial.print(" | ||
| + | Serial.print(" | ||
| + | Serial.print(" | ||
| + | Serial.print(" | ||
| + | Serial.println("" | ||
| + | |||
| + | delay(2000); | ||
| + | } | ||
| </ | </ | ||
| + | **Key Functions Explained** | ||
| + | |||
| + | * // | ||
| + | * // | ||
| + | * // | ||
| + | * // | ||
| + | * // | ||
| + | |||
| + | **Calibration for Accuracy** | ||
| + | |||
| + | The library includes built-in calibration modes to improve precision for specific ranges: | ||
| + | |||
| + | * **Default: | ||
| + | * **setCalibration_32V_1A(): | ||
| + | * **setCalibration_16V_400mA(): | ||
| - | ==== Example codes ==== | ||
| - | none | ||
| ===== I²C topics on lamaPLC ===== | ===== I²C topics on lamaPLC ===== | ||
| {{topic> | {{topic> | ||
| Line 42: | Line 133: | ||
| \\ | \\ | ||
| - | {{tag>ENS160 ScioSense gas-quality | + | {{tag>CJMCU-219 INA-219 INA219 breakout_board |
| This page has been accessed for: Today: {{counter|today}}, | This page has been accessed for: Today: {{counter|today}}, | ||