ok i have added a notificaton on the serial output to give an overheat or cold alarm if the thermal protection kicks in
int voltPin = A0; // voltage divider (middle terminal) connected to analog pin 0
int tempPin = A2; // TMP36 data pin
int val = 0; // variable to store the value read
int volt = 0; // variable to store the voltage calculated
int analogInPin = A1; // Analog input pin that the carrier board OUT is connected to
int sensorValue = 0; // value read from the carrier board
int outputValue = 0; // output in milliamps
int LDR_Pin = A4; //analog pin 0
int hightemp = 13; // choose the pin for the LED
int lowtemp = 12; // choose the pin for the LED
float amps = 0.0;
unsigned long msec = 0;
float time = 0.0;
int sample = 0;
void setup()
{
Serial.begin(9600); // setup serial
pinMode(hightemp, OUTPUT); // declare LED as output
pinMode(lowtemp, OUTPUT); // declare LED as output
}
void loop()
{
// Voltage Calculation
val = analogRead(voltPin); // read the input pin
volt = map(val, 0, 1023, 0, 29); // map 29v range
delay(50);
// temp calculaton
int reading = analogRead(tempPin); // read the input pin
float voltage = reading * 5.0;
voltage /= 1024.0;
//current monitor
// read the analog in value:
sensorValue = analogRead(analogInPin);
// convert to milli amps
outputValue = (((long)sensorValue * 5000 / 1024) - 500 ) * 1000 / 133;
amps = (float) outputValue / 1000;
float watts = amps * voltage;
//light dependsnt resistor
int LDRReading = analogRead (LDR_Pin)/10 ;
//uptime
msec = millis();
time = (float) msec / 1000.0;
//Fan control
{
float temperatureC = (voltage - 0.5) * 100;
if (temperatureC < 40) {
digitalWrite(hightemp, LOW); // turn LED OFF
} else {
digitalWrite(hightemp, HIGH); // turn LED ON
Serial.println("OVERHEAT");
}
if (temperatureC > 10) {
digitalWrite(lowtemp, LOW); // turn LED OFF
} else {
digitalWrite(lowtemp, HIGH); // turn LED ON
Serial.println("COLD");
}
// serial output
}
Serial.print(voltage);
Serial.print(" volts");
Serial.print("\t Current (amps) = ");
Serial.print(amps);
Serial.print("\t Power (Watts) = ");
Serial.print(watts);
float temperatureC = (voltage - 0.5) * 100;
Serial.print("\t degrees C = ");
Serial.print(temperatureC);
Serial.print("\t Solar output % = ");
Serial.print(LDRReading);
Serial.print("\t Time (hours) = ");
Serial.println(time/3600);
delay(500);
}
i think i figured out how to get the light sensor to show a calibrated percentage.
int voltPin = A0; // voltage divider (middle terminal) connected to analog pin 0
int tempPin = A2; // TMP36 data pin
int val = 0; // variable to store the value read
int volt = 0; // variable to store the voltage calculated
int analogInPin = A1; // Analog input pin that the carrier board OUT is connected to
int sensorValue = 0; // value read from the carrier board
int outputValue = 0; // output in milliamps
int hightemp = 13; // choose the pin for the LED
int lowtemp = 12; // choose the pin for the LED
float amps = 0.0;
unsigned long msec = 0;
float time = 0.0;
int sample = 0;
const int pinLDR = A5; // Analog Pin A0 connects across LDR
float valueVolt; // We'll need these float variables for calculations
float valueBrightness;
const int pinLED = A1; // Analog Pin A1 connects across LED
void setup()
{
Serial.begin(9600); // setup serial
pinMode(hightemp, OUTPUT); // declare LED as output
pinMode(lowtemp, OUTPUT); // declare LED as output
}
void loop()
{
// Voltage Calculation
val = analogRead(voltPin); // read the input pin
volt = map(val, 0, 1023, 0, 29); // map 29v range
delay(50);
// temp calculaton
int reading = analogRead(tempPin); // read the input pin
float voltage = reading * 5.0;
voltage /= 1024.0;
//current monitor
// read the analog in value:
sensorValue = analogRead(analogInPin);
// convert to milli amps
outputValue = (((long)sensorValue * 5000 / 1024) - 500 ) * 1000 / 133;
amps = (float) outputValue / 1000;
float watts = amps * voltage;
//light dependsnt resistor
valueVolt = analogRead(pinLED)*5.0/1024; // Store the calculated voltage in a float var
valueBrightness = map(analogRead(pinLDR),990,645,0,100);
//uptime
msec = millis();
time = (float) msec / 1000.0;
//Fan control
{
float temperatureC = (voltage - 0.5) * 100;
if (temperatureC < 40) {
digitalWrite(hightemp, LOW); // turn LED OFF
} else {
digitalWrite(hightemp, HIGH); // turn LED ON
Serial.println("OVERHEAT");
}
if (temperatureC > 10) {
digitalWrite(lowtemp, LOW); // turn LED OFF
} else {
digitalWrite(lowtemp, HIGH); // turn LED ON
Serial.println("COLD");
}
// serial output
}
Serial.print(voltage);
Serial.print(" volts");
Serial.print("\t Current (amps) = ");
Serial.print(amps);
Serial.print("\t Power (Watts) = ");
Serial.print(watts);
float temperatureC = (voltage - 0.5) * 100;
Serial.print("\t degrees C = ");
Serial.print(temperatureC);
Serial.print("\t Solar output % = ");
Serial.print(valueBrightness);
Serial.print("\t Time (hours) = ");
Serial.println(time/3600);
delay(500);
}