DS18B20 error

I am trying to make a thermal cut out to protect a pump.
but it won’t compile.

#include <OneWire.h>

#include <DallasTemperature.h>

//this device needs to turn on the power to a pump when the temp is below 30 dregrees

//declearing some variables
int tempTar =30; //the target temp
int tempSet =tempTar; // the temp which the themostat is set to

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

// 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);

// arrays to hold device address
DeviceAddress insideThermometer;

void setup(void)
{
pinMode(6, OUTPUT);// powering the temp sensor
digitalWrite(6, HIGH); // powering the sensor

pinMode(A0, OUTPUT);// relay switch pin

// start serial port
Serial.begin(9600);
Serial.println(“Dallas Temperature IC Control Library Demo”);

// locate devices on the bus
Serial.print(“Locating devices…”);
sensors.begin();
Serial.print(“Found “);
Serial.print(sensors.getDeviceCount(), DEC);
Serial.println(” devices.”);

// report parasite power requirements
Serial.print("Parasite power is: ");
if (sensors.isParasitePowerMode()) Serial.println(“ON”);
else Serial.println(“OFF”);

// assign address manually. the addresses below will beed to be changed
// to valid device addresses on your bus. device address can be retrieved
// by using either oneWire.search(deviceAddress) or individually via
// sensors.getAddress(deviceAddress, index)
//insideThermometer = { 0x28, 0x1D, 0x39, 0x31, 0x2, 0x0, 0x0, 0xF0 };

// Method 1:
// search for devices on the bus and assign based on an index. ideally,
// you would do this to initially discover addresses on the bus and then
// use those addresses and manually assign them (see above) once you know
// the devices on your bus (and assuming they don’t change).
if (!sensors.getAddress(insideThermometer, 0)) Serial.println(“Unable to find address for Device 0”);

// method 2: search()
// search() looks for the next device. Returns 1 if a new address has been
// returned. A zero might mean that the bus is shorted, there are no devices,
// or you have already retrieved all of them. It might be a good idea to
// check the CRC to make sure you didn’t get garbage. The order is
// deterministic. You will always get the same devices in the same order
//
// Must be called before search()
//oneWire.reset_search();
// assigns the first address found to insideThermometer
//if (!oneWire.search(insideThermometer)) Serial.println(“Unable to find address for insideThermometer”);

// show the addresses we found on the bus
Serial.print("Device 0 Address: ");
printAddress(insideThermometer);
Serial.println();

// set the resolution to 9 bit (Each Dallas/Maxim device is capable of several different resolutions)
sensors.setResolution(insideThermometer, 9);

Serial.print("Device 0 Resolution: ");
Serial.print(sensors.getResolution(insideThermometer), DEC);
Serial.println();
}

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”);

float tempC = sensors.getTempC(insideThermometer);
// It responds almost immediately. Let’s print out the data

Serial.print("Temp C ::::::::::::: ");
Serial.print(tempC);
Serial.println();

boolean heaterState =LOW;
if (tempC<tempSet){
digitalWrite(A0, HIGH);//this turns the relay and the Pump on below the set temp
heaterState =HIGH;
}

if (tempC>tempSet){
digitalWrite(A0, LOW);//this turns the relay and the pump off above the set temp
heaterState =LOW;
}

if (heaterState =HIGH)Serial.print(“Heater :::::::::::::: ON”);
if (heaterState =LOW)Serial.print(“Heater :::::::::::::: OFF”);
Serial.println();

Serial.print("Temp SET :::::::::::: ");
Serial.print(tempSet);
Serial.println();

delay(6000); // 6sec delay on the loop
Serial.println();
}

// function to print a device address
void printAddress(DeviceAddress deviceAddress)
{
for (uint8_t i = 0; i < 8; i++)
{
if (deviceAddress < 16) Serial.print(“0”);
_ Serial.print(deviceAddress*, HEX);_
_
}_
_
}_
_
[/quote]*_

it returns:

This report would have more information with "Show verbose output during compilation" enabled in File > Preferences. Arduino: 1.0.6 (Windows NT (unknown)), Board: "Arduino Uno" Thermal_Cut_out.cpp.o: In function __static_initialization_and_destruction_0': C:\Program Files (x86)\Arduino/Thermal_Cut_out.ino:25: undefined reference toDallasTemperature::DallasTemperature(OneWire*)' Thermal_Cut_out.cpp.o: In function loop': C:\Program Files (x86)\Arduino/Thermal_Cut_out.ino:100: undefined reference toDallasTemperature::requestTemperatures()' C:\Program Files (x86)\Arduino/Thermal_Cut_out.ino:104: undefined reference to DallasTemperature::getTempC(unsigned char const*)' Thermal_Cut_out.cpp.o: In functionsetup': C:\Program Files (x86)\Arduino/Thermal_Cut_out.ino:45: undefined reference to DallasTemperature::begin()' C:\Program Files (x86)\Arduino/Thermal_Cut_out.ino:47: undefined reference toDallasTemperature::getDeviceCount()' C:\Program Files (x86)\Arduino/Thermal_Cut_out.ino:52: undefined reference to DallasTemperature::isParasitePowerMode()' C:\Program Files (x86)\Arduino/Thermal_Cut_out.ino:66: undefined reference toDallasTemperature::getAddress(unsigned char*, unsigned char)' C:\Program Files (x86)\Arduino/Thermal_Cut_out.ino:86: undefined reference to DallasTemperature::setResolution(unsigned char const*, unsigned char)' C:\Program Files (x86)\Arduino/Thermal_Cut_out.ino:89: undefined reference toDallasTemperature::getResolution(unsigned char const*)'

