How would I timestamp the output data in Arduino software (using an Uno with 1.8.13 version) so the serial monitor would display for each data value an associated time value in seconds? I know about the milles() function and time in seconds would be this value / 1000, but I'm not sure there's any easy way of timestamping the data just using code. For example, one line of output in the serial monitor could read (temperature time) as "57.6 23" and continue time stamping the data. The code is attached below but only outputs a temperature reading after 500 ms, with no timestamp.
/* VernierTutorialThermistor (v2017) This sketch reads the temperature from a Vernier Stainless Steel Temperature Probe or a Surface Temperature Sensor once every half second. We use the Steinhart-Hart equation (in the function Thermistor) to calculate temperature from the raw voltage reading. Because of the use of log functions in the Steinhart-Hart equation, this sketch requires the math.h library.. / #include
I/include library for log function float rawCount; //create global variable for reading from A/D converter (0-1023) float temperature; //create global variable for temperature in Celsius void setup() { Serial.begin(9600); // setup communication to display } void loop() { rawCount=analogRead(A0); //read one data value (0-1023) temperature=thermistor (rawCount); // calculates temperature - see below Serial.println(temperature, 1); delay(500); //wait half second } //This function calculates temperature from raw count float thermistor(int raw) float resistor=15000; //initialize value of fixed resistor float resistance; //create local variable for resistance float temp; //create local variable for temperature resistance=log (resistor*raw/(1024-raw)); //calculate resistance temp = 1 / (0.00102119 + (0.000222468 * resistance) + (0.000000133342 * resistance * resistance * resistance)); //calculate temperature using the Steinhart-Hart equation temp = temp 273.15; //Convert Kelvin to Celsius return temp; //return the temperature } /* VernierTutorialThermistor (v2017) This sketch reads the temperature from a Vernier Stainless Steel Temperature Probe or a Surface Temperature Sensor once every half second. We use the Steinhart-Hart equation (in the function Thermistor) to calculate temperature from the raw voltage reading. Because of the use of log functions in the Steinhart-Hart equation, this sketch requires the math.h library.. / #include I/include library for log function float rawCount; //create global variable for reading from A/D converter (0-1023) float temperature; //create global variable for temperature in Celsius void setup() { Serial.begin(9600); // setup communication to display } void loop() { rawCount=analogRead(A0); //read one data value (0-1023) temperature=thermistor (rawCount); // calculates temperature - see below Serial.println(temperature, 1); delay(500); //wait half second } //This function calculates temperature from raw count float thermistor(int raw) float resistor=15000; //initialize value of fixed resistor float resistance; //create local variable for resistance float temp; //create local variable for temperature resistance=log (resistor*raw/(1024-raw)); //calculate resistance temp = 1 / (0.00102119 + (0.000222468 * resistance) + (0.000000133342 * resistance * resistance * resistance)); //calculate temperature using the Steinhart-Hart equation temp = temp 273.15; //Convert Kelvin to Celsius return temp; //return the temperature }