Temperature Data Logger

I’m tryiny to help my daughter complete a science project and to do so I need to make a temperature data loogger to measure temperature variations. I have a Freetronics Eleven board and a DS18B20 temperature sensor also by Freetronics. My idea is to measure the temperature and send it to a computer via a usb cable where it will be recorded and possibly sent to Open Office as a file, it would be nice if if I could do it both as time stamped numerical data and as a graph. have tried the software supplied by Freetronics but all I get is 0.00 degree temperrature readings. Can anyone suggest where I could get the software to do this? I

Hacktronics one-wire tutorial. You can send the data direct excel with the plx-daq macro and get live graphs. Timestamp is done within Excel using PC clock.

copjohn wrote:

ut all I get is 0.00 degree temperrature readings

where, at what point do you get this.

I know and use Freetronics boards a lot, but you need to help out a bit more and either provide links to the software or better still, just present it here exactly as you have so we can see what you are doing.
Also, a connection table showing how you connect the temp sensor to the Arduino board.


Paul

I have downloaded the sketch suggested in the first reply with the appropriate attachments. the DS18B20 is wired as per the Freetronics website with the data pin connected to pin 3 of the Eleven board. The blue LED on the sensor flashes as well as the yellow LED on the Eleven. I have opened the serial monitor and from which I recieve a temperature reading of 32 degrees fahrenheit despite every attempt to heat or cool the sensor. I am at this stage only using one sensor and have only changed the names of the sensors in the sketch. Below is the sketch. I hope this provides suffcient information for you.

#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 3

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

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

// Assign the addresses of your 1-Wire temp sensors.
// See the tutorial on how to obtain these addresses:
// http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html

DeviceAddress CavityThermometer = { 0x28, 0x94, 0xE2, 0xDF, 0x02, 0x00, 0x00, 0xFE };
DeviceAddress WarmThermometer = { 0x28, 0x6B, 0xDF, 0xDF, 0x02, 0x00, 0x00, 0xC0 };
DeviceAddress CoolThermometer = { 0x28, 0x59, 0xBE, 0xDF, 0x02, 0x00, 0x00, 0x9F };

void setup(void)
{
// start serial port
Serial.begin(9600);
// Start up the library
sensors.begin();
// set the resolution to 10 bit (good enough?)
sensors.setResolution(CavityThermometer, 10);
sensors.setResolution(WarmThermometer, 10);
sensors.setResolution(CoolThermometer, 10);
}

void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00) {
Serial.print(“Error getting temperature”);
} else {
Serial.print("C: “);
Serial.print(tempC);
Serial.print(” F: ");
Serial.print(DallasTemperature::toFahrenheit(tempC));
}
}

void loop(void)
{
delay(2000);
Serial.print(“Getting temperatures…\n\r”);
sensors.requestTemperatures();

Serial.print(“Cavity temperature is: “);
printTemperature(CavityThermometer);
Serial.print(”\n\r”);
Serial.print(“Warm temperature is: “);
printTemperature(WarmThermometer);
Serial.print(”\n\r”);
Serial.print(“Cool temperature is: “);
printTemperature(CoolThermometer);
Serial.print(”\n\r\n\r”);
}

Can you please supply links to the site where you are getting your information from.
You say you purchased a DS18B20 from Freetronics, but I do not see anywhere on their site such a device.

Also, what blue LED, I didn't think the DS18B20 has any LED, unless it is a DS18B20 module of some sort.
I do know the DHT22 temperature and humidity sensor has a blue LED, maybe you have this sensor instead, which really would be a more fun sensor to play with, since you will have both temperature and relative humidity.

From what you write, it appears to me you only have one sensor, is this correct ?
If so, then why do you have code that is seemingly wanting to work with three sensors?

Also, please place your code in the code tags provided when you make a post. You can go back and edit your last post to wrap the code tags around the code. This an important thing to do, one it becomes more easily readable and two, without code tags, any use of punctuation such as ; ) and others become horrid smiley faces.

Lastly, if you are using a DS18B20, can you confirm you have followed the procedure to obtain the unique device address, rather than what might be in some sample code?

So, code tags and links, as valid url please.

