DS18B20 only updating in .45 increments


hi, seem having issues with ds18b20 temperature sensors, have 3 of them hooked pin 47.

they work , accurate each other update in .45 increments on f , .25 on c following.

76.55
77.00
77.45
77.90
78.35
78,80

i have 4.7k resistor between each sensor. here code i'm using. ideas?

code: [select]
#include <onewire.h>
#include <dallastemperature.h>

#define one_wire_bus 47
onewire onewire(one_wire_bus);
dallastemperature sensors(&onewire);

deviceaddress insidethermometer = { 0x28, 0xa6, 0xa0, 0xb5, 0x05, 0x00, 0x00, 0xe6 };
deviceaddress outsidethermometer = { 0x28, 0x73, 0x36, 0xb5, 0x05, 0x00, 0x00, 0xe2 };
deviceaddress doghousethermometer = { 0x28, 0x4f, 0xca, 0xcf, 0x05, 0x00, 0x00, 0x46 };

void setup(void)
{
  // start serial port
  serial.begin(9600);
  // start library
  sensors.begin();
  // set resolution 10 bit (good enough?)
  sensors.setresolution(insidethermometer, 10);
  sensors.setresolution(outsidethermometer, 10);
  sensors.setresolution(doghousethermometer, 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("inside temperature is: ");
  printtemperature(insidethermometer);
  serial.print("\n\r");
  serial.print("outside temperature is: ");
  printtemperature(outsidethermometer);
  serial.print("\n\r");
  serial.print("dog house temperature is: ");
  printtemperature(doghousethermometer);
  serial.print("\n\r\n\r");
}

set resolution 12, maybe 10 not enuff


Arduino Forum > Using Arduino > Sensors > DS18B20 only updating in .45 increments


arduino

Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code