Thermistor 10k project

Hello, I have to create a code that can store temperature data every minute for 24 hours for my final project.

I have to use the cmd program to store the data in a text file and for some reason when I have the millis() interval for 1 minute it doesn't work.

Hard to see why.

Pleas post your code as text, use the </> button in the window where you type your reply, or use "copy for forum" in the IDE and paste it here so it looks like

Void loop() {
      // code &c.
{

Thanks.

Does it work for other values of the delay?

a7

#include <Thermistor.h>

#define RT0 10000
#define B 3977
#define VCC 5
#define R 10000
float a=A0;
float RT, VR, ln, Tx, TO, VRT;
unsigned long tempInterval = 60000;
unsigned long previousTime = 0;




void setup() {
  Serial.begin(9600);
  pinMode(A0,INPUT);
  TO = 25 + 273.15;
 }

void loop() {
  VRT = analogRead(A0);
  VRT = (5.00 / 1023.00) * VRT;
  VR = VCC - VRT;
  RT = VRT / (VR / R) ;

  ln = log(RT / RT0);
  Tx = (1 / ((ln / B) + (1 / TO)));
  Tx = Tx - 273.15;
  
  unsigned long currentTime = millis();
  if( currentTime - previousTime >= tempInterval){
  Serial.print(currentTime);
  Serial.print("  , ");
  Serial.print("Temperature:");
  Serial.print("\t");
  Serial.println(Tx);

  

 previousTime = currentTime;


}
}

Here's the code. if I change the 60000 to 1000 it works perfectly fine. Just don't understand why it doesn't work at 60000.

Try using 600000UL.

BTW see why I asked for the code? :expressionless:

a7

Isn't 1 minute 60000UL? If it is I've tried it and it still doesn't work

OK so your claim is

unsigned long tempInterval = 1000;

prints once a second and
unsigned long tempInterval = 60000UL;

does not print once per minute?

Do you have the UL on the 60000?

So what does happen? How often does it print?

a7

Using 60000UL does print once per minute on the Serial monitor of arduino but I have to use the cmd program to store the data onto a text file. However, when I use the cmd program, it only works for 1000 and not 60000UL.

hope that makes better sense.

Yes. It means you be wasting time.

Post the code that actually exhibits the problem.

Or what you mean about “cmd program”.

Describe what happens that shouldn’t, or doesn’t that should.

You have a problem in code we have not been shown.

a7

cmd is the command prompt in windows.

What I have to do is after clicking upload on the arduino app, I turn on cmd and type in "copy COM7 test.txt"

And after that the program is supposed to gather the data and store it in a text file as shown with the picture

But as I said it only works for 1000 milliseconds and not for 60000 milliseconds and I'm just trying to see if anyone knows why

So…

if you start the program (with the 60000UL constant), let it print every minute for a few minutes, then do this cmd thing…

does it suddenly stop working?

If your intent is to simply capture the serial output of the Arduino, you could try using a terminal program.

I use Coolterm available free for various platforms. There are others.

a7

Yes as soon as I try and use the cmd program it stops showing the temperature data.

I wish I could use some other program but this is for my finals project so I have no other choice but to use the cmd program unfortunately.

OK, so your problem is not with the Arduino or your sketch. So I am no help.

But it seems like messing with the com port on the PC side as you are doing makes something go wrong.

The only thing I can suggest is to place the output you wish to hoover up collect on another serial port, independent of the one used to uplaod code and talk to the serial monitor in the IDE.

Some Arduinos have extra hardware serial ports. If you have a hardware serial port then try it.

If you Arduino has no additional hardware support for serial communication (UARTs) you could try the Arduino SoftwareSerial library.

a7

I'll give that a try.

Thank you for your help!

Just to clarify, EXACTLY what hardware are you using (eg UNO, MEGA, ESP32 etc etc.)