Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
documentation:microcontroleurs:arduino:modules:ina219_va_meter:index [2025/05/01 14:04] – [PINOUT] f1sls | documentation: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/ |
{{: | {{: | ||
\\ | \\ | ||
Ligne 11: | Ligne 11: | ||
===== I2C ===== | ===== I2C ===== | ||
- | I2C Address | ||
- | |||
The INA219 uses the I2C protocol to communicate with microcontrollers, | The INA219 uses the I2C protocol to communicate with microcontrollers, | ||
Ligne 89: | Ligne 87: | ||
===== WIRING ===== | ===== WIRING ===== | ||
{{: | {{: | ||
+ | {{: | ||
===== Librairie(s) ===== | ===== Librairie(s) ===== | ||
* [[https:// | * [[https:// | ||
Ligne 149: | Ligne 148: | ||
Serial.println("" | Serial.println("" | ||
+ | delay(1000); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | <code cpp> | ||
+ | #include " | ||
+ | #include " | ||
+ | |||
+ | 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(" | ||
+ | while (1) { delay(10); } | ||
+ | } | ||
+ | |||
+ | Serial.print(" | ||
+ | Serial.print(" | ||
+ | Serial.print(" | ||
+ | Serial.print(" | ||
+ | Serial.println(" | ||
+ | } | ||
+ | |||
+ | 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(shuntvoltage); | ||
+ | Serial.print(loadvoltage); | ||
+ | Serial.print(current_mA); | ||
+ | Serial.println(power_mW); | ||
+ | |||
delay(1000); | delay(1000); | ||
} | } | ||
</ | </ |