Temperaturelogging

Hi. Totally new to Arduino, and this is my first project. I really tried to find answers by searching. I am pretty sure this problem is not uniquely.
So, i need to log water temp over a period of time, lets say 8-10 hours, preferably more. I want it to give me a chart easy to read on screen.
I have the whole project completed, and it works just fine. Problem is the serial plotter in the software that i don't really like. It doesn't show "start to end".
Do i have to copy all data, and create a chart in excel, or are there other software to Arduino that can plot better?
I am using UNO R3, and software 1.8.19.

I have used the Processing language to write plotting and graphing programs.

With the PLX DAQ program you can send data right to Excel.

1 Like
  • From "start to end", there's 500 data points in the serial plotter, so if you read and print every 72 sec, after 10 hours you'll see the complete plot.

  • If you've already saved all data with readings taken every second, then just plot every 72nd data-point from your saved data.

To get the plot labels to display OK, use a format like this ...

Serial.print(F("Time: "));        Serial.print(timeSec);    Serial.print(F(" sec, "));
Serial.print(F("Water Temp: "));  Serial.print(waterTemp);  Serial.print(F(" °F, "));
Serial.println();

Ok. I use one of these, not all of them?

Seems good. Problem is i use OpenOffice, not Office. Too bad.

Then there is time.
How do i know what time it is on the x-axis? That changes depending on "Delay".
Delay is now set to 1000.

This would be easier to answer if you post your code.

1 Like
#include <DallasTemperature.h>

// Include the libraries we need
#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 13

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);

/*
 * The setup function. We only start the sensors here
 */
void setup(void)
{
  // start serial port
  Serial.begin(9600);
  Serial.println("Dallas Temperature IC Control Library Demo");

  // Start up the library
  sensors.begin();
}
/*
 * Main function, get and show the temperature
 */
 
  // call sensors.requestTemperatures() to issue a global temperature 
  // request to all devices on the bus
  Serial.print("Requesting temperatures...");
  sensors.requestTemperatures(); // Send the command to get temperatures
  Serial.println("DONE");
  // After we got the temperatures, we can print them here.
  // We use the function ByIndex, and as an example get the temperature from the first sensor only.
  float tempC = sensors.getTempCByIndex(0);

  // Check if reading was successful
  if(tempC != DEVICE_DISCONNECTED_C) 
  {
    Serial.print("Temperature for the device 1 (index 0) is: ");
    Serial.println(tempC);
  } 
  else
  {
    Serial.println("Error: Could not read temperature data");
  }
}

Read the forum guidelines to see how to properly post code and some information on how to get the most from this forum.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

You can go back and fix your original post by highlighting the code and clicking the </> in the menu bar.
code tags new

It looks like the example code from here where they use a delay of 1000. If this is what you're using, then if you changed delay to 72000 (ouch!), you would have a complete plot with 500 data points in 10 hours.

Sorry, my bad. I mixed up two codes. This is the one i will use. No Delay this time.

// Include the libraries we need
#include <LiquidCrystal.h>
#include <OneWire.h>
#include <DallasTemperature.h>
  LiquidCrystal lcd(12,11,5,4,3,2);

// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 13

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);

/*
 * The setup function. We only start the sensors here
 */
void setup(void)
{
  analogWrite(6,100);
    lcd.begin(16,2);
  // start serial port
  Serial.begin(9600);
  Serial.println("Dallas Temperature IC Control Library Demo");

  // Start up the library
  sensors.begin();
}

/*
 * Main function, get and show the temperature
 */
void loop(void)
{ 
  // call sensors.requestTemperatures() to issue a global temperature 
  // request to all devices on the bus
  Serial.print("Requesting temperatures...");
  sensors.requestTemperatures(); // Send the command to get temperatures
  Serial.println("DONE");
  // After we got the temperatures, we can print them here.
  // We use the function ByIndex, and as an example get the temperature from the first sensor only.
  Serial.print("Temperature for the device 1 (index 0) is: ");
  Serial.println(sensors.getTempCByIndex(0));  
  lcd.setCursor(1,0);
    lcd.print("Temp :");
    lcd.setCursor(8,0);
    lcd.print(sensors.getTempCByIndex(0));
    lcd.setCursor(14,0);
    lcd.print("C ");
}

Isn't there a maximum read frequency with that sensor?
Quick google suggests its 750mSec
Multiple sensors all have the data line tied together at a pullup resistor .
So alternating is possible.
Srp

Not sure what to answer. I use a DS18B20 sensor, and have a 4,7k resistor signal to 5 volt.
Do you suggest that i use a different sensor?

not in the least.
thought if you add a second, then read each alternatively, still at 750mS, no chance of exceeding the max rate, then it might be easier.

adding a second or many more,all 3 leads, red, yellow, black just wire to 5v, data and ground.
check the datasheet, pretty sure that's covered.
all i could see was a 4k7 pullup to the supply rail.

There are many ways to do this, but most of them require WiFi or Ethernet to send the data somewhere for display. With the Uno, your only way to pass the data is serial, so you need a program on the attached PC to accept it. From the PC though, you could save the data to a database and graph from that, or send it to one of the IoT platforms that will store & graph it for you. Custom code though, probably.

Seems like a lot of work for just one simple task, considering my knowledge level.
(Below level 1 :sweat_smile:)
dlloyd: Whith a delay of about 72000 i get a quite good result, and all fits in one screen. though if i have rapid changes in temp, the chart looks a little strange, and i can not zoom in on that particular time. But it does not have to be perfect.

An improvement might be to take average of 72 readings in 72 seconds ...

float tempC = 0;
for (int i = 0; i < 72; i++) {
  tempC += sensors.getTempCByIndex(0);
  delay(1000);
}
tempC /= 72.0;

Should be smoother, but no zooming in unless all data is stored or data-logged (this is much more complex), or if you just plot everything and let the plot scroll.

Does not work to input that... :thinking:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.