Untitled
unknown
plain_text
a year ago
1.5 kB
22
Indexable
void setup() {
//serial connection setup
//opens serial port, sets data rate to 9600 bps
Serial.begin(9600);
//clear all data that’s been place in already
Serial.println("CLEARDATA");
//define the column headings (PLX-DAQ command)
Serial.println("LABEL,t,voltage,current,power,light_intensity");
}
void loop() {
//measuring voltage using "B25 0 to 25V" Voltage Sensor
//measuring current using "INA169" Current Sensor
//reading of the current and voltage from sensors
float voltage = analogRead(A0) * 5.0 * 5.0 / 1023; //PV panel voltage
float current = analogRead(A1) * 5.0 / 1023; //PV panel current
float power = voltage * current; //PV panel power
//measuring light intensity using TEMT6000 on analog pin A2
int lightIntensityRaw = analogRead(A2); // Read raw value
float lightIntensity = lightIntensityRaw * (5.0 / 1023); // Convert to voltage
//allows the serial port to send data to Excel in real-time
Serial.print("DATA,TIME,"); // PLX-DAQ command
Serial.print(voltage); // send the voltage to serial port
Serial.print(",");
Serial.print(current); // send the current to serial port
Serial.print(",");
Serial.print(power); // send the power to serial port
Serial.print(",");
Serial.println(lightIntensity); // send light intensity to serial port
delay(1000); //wait 1s before repeating
}
Editor is loading...
Leave a Comment