Edit: found the DS1820 temperature module. (providing links for us helps save time)
For others, it is this device DS18B20 module

And this is I am guessing, your reference guide to construction, yes ? Freetronics DS18B20 guide

The code in this guide does not match your code, not even the same code, so I am now guessing it is another guide. Again, one that I can not find, and am wasting time searching.

I have downloaded the sketch suggested in the first reply with the appropriate attachments

'suggestions' often lead to 'assumptions', something have trouble with. I have a need for conciseness.


Paul

The code you have is more or less what I would expect to see and compiles fine. The comment on the LEDs seems irrelevant, as the they don’t feature in the code and I assume they are just the traffic lights on the Eleven, and it doesn’t matter where the sensors come from. What does matter is that you are getting a dodgy reading, it’s not even a standard error message.

It could be in the calcs, which should be redundant anyway.

See if this helps. It isn’t very different but delivers tC only.

/* Basic 2xDS18B20 code for serial monitor, bluetooth, Excel or w.h.y.
Derived from Hacktronics. Use their address sniffer and substitute your 
numbers. Use Hacktronics connections diagram. \
Resolution is 12bit by default, prints to two decimal places
Stay away from using parasite power
 85 means you haven't gotten a read yet, probably wrong order of commands
-127C means bad connection
*/

#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 3

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

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

// Assign the addresses of your 1-Wire temp sensors.  
byte Thermo1[8] =  {0x28, 0x39, 0xFD, 0x50, 0x04, 0x00, 0x00, 0X69};
byte Thermo2[8] = {0x28, 0x09, 0xA9, 0xC0, 0x03, 0x00, 0x00, 0x95};

float Temp,Temp1,Temp2;  

void setup(){
  Serial.begin(9600);
  sensors.begin();
  delay(750);//Wait for newly restarted system to stabilize
}

void loop() {
 sensors.requestTemperatures();  // call readings from the addresses
  Temp1 = sensorValue(Thermo1);
  Temp2 = sensorValue(Thermo2);  

Serial.print(" Thermo1 = ");
Serial.print(Temp1);
Serial.print("     Thermo2 = "); 
Serial.println(Temp2);

delay(1000);
}

//sensorValue function
float sensorValue (byte deviceAddress[])
{
     Temp = sensors.getTempC (deviceAddress);
}

I assume you got the addresses and this suggests the sensors are fine, and you know what to do with them.

Hi Rockwallaby I apologise for my lack of knowledge on this forum as this is the first time I have resorted to a forum.
To give some background on what I am trying to achieve and how I have gone about it. My daughter is entering a science fair and her project is to test the thermal properties of insulation, in order to do this she is going to build a chamber which will be divided by wall cavity. one cavity will be kept at constant 20 degrees celcius the warm chamber, the other wil be unheated the cool chamber and temperature measurements will be taken inside both the wall cavity and the cool chamber to see if there is any rise in temperature within these areas over a 24 hr period and to record these measurements.
The module is as you have assumed is a DS18B20 module from Freetronics and the sketch I used was from the same site which only provided a 0.00 degrees reading.
The code you have seen was provided by Nick_Pyner in his reply. Following his advice I visted Hacktronics to upload their code I have also downloaded other sketches Ardunio DS18B20 temperature sensor and Dallas one wire temperature from their site.
I belive I followed Nick Pyners directions closely and uploaded the programs his has suggested. I have got to the point of finding an address for the sensor through a sketch provided by Hacktronics which is not uploading due to a reoccuring error message

// This sketch looks for 1-wire devices and
// prints their addresses (serial number) to
// the UART, in a format that is useful in Arduino sketches
// Tutorial: 
// http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html

#include <OneWire.h>

OneWire  ds(3);  // Connect your 1-wire device to pin 3

void setup(void) {
  Serial.begin(9600);
  discoverOneWireDevices();
}