Did you install DallasTemperature library ?

I think Waski is probably asking the right question, but I think the code is junk as well, and I’m not just referring to the stuff you have actually written. It my be kosher to power the sensor off pin 6, but nobody else does it and I bet you don’t have a good reason for doing it. Similarly, I bet you don’t have a good reason for using parasitic power either.

The Hacktronics tutorial is a lot more practical, and a lot easier to read.

http://www.hacktronics.com/Tutorials/arduino-1-wire-tutorial.html

This programme is derived therefrom

/* 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. 
http://www.hacktronics.com/Tutorials/arduino-1-wire-tutorial.html
Stay away from using parasite power
-127C means bad connection
85 means you haven't gotten a read yet, probably just the 
wrong order of commands
*/

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

// Data wires are 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);
  
byte Thermo1[8] = {0x28, 0x39, 0xFD, 0x50, 0x04, 0x00, 0x00, 0X69};
byte Thermo2[8] = {0x28, 0x09, 0xA9, 0xC0, 0x03, 0x00, 0x00, 0x95};
float tempC,Temp1,Temp2;  

void setup(){
  Serial.begin(9600);
  sensors.begin();
  delay(500);//Wait for newly restarted system to stabilize
  sensors.setResolution(Thermo1, 12); 
  sensors.setResolution(Thermo2, 12);
}

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

Serial.print("      Temp1 = ");
Serial.print(Temp1);
Serial.print("      Temp2 = "); 
Serial.println(Temp2);
delay(1000);
}

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

@waski Yes i did install the DallasTemperature library??

i.e. this one: https://github.com/milesburton/Arduino-Temperature-Control-Library/blob/master/DallasTemperature.h

@Nick_Pyner yeah its a code c&p from an example/other project and the one 5v out on the board has the relay on it

I am trying to make a thermal cut out to protect a pump.

Have you tried some of the simple examples that come along with the library?

Regards

EyesOfAHunter: @Nick_Pyner yeah its a code c&p from an example/other project and the one 5v out on the board has the relay on it

OK, the library is the same as I use and it's fine, although I wouldn't touch any of the examples that come with it. You should make sure the library is in the proper place - namely, the same place as all the other libraries that are known to work. You then need to close the IDE and start over so that it can find the library in its proper place.

I don't think having the relay on the 5v pin is a good enough reason not to have the sensor on it too. It's your prerogative and may even be common practice but, judging from the rest of the code, I wouldn't be too confident about the latter.

OK, the library is the same as I use and it’s fine, although I wouldn’t touch any of the examples that come with it. You should make sure the library is in the proper place - namely, the same place as all the other libraries that are known to work. You then need to close the IDE and start over so that it can find the library in its proper place.

Hi,

I’m suggesting to check if the basic -hardware, mainly- of the project is correct by means of the examples: Why do you say not to use them to do it?

Regards.

vffgaston: Why do you say not to use them to do it?

I'm afraid I can't remember the details, but I recall that every example with the library was convoluted junk. Indeed, I suspect the code OP posted above has been derived from the same junk. Even if it works as a demo, it is a poor path to a practical application. I recognise that the perception of junk can depend somewhat on where you are on the road to Damascus, but I got nowhere until I found the Hacktronics tutorial. Having said that, the Hacktronics stuff also left a bit to be desired, IMHO. I can't remember what that was about either, but the stuff I posted is slightly different.

I thought the original problem might simply be the library as Waski suggested, but I actually tried the code and the compile dies at line 142 (yes, 142!) which is in a function that is utterly alien to me, and I can't comment on it.

ok yeah its a library error

I have tried other sketchs and even running the bare min with the DallasTemperature and one wire library

and I still get a compile error.

So I re-installed these librarys: that didn't work so then uninstalled the Arduino software all together and installed them again.

they still don't work??

The compiler works for other e.g.'s without those library's.

am thinking I might have an error in my un-zipping software: does anyone have these files in an unzipped format?

otherwise????

If you follow the tutorial on library installation http://arduino.cc/en/Guide/Libraries you should be able to work with the .zip file without having to expand it.

maybe you have a library installation problem, but read reply #8 again. As I said, your code will not compile, even if the library is entirely kosher.