Hello, I have an Arduino board and an analog temperature sensor and I want to connect it to an external power supply unit and let it measure the maximum and the minimum temperature, the only issue is that when I disconnect it from the supply unit the void Setup runs and reset the values.
Here is the code I used:
const int termo = A0;
double Max;
double Min;
double temp;
void setup() {
pinMode(termo,INPUT);
temp = GetTemp(analogRead(termo));
Max = temp;
Min = temp;
Serial.begin(9600);
delay(50);
}
void loop() {
double a = GetTemp( analogRead(termo) );
Clear();
if(a > Max){
Max = a;
}
else{
if(a < Min){
Min = a;
}
}
Serial.print("Current Temperature: ");
Serial.println(a);
Serial.println();
Serial.print("Maximum Temperature: ");
Serial.println(Max);
Serial.print("Minimum Temperature: ");
Serial.println(Min);
delay(500);
}
double GetTemp(int RawADC) {
double Temp;
Temp = log(10000.0*((1024.0/RawADC-1)));
Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
Temp = Temp - 273.15; // Convert Kelvin to Celcius
//Temp = (Temp * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit
return Temp;
}
void Clear(){
for(int i = 0;i<1;i++){
Serial.println();
}
}
It's a great solution for finding the maximum and minimum temperature values like I wanted when it's connected to my computer(and I see that through the serial monitor) but it's useless when I want to connect it to an external power supply and see the values afterwards when I have an access to a computer.
I considered buying an SD module and saving the values there but using an SD card for this purpose it's overkill because most of them can provide about 8 Gb when I need 8 bytes(2 double variables).
So can somebody give me an optimal solution for my problem?