// =======================bibliothèques et adresses============== #include #include Adafruit_INA219 ina219_A(0x40); // adresse du module de charge Adafruit_INA219 ina219_B(0x41); // adresse du module de décharge //==================== Variables du module de charge ============================= float current_mA_A = 0; float shuntVoltage_mV_A = 0; float busVoltage_V_A = 0; float loadvoltage_V_A = 0; //==================== Variables du module de décharge =========================== float current_mA_B = 0; float shuntVoltage_mV_B = 0; float busVoltage_V_B = 0; float loadvoltage_V_B = 0; //================================================================================== void setup(void) { Serial.begin(9600); ina219_A.begin(); //---- Initialisation du module de charge (adresse 0x40) ina219_A.setCalibration_16V_400mA(); // --- Calibration minimum ------------ ina219_B.begin(); //---- Initialisation du module de décharge (adresse 0x41) ina219_B.setCalibration_16V_400mA(); // --- Calibration minimum ------------ Serial.println("CLEARDATA"); //Serial.println("LABEL,Date,Voltage A,Voltage B"); } //================================================================================== void loop() { delay(120); // if (Serial.available()>0) // { // octetRecu = Serial.read(); // delay(20); // } // Serial.println (octetRecu); // Serial.println((char)octetRecu); busVoltage_V_A = ina219_A.getBusVoltage_V(); shuntVoltage_mV_A = ina219_A.getShuntVoltage_mV(); current_mA_A = ina219_A.getCurrent_mA(); loadvoltage_V_A = busVoltage_V_A + shuntVoltage_mV_A/1000-0.6;//on soustrait la tension de seuil de la diode; delay(100); busVoltage_V_B = ina219_B.getBusVoltage_V(); shuntVoltage_mV_B = ina219_B.getShuntVoltage_mV(); current_mA_B = ina219_B.getCurrent_mA(); loadvoltage_V_B = busVoltage_V_B + shuntVoltage_mV_B/1000; delay(280); //===========================variables à afficher=========================== //Serial.print("tension de charge condensateur en volts"); //Serial.println(busVoltage_V_A); //Serial.print("courant de charge en mA"); //Serial.println(current_mA_A); //Serial.print("tension de décharge condensateur en volts"); Serial.println(busVoltage_V_B); //Serial.print("courant de décharge en mA"); //Serial.println(current_mA_B); } //==================================================================================