void discoverOneWireDevices(void) {
  byte i;
  byte present = 0;
  byte data[12];
  byte addr[8];
  
  Serial.print("Looking for 1-Wire devices...\n\r");
  while(ds.search(addr)) {
    Serial.print("\n\rFound \'1-Wire\' device with address:\n\r");
    for( i = 0; i < 8; i++) {
      Serial.print("0x");
      if (addr[i] < 16) {
        Serial.print('0');
      }
      Serial.print(addr[i], HEX);
      if (i < 7) {
        Serial.print(", ");
      }
    }
    if ( OneWire::crc8( addr, 7) != addr[7]) {
        Serial.print("CRC is not valid!\n");
        return;
    }
  }
  Serial.print("\n\r\n\rThat's it.\r\n");
  ds.reset_search();
  return;
}

void loop(void) {
  // nothing to see here
}

This is the error message I get from this sketch
Arduino: 1.6.5 (Windows XP), Board: “Arduino Uno”

Build options changed, rebuilding all

collect2.exe: error: ld returned 5 exit status
Error compiling.

This report would have more information with
“Show verbose output during compilation”
enabled in File > Preferences.
I don’t know how much of this error message you want as it is quite extensive

Would I make my life easier and possibly yours if I gave the DS18B20 modules a miss and just daisychain together some LM35 sensors or carry on the way I’m going

copjohn wrote:

I apologise for my lack of knowledge

There is never a need to apologise for lack of knowledge, we are all learners to varying degrees.

First, stay with the DS18B20, I don't use them personally, but I think they will be your best bet, in terms of getting the solution faster. They are digital, and calibrated and once working for you will be more than suitable for your daughter's project.

I have got to the point of finding an address for the sensor through a sketch provided by Hacktronics which is not uploading due to a reoccuring error message

I guess I'm somewhat confused by how you obtained the individual addresses if you were not able to compile or upload the program to discover addresses.

Once you know the individual device addresses, then put that into the program as suggested by Nick and you should be reading temperatures.

The error you describe, with collect2.exe, I have no idea of, sorry.
It is an application that operates on microsoft windows, which I don't use.

As is mentioned in the code Nick_Pyner gives, 'Stay away from using parasite power', how are you powering theses devices ?

So, to confirm, do you know the exact unique addresses for each DS18B20 ?
If yes, then list them here.

Until you have these addresses, the code will not talk to your devices.


Paul

Over in another part of the forum I found this, by Rob Tillaart, a 1-Wire scanner for e.g. DS18B20
It may help you.


Paul

copjohn:
Error compiling.

No need to be any more verbose than that.

The address sniffer you post seems exactly the same as the one I use. If it won't compile, I suspect there is something wrong with the installation of the IDE.

I note that you are using XP. FWIW I despaired of ever getting v1.6.5 to work, and upgraded to v1.5.6-r2. I have wondered if XP was the problem but I have never heard of anybody else having this grief. This may only be because there aren't many of us XP users left.

Hi to Paul and Mark After some effort I have finally found the address for the sensor got the sensor to talk to the Eleven and finally got a reading that meant something. The sketch I am using is providing two temp readings which is perfect for what I need. Thank you for all your help and guidance it was very much appreciated

John

We are stuck with technology when what we really want is just stuff that works Douglas Adams

Glad to hear you have success.
Appreciate your feedback in letting us know, and ask any time if you need more or want to expand the project.


Paul

Hi Paul I have only two more more questions where do I find the plx-daq macro and how do I change the names of the temp sensors, I have used the sketch you have provided

I had to search what plx-daq was, as I had no idea. It is some assistant tool for Microsoft Windows spreadsheet program called Excel. Sorry, I don't use Microsoft for my computing. If you need to use it, I am sure there will be others here on the forum who know it well and will be far better able to direct you on this. You may need to search an existing thread or start one to ask this question.

With the temperature sensor names, and I think you mean the program that Nick provided, yes ?, just do a search and replace on the actual variable name.

For example, where you have:

float Temp,Temp1,Temp2;

do a search and replace on Temp to a new name of your choosing, then the same with others.

I hope this helps somewhat.

I don't use the Arduino IDE for any of my coding work, I would far too quickly become frustrated and throw it all in and go sailing instead, but I am sure the Arduino IDE has search and replace capabilities.

Gosh, going sailing does sound like an idea actually :slight_smile:


Paul

I'm sorry Paul that question should have been for Nick as it was his suggestion but after reading up on it I would have install Excel and I'm have enough trouble with my antiquated technology. you have said there are other programming software can you offer some simpler suggestions

