DallasTemp temperature accuracy [need to tweak the code a bit]


hi guys,

i've managed connect 5 temp. sensors 1 bus using code:

code: [select]
/* yourduino multiple ds18b20 temperature sensors on 1 wire
 connections:
 ds18b20 pinout (left right, pins down, flat side toward you)
 - left   = ground
 - center = signal (pin 10):  (with 3.3k 4.7k resistor +5 or 3.3 )
 - right  = +5 or +3.3 v

  questions: terry@yourduino.com
  v1.01  01/17/2013 ...based on examples rik kretzinger
 
/*-----( import needed libraries )-----*/
// 1-wire library here: http://www.pjrc.com/teensy/td_libs_onewire.html
#include <onewire.h>

//get dallastemperature library here:  http://milesburton.com/main_page?title=dallas_temperature_control_library
#include <dallastemperature.h>

/*-----( declare constants , pin numbers )-----*/
#define one_wire_bus_pin 10

//lcd
#include <liquidcrystal.h>
liquidcrystal lcd(12, 11, 5, 4, 3, 2);

/*-----( declare objects )-----*/
// setup onewire instance communicate onewire devices
onewire onewire(one_wire_bus_pin);

// pass our onewire reference dallas temperature.
dallastemperature sensors(&onewire);

/*-----( declare variables )-----*/
// assign addresses of 1-wire temp sensors.
// see tutorial on how obtain these addresses:
// http://www.hacktronics.com/tutorials/arduino-1-wire-address-finder.html

deviceaddress probe01 = { 0x28, 0x78, 0xe0, 0x10, 0x05, 0x00, 0x00, 0xf0 };
deviceaddress probe02 = { 0x28, 0xa2, 0xa3, 0x10, 0x05, 0x00, 0x00, 0x5c };
deviceaddress probe03 = { 0x28, 0xb8, 0x45, 0x11, 0x05, 0x00, 0x00, 0x01 };
deviceaddress probe04 = { 0x28, 0xa2, 0x18, 0x11, 0x05, 0x00, 0x00, 0xec };
deviceaddress probe05 = { 0x28, 0x73, 0x5a, 0x11, 0x05, 0x00, 0x00, 0x75 };


void setup()   /****** setup: runs once ******/
{
 // start serial port show results
 serial.begin(9600);
 serial.print("initializing temperature control library version ");
 serial.println(dallastemplibversion);
 lcd.begin(20, 4);
 
 // initialize temperature measurement library
 sensors.begin();
 
 // set resolution 10 bit (can 9 12 bits .. lower faster)
 sensors.setresolution(probe01, 10);
 sensors.setresolution(probe02, 10);
 sensors.setresolution(probe03, 10);
 sensors.setresolution(probe04, 10);
 sensors.setresolution(probe05, 10);

}//--(end setup )---

void loop()   /****** loop: runs ******/
{
 delay(1000);
 serial.println();
 serial.print("number of devices found on bus = ");  
 serial.println(sensors.getdevicecount());  
 serial.print("getting temperatures... ");  
 serial.println();  
 
 // command devices on bus read temperature  
 sensors.requesttemperatures();  
 
 serial.print("probe 01 temperature is:   ");
 printtemperature(probe01);
 serial.println();

 serial.print("probe 02 temperature is:   ");
 printtemperature(probe02);
 serial.println();


 serial.print("probe 03 temperature is:   ");
 printtemperature(probe03);
 serial.println();

 
 serial.print("probe 04 temperature is:   ");
 printtemperature(probe04);
 serial.println();

 
 serial.print("probe 05 temperature is:   ");
 printtemperature(probe05);
 serial.println();

   
 
}//--(end main loop )---

/*-----( declare user-written functions )-----*/
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));
  }
}// end printtemperature
//*********( end )***********


and i'd change code displays temperature more accurately instead of every .25.

which bit if code need tweak in order want? (funny enough, noticed sensor #5 shows data, not .25.

ps. display data on lcd display. bit of code need modify working properly?

thanks in advance

it idea read on libraries using. hint: suppose following does?
code: [select]
  // set resolution 10 bit (can 9 12 bits .. lower faster)
  sensors.setresolution(probe01, 10);


Arduino Forum > Using Arduino > Project Guidance > DallasTemp temperature accuracy [need to tweak the code a bit]


arduino

Comments

Popular posts from this blog

opencv3, tbb and rasp pi 2 - Raspberry Pi Forums

small ethernet problem - Raspberry Pi Forums

Multithumb configuration params not working? - Joomla! Forum - community, help and support