Tadeas Dvoracek
Published

Solar Power Meter

This meter measures the voltage, current and power of my 40W solar panel.

IntermediateShowcase (no instructions)3 hours2,131
Solar Power Meter

Things used in this project

Hardware components

ESP8266 ESP-01
Everything ESP ESP8266 ESP-01
×1
INA219 - Current sensor
×1
OLED display
×1
AMS1117 - 3,3V
×1
Capacitor 220 µF
Capacitor 220 µF
×1
Screw terminal connector
×1
DIN Rail Mounted Plastic Box
×1

Software apps and online services

Arduino IDE
Arduino IDE
Cayenne
myDevices Cayenne

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Schematics

Snimek obrazovky (52) cf0p9kjrhb

Code

Code

Arduino
#include <Wire.h>
#include <Adafruit_INA219.h>
Adafruit_INA219 ina219;
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

float shuntvoltage = 0;
float busvoltage = 0;
float current_mA = 0;
float current_A = 0;
float loadvoltage = 0;
float power_W = 0;
       
#define CAYENNE_PRINT Serial  
#include "CayenneDefines.h"
#include "BlynkSimpleEsp8266.h"
#include "CayenneWiFiClient.h"


char token[] = "token";
char ssid[] = "ssid";
char password[] = "password";


void setup()
{
  Serial.begin(9600);
  Cayenne.begin(token, ssid, password);
  
  Wire.begin(2, 0); // SDA, SDL
  uint32_t currentFrequency;
  ina219.begin();
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
}

void loop()
{
  Cayenne.run();
  
  shuntvoltage = ina219.getShuntVoltage_mV();
  busvoltage = ina219.getBusVoltage_V();
  current_mA = ina219.getCurrent_mA();
  loadvoltage = busvoltage + (shuntvoltage / 1000);
  current_A = current_mA / 1000;
  power_W = current_A * loadvoltage; 
  
  display.clearDisplay();
  display.setTextColor(WHITE);
  display.setTextSize(1);
  display.setCursor(0, 0);  
  display.println(loadvoltage);
  display.setCursor(45, 0);
  display.println("V");
  display.setCursor(0, 10);  
  display.println(current_A);    
  display.setCursor(45, 10);
  display.println("A");
  display.setCursor(0, 20);  
  display.println(power_W);    
  display.setCursor(45, 20);
  display.println("W");
  display.display();
  
}


CAYENNE_OUT(V0)
{
  Cayenne.virtualWrite(V0, loadvoltage);
}

CAYENNE_OUT(V1)
{
  Cayenne.virtualWrite(V1, current_A);
}

CAYENNE_OUT(V2)
{
  Cayenne.virtualWrite(V2, power_W);
}

Credits

Tadeas Dvoracek

Tadeas Dvoracek

5 projects • 16 followers
Contact

Comments