Voltmètre / Ampèremètre INA219/GY-219 []

Outils pour utilisateurs

Outils du site


Voltmètre / Ampèremètre INA219/GY-219

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
documentation:microcontroleurs:arduino:modules:ina219_va_meter:index [2025/05/01 14:03] – [ARDUINO CODE] f1slsdocumentation:microcontroleurs:arduino:modules:ina219_va_meter:index [2025/05/04 14:42] (Version actuelle) f1sls
Ligne 1: Ligne 1:
-====== Voltmètre / Ampèremètre INA219 ======+====== Voltmètre / Ampèremètre INA219/GY-219 ======
 {{:documentation:microcontroleurs:arduino:modules:ina219_va_meter:ina219_01.jpg?300&nolink|}} {{:documentation:microcontroleurs:arduino:modules:ina219_va_meter:ina219_01.jpg?300&nolink|}}
 \\ \\
Ligne 11: Ligne 11:
  
 ===== I2C ===== ===== I2C =====
-I2C Address 
- 
 The INA219 uses the I2C protocol to communicate with microcontrollers, and each device on the I2C bus must have a unique address. The default I2C address for the INA219 is 0x40 (or 1000000 in binary). The INA219 uses the I2C protocol to communicate with microcontrollers, and each device on the I2C bus must have a unique address. The default I2C address for the INA219 is 0x40 (or 1000000 in binary).
  
Ligne 77: Ligne 75:
 ==== Calibration Register (Address = 05h) ==== ==== Calibration Register (Address = 05h) ====
 This register is used to set the calibration value for the current and power calculations. It can be read or written to set the correct calibration value. This register is used to set the calibration value for the current and power calculations. It can be read or written to set the correct calibration value.
-===== WIRING ===== 
  
 ===== PINOUT ===== ===== PINOUT =====
Ligne 88: Ligne 85:
   * **Vin+** this pin connects to the positive terminal of the voltage supply that you want to measure.   * **Vin+** this pin connects to the positive terminal of the voltage supply that you want to measure.
  
 +===== WIRING =====
 +{{:documentation:microcontroleurs:arduino:modules:ina219_va_meter:interfacing-ina219-dc-current-sensor-module-with-arduino.jpg?600|}}
 +{{:documentation:microcontroleurs:arduino:modules:ina219_va_meter:ina219-arduino-nano_steckplatine.png?600|}}
 ===== Librairie(s) ===== ===== Librairie(s) =====
   * [[https://github.com/adafruit/Adafruit_INA219|Adafruit INA219]]   * [[https://github.com/adafruit/Adafruit_INA219|Adafruit INA219]]
Ligne 148: Ligne 148:
   Serial.println("");   Serial.println("");
    
 +  delay(1000);
 +}
 +</code>
 +
 +<code cpp>
 +#include "Wire.h"
 +#include "Adafruit_INA219.h"
 +
 +Adafruit_INA219 ina219;
 +
 +void setup() {
 +  // Open serial communications and wait for port to open:
 +  Serial.begin(9600);
 +  while (!Serial) {
 +    ; // wait for serial port to connect. Needed for native USB port only
 +  }
 +
 +  if (! ina219.begin()) {
 +    Serial.println("Failed to find INA219 chip");
 +    while (1) { delay(10); }
 +  }
 +
 +  Serial.print("BV"); Serial.print("\t"); // Bus Voltage
 +  Serial.print("SV"); Serial.print("\t"); // Shunt Voltage
 +  Serial.print("LV"); Serial.print("\t"); // Load Voltage
 +  Serial.print("C"); Serial.print("\t");  // Current
 +  Serial.println("P");  // Power
 +}
 +
 +void loop() {
 +  float shuntvoltage = 0;
 +  float busvoltage = 0;
 +  float current_mA = 0;
 +  float loadvoltage = 0;
 +  float power_mW = 0;
 +
 +  shuntvoltage = ina219.getShuntVoltage_mV();
 +  busvoltage = ina219.getBusVoltage_V();
 +  current_mA = ina219.getCurrent_mA();
 +  power_mW = ina219.getPower_mW();
 +  loadvoltage = busvoltage + (shuntvoltage / 1000);
 +
 +  Serial.print(busvoltage); Serial.print("\t"); 
 +  Serial.print(shuntvoltage); Serial.print("\t");
 +  Serial.print(loadvoltage); Serial.print("\t");
 +  Serial.print(current_mA); Serial.print("\t");
 +  Serial.println(power_mW);
 +
   delay(1000);   delay(1000);
 } }
 </code> </code>
documentation/microcontroleurs/arduino/modules/ina219_va_meter/index.1746101029.txt.gz · Dernière modification : de f1sls