you have said there are other programming software can you offer some simpler suggestions

I'm looking to find where I might have said that.

In terms of what I am thinking you wish to do, which is to take the data and get that onto a PC of sorts and then represent that data in a chart or to do other analyses on it, there are many methods to do this.

One very simple method is to simply use the serial.print to send the data out in a CSV format, (Comma Separated Variable). The use a terminal program on your PC, whether that be the terminal program in the Arduino IDE or some other program, Hyperterm, CoolTerm so forth, there are hundreds.

Use the terminal program to capture the streaming data and save to file.
Use that file and open in your favourite spreadsheet application and then start munching the data and making pretty charts, pie, bar or line charts, showing minimums and maximums and maybe standard deviation for your temperature sensors based over time.

I think with what your daughter is wanting to do, you can really make a nice job of it and if this is a school project of sorts, she should get top marks.

As I mentioned, there are many methods to getting and representing data. I work mostly with control systems where the data is presented on a web application, dials and gauges showing live data and then historical charts to detail what has been. A whole other level in terms of sensor data to the screen.

You can go this way too, but if this is a school project, then I guess you need to have this up and running quick smart.

I hope this gives you some more insight and possibilities with what you can achieve with such systems as Arduino. They really can be amazing. I have used them in industrial research projects. It all comes down to good understanding of the project design and knowing the limits of capability.


Paul

I don't use the Arduino IDE for any of my coding work, /quote]

This is what I was refering to.so if there is a simpler coding system out there it would be good as wish to expand what I have and use it on a model railway system

Ah right, I understand now, sorry.

I would suggest you continue to use the Arduino IDE as it is the simplest and is particularly suited for people starting out with Arduino. It makes a lot of assumptions for you and helps 'tries' to make it as easy for you.

Saying that, being the simplest means for others who do more complex and serious work, the standard Arduino IDE just doesn't cut it, not at all.

the IDE is just that, an Integrated Development Environment, and there are a handful of others to choose from.
But these will take some effort and understanding to setup and make the most of.

But once you have it setup, wow, the difference is just worlds apart, and I often see how beginners really struggle to develop good structured code with the Arduino IDE, especially with deciphering errors, they often become lost and overwhelmed.

I use Eclipse IDE with the Arduino plugin. It is available for all major platforms and I am thrilled with how this IDE has made my life so much easier. So much so, I donated to the developer a few time in appreciation of my support.

As an example, in the Arduino IDE if you hover over a variable or function name, you see nothing.
In a serious IDE, when you hover over many parts of the code, you see all sorts of important and relevant information, and information that will and does help build better code. It also allows you to see where mistakes are. I can see all errors as underlined red.

So, rather than having to compile and wade through the errors I might have, I can quickly see them in my code as they are highlighted as such.

What I mentioned above is just a taster of what a more serious IDE provides.

I can only encourage people who are struggling with the Arduino IDE in terms of its limitations and needing more features to look at something like Eclipse with the Arduino plugin.

There is a section in the forum about this IDE, http://forum.arduino.cc/index.php?topic=79595.0
Or, go directly to the developers site at Arduino Eclipse IDE named Sloeber - Welcome!

If you are only going to dabble with Arduino, then the Arduino IDE will be fine for you.

I hope this provides you with the information you seek.


Paul

copjohn:
I would have install Excel and I'm have enough trouble with my antiquated technology. you have said there are other programming software can you offer some simpler suggestions

Antiquated technology is just what you need. PLX-DAQ is a freebie macro for Excel that effectively turns it into a terminal, thereby allowing Arduino to feed directly into a worksheet and, best of all, allows you to have live graphs. It only works with older versions of Excel. I use Office 2000 under XP. Indeed anything Excel can do can be done direct from Arduino. No need to send time, timestamping is done by Excel using the PC clock.

The extra programming for Arduino is just a couple of lines. Some notes are at

http://homepages.ihug.com.au/~npyner/Arduino/GUIDE_2PLX.pdf

Note that any terminal programme, like RealTerm, does local timestamping and they make files that can be subsequently exported to Excel. All you need do is send comma separated date from Arduino. Your last choice is the serial monitor, which is really just a debugging tool.