-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathirradiance.cpp
More file actions
37 lines (28 loc) · 1010 Bytes
/
irradiance.cpp
File metadata and controls
37 lines (28 loc) · 1010 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "irradiance.h"
#include <Arduino.h>
// Global variables to hold irradiance data
extern float irradiance;
extern float power_watt;
void setupIrradiance() {
// No specific setup needed for irradiance calculation
}
float calculateIrradiance() {
// Read solar panel voltage from analog pin
float voltage_solar_panel = analogRead(A0) * 5.0 / 1023.0; // Read ADC value and convert to voltage
// Calculate power of solar panel
power_watt = voltage_solar_panel * voltage_solar_panel / (R2 / (R1 + R2));
// Convert power to irradiance (Watt/m^2)
irradiance = power_watt / luasPanel;
///Show Data serial monitor
// Serial.print("Solar Panel Voltage: ");
// Serial.print(voltage_solar_panel);
// Serial.println(" V");
// Serial.print("Power (Calculated): ");
// Serial.print(power_watt);
// Serial.println(" W");
// Serial.print("Irradiance: ");
// Serial.print(irradiance);
// Serial.println(" W/m^2");
///EndShow Data serial monitor
return irradiance;
}