Arduino UNO Solar Panel Efficiency Monitoring System with SD Card Data Logging
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to monitor the efficiency of a solar panel system. It measures voltage, current, light intensity, and temperature, and logs the data to an SD card. The core of the system is an Arduino UNO microcontroller, which interfaces with various sensors and an SD card module.
Component List
Arduino UNO
- Description: Microcontroller board based on the ATmega328P.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
ACS712 Current Sensor 5A 20A 30A
- Description: Sensor to measure current.
- Pins: 1, 2, GND, OUT, VCC
Photocell (LDR)
- Description: Light-dependent resistor to measure light intensity.
- Pins: pin 0, pin 1
Resistor (10k Ohms)
- Description: Resistor with a resistance of 10k Ohms.
- Pins: pin1, pin2
Voltage Sensor
- Description: Sensor to measure voltage.
- Pins: Ground, Phase, Vcc, Out, Gnd
Solar Panel
- Description: Solar panel to generate electricity.
- Pins: +, -
DS18B20 1-Wire Temperature Sensor Probe Cable
- Description: Temperature sensor.
- Pins: shield, GND, DQ, VDD
Resistor (4.7k Ohms)
- Description: Resistor with a resistance of 4.7k Ohms.
- Pins: pin1, pin2
SD Module
- Description: Module to interface with an SD card.
- Pins: CS, SCK, MOSI, MISO, VCC, GND
Wiring Details
Arduino UNO
5V connected to:
- VDD of DS18B20 1-Wire Temperature Sensor Probe Cable
- pin2 of 4.7k Ohms Resistor
- pin 0 of Photocell (LDR)
- VCC of ACS712 Current Sensor
- VCC of SD Module
- Vcc of Voltage Sensor
GND connected to:
- GND of DS18B20 1-Wire Temperature Sensor Probe Cable
- pin2 of 10k Ohms Resistor
- GND of SD Module
- Gnd of Voltage Sensor
- GND of ACS712 Current Sensor
D2 connected to:
- DQ of DS18B20 1-Wire Temperature Sensor Probe Cable
- pin1 of 4.7k Ohms Resistor
A2 connected to:
- pin 1 of Photocell (LDR)
- pin1 of 10k Ohms Resistor
A0 connected to:
- Out of Voltage Sensor
A1 connected to:
- OUT of ACS712 Current Sensor
D13 connected to:
- SCK of SD Module
D12 connected to:
- MISO of SD Module
D11 connected to:
- MOSI of SD Module
D10 connected to:
- CS of SD Module
Voltage Sensor
Ground connected to:
-
- of Solar Panel
-
Phase connected to:
-
- of Solar Panel
-
Code Documentation
#include <SPI.h>
#include <SD.h>
#include <OneWire.h>
#include <DallasTemperature.h>
// Pin Definitions
#define VOLTAGE_PIN A0 // Voltage Sensor output
#define CURRENT_PIN A1 // Current Sensor output
#define LDR_PIN A2 // Light Sensor (LDR)
#define DS18B20_PIN 2 // DS18B20 Data Pin
#define SD_CS 10 // Chip Select Pin for SD card module
// Initialize DS18B20
OneWire oneWire(DS18B20_PIN);
DallasTemperature sensors(&oneWire);
// Sensor Calibration Values
float voltageDividerRatio = 5.0; // Voltage sensor divides input by 5
float analogResolution = 5.0 / 1023.0; // Arduino ADC resolution (5V system)
float currentOffset = 2.5; // ACS712 outputs ~2.5V for 0A
float currentSensitivity = 0.185; // ACS712 sensitivity for 5A version (in V/A)
File dataFile;
void setup() {
Serial.begin(9600);
sensors.begin(); // Initialize DS18B20
Serial.println("Solar Panel Efficiency Monitoring Started");
// Initialize SD card
if (!SD.begin(SD_CS)) {
Serial.println("SD card initialization failed!");
while (1);
}
Serial.println("SD card initialized successfully.");
}
void loop() {
// Measure Voltage
int voltageRaw = analogRead(VOLTAGE_PIN);
float voltage = (voltageRaw * analogResolution) * voltageDividerRatio;
// Measure Current
int currentRaw = analogRead(CURRENT_PIN);
float currentVoltage = currentRaw * analogResolution;
float current = (currentVoltage - currentOffset) / currentSensitivity;
// Calculate Power
float power = voltage * current;
// Measure Light Intensity
int lightIntensity = analogRead(LDR_PIN);
// Measure Temperature (DS18B20)
sensors.requestTemperatures();
float temperature = sensors.getTempCByIndex(0);
// Print data to Serial Monitor
Serial.print("Voltage (V): ");
Serial.print(voltage);
Serial.print("\tCurrent (A): ");
Serial.print(current);
Serial.print("\tPower (W): ");
Serial.print(power);
Serial.print("\tLight Intensity: ");
Serial.print(lightIntensity);
Serial.print("\tTemperature (C): ");
Serial.println(temperature);
// Save data to SD card
dataFile = SD.open("data.csv", FILE_WRITE);
if (dataFile) {
dataFile.print(voltage);
dataFile.print(",");
dataFile.print(current);
dataFile.print(",");
dataFile.print(power);
dataFile.print(",");
dataFile.print(lightIntensity);
dataFile.print(",");
dataFile.println(temperature);
dataFile.close();
Serial.println("Data saved to SD card.");
} else {
Serial.println("Error opening data.csv");
}
// Delay before next reading
delay(5000); // 5 seconds
}
This code initializes the sensors and SD card module, reads data from the sensors, calculates power, and logs the data to the SD card every 5 seconds.