Mesure de l'intensité d'un panneau solaire avec capteur INA219

Bonjour à tous,
Je vous explique mon problème :
Je voudrais mesurer l'intensité et la tension d'un panneau solaire reçue par l'énergie solaire grâce au capteur INA219. J'ai fait le schéma et le code (voir en bas), mais cela ne marche pas...
Savez vous où est le problème ? Pour afficher les mesures j'utilise un écran LCD.

Merci d'avance

#include <Wire.h>
#include <Adafruit_INA219.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Fonts/FreeSerifItalic12pt7b.h>

Adafruit_INA219 ina219;

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET     4 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
float current_mA = 0;
float loadvoltage = 0;
float power_mW = 0;

void setup(void)
{
  Serial.begin(115200);
  while (!Serial) {
    // will pause Zero, Leonardo, etc until serial console opens
    delay(1);
  }
  uint32_t currentFrequency;

  if (! ina219.begin()) {
    Serial.println("Failed to find INA219 chip");
    while (1) {
      delay(10);
    }
  }

  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
    Serial.println(F("SSD1306 allocation failed"));
    for (;;); // Don't proceed, loop forever
  }
  // Clear the buffer
  display.clearDisplay();
  Serial.println("Measuring voltage and current with INA219 ...");
}

void loop(void)
{
  float shuntvoltage = 0;
  float busvoltage = 0;
  current_mA = 0;
  loadvoltage = 0;
  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("Load Voltage:  "); Serial.print(loadvoltage); Serial.println(" V");
  Serial.print("Current:       "); Serial.print(current_mA); Serial.println(" mA");
  Serial.print("Power:         "); Serial.print(power_mW); Serial.println(" mW");
  Serial.println("");
  display.clearDisplay();
  voltCurrent();
  delay(2000);
  display.clearDisplay();
  powerr();
  delay(2000);
}

void voltCurrent() {
  display.setFont();
  display.setTextSize(2); // Draw 2X-scale text
  display.setTextColor(WHITE);
  display.setCursor(0, 0);            // Start at top-left corner
  display.print(loadvoltage);
  display.print("V");
  display.setCursor(0, 18);
  display.print(current_mA);
  display.print("mA");
  display.display();
}

void powerr() {
  display.setFont(&FreeSerifItalic12pt7b);
  display.setTextSize(1); // Draw 2X-scale text
  display.setTextColor(WHITE);
  display.setCursor(0, 20);            // Start at top-left corner
  display.print(power_mW);
  display.print("mW");
  display.display();
}

Même pas l'honnêteté intellectuelle de dire que vous avez pompé cela sur internet ? :man_shrugging:

1 Like

C'est-à-dire?
Pas d'affichage, pas de mesure, fumée bleue?
Qu'est-ce qui s'affiche dans le moniteur série?

Quel écran, un lien vers le site du fournisseur?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.