Pages: 1 [2]   Go Down
Author Topic: Help with DS18S20 Temp Sensors  (Read 4041 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 8
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Not meaning to hijack this thread, but has anyone had any luck running that fungizmos.com code (with the exact parts outlined - DS18S20-PAR, 4.7 kohm resistor, arduino, etc...) in sub-freezing temperatures (i.e., <32F)? Once any of my sensors drop below ~32F, the reading switches to something like -190 (I'm not in front of my setup). I'll admit that I need to spend a little more time deep in the code (or am I missing something), but I figured it wouldn't hurt to ask? It's either that or run a line to the freezer and debug!

I did find this -> http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1161557194/58#58
But it really wasn't that helpful...

Thanks in advance for any help you may provide.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Woodnotoil, any chance you could post a picture of your Arduino and wiring?  I saw that picture too but as soon as I flip the sensor around I get the no more addresses error.  If it's flipped the other way I get the errors about it not being a dS18S20 family device and a CRC error.

I was originally was going to order the sensors you have directly from Maxim but there were closed for the holiday break and I wanted to work on this project ASAP.  If I don't get this going with the current sensors though I guess I'll have to order some from them anyway.

thanks
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 36
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I couldn't figure out how to post the pictures on this forum so I put them in a post on the other one we were following.

http://forums.fungizmos.com/viewtopic.php?f=6&t=2&p=36&sid=9fa3f5eb05dbbe84f6f41dbe58437bb6#p36
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 36
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Now for a code question.  I now need to turn a relay on and off based on an if statement.  That if statement will include the temp of the boiler output, the storage tank temp, a setpoint temperature and a differential.  I will add the following to the top of the code to initialize the relay pin and to set the last two variables:

Code:
   byte boiler[8]  = {0x10, 0xCE, 0xE3, 0x0F, 0x01, 0x08, 0x00, 0xA4};
    byte storage[8] = {0x10, 0xC0, 0x08, 0x64, 0x00, 0x08, 0x00, 0xB2};
    int relayPin = 12;      // Relay connected to digital pin 12
    int setpoint = 175;     // Set the desired storage maximum temp in Fahrenheit here
    int differential = 10;   // Set the differential between source temp and storage temp in Fahrenheit here

Then I need to add the if statement to the loop at the end of the code.  My problem is that I am not sure what each temp that has been floated is being called to use in the statement.  They appear to both be called temp and printed to serial.  I need to use those temps.  This is what I have worked out so far and have simply called them (boiler) and (storage) for now.  Anyone know how to do this?

Code:
   // ########### L O O P ###########
    void loop(void) {

       //search_devices(); //enable this line to get sensor device id. comment out when finished
      
       float temp;
       temp = get_temp(boiler);
      
       Serial.print("Temp = ");
       Serial.println(temp, DEC);
  
       temp = get_temp(storage);
      
       Serial.print("Temp = ");
       Serial.println(temp, DEC);


     //Turn Relay on/off routine

     if ((boiler) > (storage) + (differential))     //check source temp for differential
                         {
       digitalWrite (relayPin, HIGH);            //if temp is above x degrees turn pin "ON"
                           }
       else if ((storage) > (setpoint))                  //check storage temp against setpoint
                         {
       digitalWrite (relayPin, LOW);            //if temp is below x degree turn pin "OFF"
                         }
       else
                               {
       digitalWrite (relayPin, LOW);            //if temp is below x degree turn pin "OFF"
                               }

     delay(1000*60);  //1 minute loop
    }
Logged

Woodland, WA
Offline Offline
Newbie
*
Karma: 0
Posts: 17
Always extra parts after reassembly
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry about that, my quick code/mangle/snippit on the FunGizmos forum left off the twos complement adjustment for temps below freezing.

Where it checks to see if the sign bit is set it you need to do a two's compliment flip as well as making the temp negative.  You can replace the if statement to read as follows:

 if (data[1] > 0x80){  // sign bit set, temp is negative
     temp = !temp + 1; //two's complement adjustment
     temp = temp * -1; //flip value negative.
  }


That was mentioned in the datasheet, but didn't get tested here until a few weeks ago when our outside temp dropped down to 8 degrees or so..



Quote
Not meaning to hijack this thread, but has anyone had any luck running that fungizmos.com code (with the exact parts outlined - DS18S20-PAR, 4.7 kohm resistor, arduino, etc...) in sub-freezing temperatures (i.e., <32F)? Once any of my sensors drop below ~32F, the reading switches to something like -190 (I'm not in front of my setup). I'll admit that I need to spend a little more time deep in the code (or am I missing something), but I figured it wouldn't hurt to ask? It's either that or run a line to the freezer and debug!
« Last Edit: January 14, 2009, 03:50:29 am by willp » Logged

Will -  FunGizmos.com

0
Offline Offline
Full Member
***
Karma: 0
Posts: 177
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello everybody

I'm trying to use the same code from the Playground plus the latest version of OneWire library, but when compiling I have these errors, PLEASE HELP CAUSE I HAVE NO CLUE smiley-sad

(I have noticed OneWire.o is not present in the library zip file and it's created the first time something with it included is compiled)

o: In function `OneWire':
C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build42963.tmp/OneWire.cpp:72: multiple definition of `OneWire::OneWire(unsigned char)'


hardware\libraries\OneWire\OneWire.o:C:\Programmi\arduino-0012/hardware\libraries\OneWire/OneWire.cpp:72: first defined here


o: In function `OneWire':
C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build42963.tmp/OneWire.cpp:72: multiple definition of `OneWire::OneWire(unsigned char)'


hardware\libraries\OneWire\OneWire.o:C:\Programmi\arduino-0012/hardware\libraries\OneWire/OneWire.cpp:72: first defined here


o: In function `OneWire::reset_search()':
C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build42963.tmp/OneWire.cpp:212: multiple definition of `OneWire::reset_search()'


hardware\libraries\OneWire\OneWire.o:C:\Programmi\arduino-0012/hardware\libraries\OneWire/OneWire.cpp:212: first defined here


o: In function `OneWire::crc8(unsigned char*, unsigned char)':
C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build42963.tmp/OneWire.cpp:328: multiple definition of `OneWire::crc8(unsigned char*, unsigned char)'


hardware\libraries\OneWire\OneWire.o:C:\Programmi\arduino-0012/hardware\libraries\OneWire/OneWire.cpp:328: first defined here


o: In function `OneWire::depower()':
C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build42963.tmp/OneWire.cpp:201: multiple definition of `OneWire::depower()'


hardware\libraries\OneWire\OneWire.o:C:\Programmi\arduino-0012/hardware\libraries\OneWire/OneWire.cpp:201: first defined here


o: In function `OneWire::read_bit()':
C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build42963.tmp/OneWire.cpp:135: multiple definition of `OneWire::read_bit()'


hardware\libraries\OneWire\OneWire.o:C:\Programmi\arduino-0012/hardware\libraries\OneWire/OneWire.cpp:135: first defined here


o: In function `OneWire::read()':
C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build42963.tmp/OneWire.cpp:171: multiple definition of `OneWire::read()'


hardware\libraries\OneWire\OneWire.o:C:\Programmi\arduino-0012/hardware\libraries\OneWire/OneWire.cpp:171: first defined here


o: In function `OneWire::write_bit(unsigned char)':
C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build42963.tmp/OneWire.cpp:117: multiple definition of `OneWire::write_bit(unsigned char)'


hardware\libraries\OneWire\OneWire.o:C:\Programmi\arduino-0012/hardware\libraries\OneWire/OneWire.cpp:117: first defined here


o: In function `OneWire::write(unsigned char, unsigned char)':
C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build42963.tmp/OneWire.cpp:156: multiple definition of `OneWire::write(unsigned char, unsigned char)'


hardware\libraries\OneWire\OneWire.o:C:\Programmi\arduino-0012/hardware\libraries\OneWire/OneWire.cpp:156: first defined here


o: In function `OneWire::skip()':
C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build42963.tmp/OneWire.cpp:196: multiple definition of `OneWire::skip()'


hardware\libraries\OneWire\OneWire.o:C:\Programmi\arduino-0012/hardware\libraries\OneWire/OneWire.cpp:196: first defined here


o: In function `OneWire::select(unsigned char*)':
C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build42963.tmp/OneWire.cpp:184: multiple definition of `OneWire::select(unsigned char*)'


hardware\libraries\OneWire\OneWire.o:C:\Programmi\arduino-0012/hardware\libraries\OneWire/OneWire.cpp:184: first defined here


o: In function `OneWire::reset()':
C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build42963.tmp/OneWire.cpp:92: multiple definition of `OneWire::reset()'


hardware\libraries\OneWire\OneWire.o:C:\Programmi\arduino-0012/hardware\libraries\OneWire/OneWire.cpp:92: first defined here


o: In function `OneWire::search(unsigned char*)':
C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build42963.tmp/OneWire.cpp:233: multiple definition of `OneWire::search(unsigned char*)'


hardware\libraries\OneWire\OneWire.o:C:\Programmi\arduino-0012/hardware\libraries\OneWire/OneWire.cpp:233: first defined here


Couldn't determine program size: C:\Programmi\arduino-0012\hardware/tools/avr/bin/avr-size: 'C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build42963.tmp\onewiretemp.hex': No such file
« Last Edit: January 14, 2009, 07:00:58 pm by agentsmith » Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 107
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't have any problem with the onewire library.. I've been using it since before v10 and I'm on v12 IDE now and it still works.
  I'm using the 18B20, but they both have the same features.

I found that, especially if you are dealing with +100c temperature, you want to do powered, not parasite mode... or the temps go funky somewhere over 85c.  The app note says there is too much leakage at high temps in regards to parasite mode..

As for reading multiple sensors.. it's really not that hard... I'll try to give a good code snippet tomorrow
« Last Edit: January 14, 2009, 09:32:48 pm by dnear1 » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 8
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Will. But, for once, I figured this one out on my own... The geek in me couldn't let it go and I ended up taking the whole set up with me on this last trip, LCD, two sensors, arduino, breakout shield and breadboards, battery pack... Guess that explains the "notice of baggage inspection" from TSA!

I think I'll do a little write up and post it in the "exhibition" section soon.
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 177
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

BTW I make it working.. no more compile errors. don't know, just rebooted the pc.
From my Arduino 101 last december, things are getting really interesting smiley-grin

Biometrics: Yeah it could be a problem at the security check... I would bring with me the Getting Started with Arduino book, that's like a proof it's not harmful smiley
« Last Edit: January 15, 2009, 04:29:09 pm by agentsmith » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 8
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In all seriousness, I've actually never had any trouble transporting electronics in my luggage. I just don't take it in my carry on.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 36
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I finished my arduino based heating project and anyone interested can view the results at http://woodnotoil.googlepages.com/arduino .  Thanks to everyone on here for the great help.   smiley-wink
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 8
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Nice post Woodnotoil. I finally got my write-up finished and posted for the indoor/outdoor thermometer I built. http://www.forestdynamics.com/?p=344
Thanks again for the discussion and for all the insights... now to get this thing reading humidity and controlling the HVAC!
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 36
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Nice writeup.  Keep us posted on future projects.
Logged

Victoria, BC, Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 10
Learning, learning, always learning.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Woodnotoil;
Quote
My sensors are DS18S20+.  Not sure if different code is required for the +.  

On the DS1822 datasheet, the + version is a lead-free version. The coding should be no different.

Logged

--
Victoria, BC
48˚ 57'N 123˚ 13'W

Berkeley, California
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That compile-time Error Agent Smith reported: I just had it too. The resolution is to pull out of the hardware libraries folder the DallasTemperature lib. It conflicts in the definitions of OneWire lib.
I got the same error messages:
Quote
o: In function `OneWire':
C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build42963.tmp/OneWire.cpp:72: multiple definition of `OneWire:ShockedneWire(unsigned char)'


hardware\libraries\OneWire\OneWire.o:C:\Programmi\arduino-0012/hardware\librarie
s\OneWire/OneWire.cpp:72: first defined here


o: In function `OneWire':
C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build42963.tmp/OneWire.cpp:72: multiple definition of `OneWire:ShockedneWire(unsigned char)'


hardware\libraries\OneWire\OneWire.o:C:\Programmi\arduino-0012/hardware\librarie
s\OneWire/OneWire.cpp:72: first defined here


o: In function `OneWire::reset_search()':
C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build42963.tmp/OneWire.cpp:212: multiple definition of `OneWire::reset_search()'


hardware\libraries\OneWire\OneWire.o:C:\Programmi\arduino-0012/hardware\librarie
s\OneWire/OneWire.cpp:212: first defined here


o: In function `OneWire::crc8(unsigned char*, unsigned char)':
C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build42963.tmp/OneWire.cpp:328: multiple definition of `OneWire::crc8(unsigned char*, unsigned char)'


hardware\libraries\OneWire\OneWire.o:C:\Programmi\arduino-0012/hardware\librarie
s\OneWire/OneWire.cpp:328: first defined here


o: In function `OneWire::depower()':
C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build42963.tmp/OneWire.cpp:201: multiple definition of `OneWire::depower()'


hardware\libraries\OneWire\OneWire.o:C:\Programmi\arduino-0012/hardware\librarie
s\OneWire/OneWire.cpp:201: first defined here


o: In function `OneWire::read_bit()':
C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build42963.tmp/OneWire.cpp:135: multiple definition of `OneWire::read_bit()'


hardware\libraries\OneWire\OneWire.o:C:\Programmi\arduino-0012/hardware\librarie
s\OneWire/OneWire.cpp:135: first defined here


o: In function `OneWire::read()':
C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build42963.tmp/OneWire.cpp:171: multiple definition of `OneWire::read()'


hardware\libraries\OneWire\OneWire.o:C:\Programmi\arduino-0012/hardware\librarie
s\OneWire/OneWire.cpp:171: first defined here


o: In function `OneWire::write_bit(unsigned char)':
C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build42963.tmp/OneWire.cpp:117: multiple definition of `OneWire::write_bit(unsigned char)'


hardware\libraries\OneWire\OneWire.o:C:\Programmi\arduino-0012/hardware\librarie
s\OneWire/OneWire.cpp:117: first defined here


o: In function `OneWire::write(unsigned char, unsigned char)':
C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build42963.tmp/OneWire.cpp:156: multiple definition of `OneWire::write(unsigned char, unsigned char)'


hardware\libraries\OneWire\OneWire.o:C:\Programmi\arduino-0012/hardware\librarie
s\OneWire/OneWire.cpp:156: first defined here


o: In function `OneWire::skip()':
C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build42963.tmp/OneWire.cpp:196: multiple definition of `OneWire::skip()'


hardware\libraries\OneWire\OneWire.o:C:\Programmi\arduino-0012/hardware\librarie
s\OneWire/OneWire.cpp:196: first defined here


o: In function `OneWire::select(unsigned char*)':
C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build42963.tmp/OneWire.cpp:184: multiple definition of `OneWire::select(unsigned char*)'


hardware\libraries\OneWire\OneWire.o:C:\Programmi\arduino-0012/hardware\librarie
s\OneWire/OneWire.cpp:184: first defined here


o: In function `OneWire::reset()':
C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build42963.tmp/OneWire.cpp:92: multiple definition of `OneWire::reset()'


hardware\libraries\OneWire\OneWire.o:C:\Programmi\arduino-0012/hardware\librarie
s\OneWire/OneWire.cpp:92: first defined here


o: In function `OneWire::search(unsigned char*)':
C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build42963.tmp/OneWire.cpp:233: multiple definition of `OneWire::search(unsigned char*)'


hardware\libraries\OneWire\OneWire.o:C:\Programmi\arduino-0012/hardware\librarie
s\OneWire/OneWire.cpp:233: first defined here


Couldn't determine program size: C:\Programmi\arduino-0012\hardware/tools/avr/bin/avr-size: 'C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build42963.tmp\onewiretemp.hex': No such file
Logged

Pages: 1 [2]   Go Up
Jump to: