Two data sampling rates in same output

Hi,

I have a thermistor attached via voltage divider to my arduino. I need it to measure the temperature of a system 24/7. I want to be able to monitor temperature at a 1 sec resolution via the serial monitor (through remote desktop) but record data only at a 10 minute resolution (through PuTTY). How can I do this through the same COM port?

This is my code for the 1 sec resolution (adapted from different guides online):

#define THERMISTORPIN2 A2
#define THERMISTORNOMINAL 22000  
#define TEMPERATURENOMINAL 25 
#define NUMSAMPLES 10
#define BCOEFFICIENT 3500
#define SERIESRESISTOR 22600 

uint16_t samples[NUMSAMPLES];
 
void setup(void) {
  Serial.begin(9600);
  analogReference(EXTERNAL);
}

void loop(void) {
  uint8_t i;
  float average;
 
     for (i=0; i< NUMSAMPLES; i++) {          // take N samples in a row, with a slight delay
   samples[i] = analogRead(THERMISTORPIN2);
   delay(100);
  }
 
  average = 0;                               // average all the samples out
  for (i=0; i< NUMSAMPLES; i++) {
     average += samples[i];
  }
  average /= NUMSAMPLES;
 
  average = 1023 / average - 1;           // convert the value to resistance
  average = SERIESRESISTOR / average;
 
  float steinhart;
  steinhart = average / THERMISTORNOMINAL;     // (R/Ro)
  steinhart = log(steinhart);                  // ln(R/Ro)
  steinhart /= BCOEFFICIENT;                   // 1/B * ln(R/Ro)
  steinhart += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To)
  steinhart = 1.0 / steinhart;                 // Invert
  steinhart -= 273.15;                         // convert to C

  Serial.print("R1 ");
  Serial.print(", ");
  Serial.print(steinhart);
  Serial.print(", ");
  Serial.println("*C");
 
}

faaizenam:
How can I do this through the same COM port?

I don’t think you can - and this is a PC limitation, not an Arduino limitation. Only one PC program can access a COM port at any one time.

Why not just use PuTTY and not bother with the Serial Monitor?

…R

Thanks Robin.

Because my application is remote temperature monitoring: I will establish a remote desktop connection to continuously monitor temperature (every second) while away from the site but also don't want to save all that data. Ideally, I would only save the temperature every 10 minutes.

Is it possible with PuTTY to sample the serial connection every ten minutes instead of logging all the seconds?

Oh - you're also saying that I cannot have both PuTTY and the Serial Monitor running at the same time?

Faaiz

faaizenam: I will establish a remote desktop connection to continuously monitor temperature (every second) while away from the site but also don't want to save all that data. Ideally, I would only save the temperature every 10 minutes.

I think you will need to write your own PC program to do that.

...R

I see, thanks. So I should have the Arduino output every second and have it displayed it on PuTTY's monitor. When my experiment is done, I should have a script that pulls every nth recording into a new file. Does that sound right?

Faaiz

Another option is to put the 10 minute data on SD and read it later.

Hi, Have you looked at"Processing" IDE?

It allows you to write your own GUI and has applications related to Arduino.

As all you want to do is monitor and log, the "Processing" on the PC can do all that for you, the Arduino just sends the 1second interval data burst.

https://processing.org/

Tom... :)