Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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.

image text in transcribed

/* 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 }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions

Question

1. What are the peculiarities of viruses ?

Answered: 1 week ago

Question

1. Identify outcomes (e.g., quality, accidents).

Answered: 1 week ago