Jeffrey
Published © GPL3+

Measuring Solar Radiation with Arduino

Want to measure solar radiation but cant afford a Pyranometers? Well, make your own device with your Arduino board using this guide.

IntermediateFull instructions provided1 hour22,411
Measuring Solar Radiation with Arduino

Things used in this project

Hardware components

Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
Arduino Ethernet Shield 2
Arduino Ethernet Shield 2
×1
solar cell
×1
Resistor 10k ohm
Resistor 10k ohm
×1

Hand tools and fabrication machines

Digital Multimeter

Story

Read more

Schematics

Schematic

Schematic of solar panel, resistor and connections

Code

sample code for Pyranometer

Arduino
#define ANALOG_PIN A0 // Analog pin
#define RESISTANCE 10 // Resistance in thousands of ohms
#define PANEL_LENGTH 60 // Length of solar cell in mm
#define PANEL_WIDTH 20 // Width of solar cell in mm

volatile float Area;
volatile float Power;
volatile float Radiation;

/*
* Main Setup function
*/
void setup() {
// Begin serial communication
Serial.begin(9600);
while(!Serial);

delay(100);
}


/*
* Main Setup function
*/
void loop() {

Area = PANEL_LENGTH * PANEL_WIDTH / (100*100); // we are dividing by 10000 get the area in square meters

Power = pow(analogRead( ANALOG_PIN ), 2) / RESISTANCE ; // Calculating power

Radiation = Power / Area;

char *msg;

sprintf(msg, " The Solar Radiation is %f W/M2 ", Radiation); // Generating message to be printed

Serial.println(msg);

delay(1000);
}
No preview (download only).

Ethernet function code

Arduino
#include <SPI.h>
#include <Ethernet.h>

#define ANALOG_PIN A0 // Analog pin
#define RESISTANCE 10 // Resistance in thousands of ohms
#define PANEL_LENGTH 60 // Length of solar cell in mm
#define PANEL_WIDTH 20 // Width of solar cell in mm

volatile float Area;
volatile float Power;
volatile float Radiation;


// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
0xDE, 0x0D, 0x8E, 0xEF, 0xFE, 0xED
};
IPAddress ip(192, 168, 1, 177);

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);

void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}


// start the Ethernet connection and the server:
Ethernet.begin(mac, ip);
server.begin();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
}


void loop() {

Area = PANEL_LENGTH * PANEL_WIDTH / (100*100); // we are dividing by 10000 get the area in square meters
Power = pow(analogRead( ANALOG_PIN ), 2) / RESISTANCE ; // Calculating power
Radiation = Power / Area;
char *msg;
sprintf(msg, " The Solar Radiation is %f W/M2 ", Radiation); // Generating message to be printed


// listen for incoming clients
EthernetClient client = server.available();
if (client) {
Serial.println("new client");
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
Serial.write(c);
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close"); // the connection will be closed after completion of the response
client.println("Refresh: 5"); // refresh the page automatically every 5 sec
client.println();
client.println("<!DOCTYPE HTML>");
client.println("<html>");

/*
* Send message to client
*/
client.print(msg);
client.println("<br />");

client.println("</html>");
break;
}
if (c == '\n') {
// you're starting a new line
currentLineIsBlank = true;
} else if (c != '\r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
Serial.println("client disconnected");
}
}
No preview (download only).

Credits

Jeffrey

Jeffrey

1 project • 9 followers
CEO, Chinavasion Wholesale Ltd., tech and cool gadgets enthusiast, creator of the Chinese e-commerce shop www.chinavasion.com

Comments