Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DS18B20 FAHRENHEIT ACCURACY
04-07-2015, 03:29 PM,
#1
DS18B20 FAHRENHEIT ACCURACY
Code:
#define ONEWIREBUS    11                        // DQ line                        
int ifar;
int ffar;

void setup()
{
lcd.pins(8, 9, 4, 5, 6, 7, 0, 0, 0, 0);
lcd.begin(20, 4);


}

void loop()
{
    TEMPERATURE t;
    ifar = t.integer * 9 / 5 + 32;
ffar = t.fraction * 9 / 5;
    if (DS18B20.read(ONEWIREBUS, SKIPROM, RES10BIT, &t))
    {
        if (t.sign) lcd.print("-");
  lcd.setCursor(8,3);
        lcd.printf("%d.F", ifar, ffar);
 //lcd.setCursor(0,2);
        //lcd.printf("%d.%dC", t.integer, t.fraction);
 lcd.setCursor(4,0);  
 lcd.print("ETCHING TANK");
 lcd.setCursor(4,1);
 lcd.print("TEMPERATURE");
    }
    delay(100);
//lcd.clear();
}
i am using a 45k50 on linux debian with the latest ide 11
my issue is with the Fahrenheit temperature accuracy the celsius reading is accurate but the fahrenheit reading jumps by 2 degrees can some please help.thank you
fred
Reply
04-07-2015, 06:02 PM, (This post was last modified: 04-07-2015, 06:09 PM by moreno.)
#2
RE: DS18B20 FAHRENHEIT ACCURACY
Hi

I think you do use a wrong formula.

ifar = t.integer * 100;
ifar += t.fraction;

ifar = ((ifar * 9) / 5) + 3200;
ffar = ifar % 100;
ifar /= 100;

Bye Bye, Moreno
Reply
05-07-2015, 04:35 AM,
#3
RE: DS18B20 FAHRENHEIT ACCURACY
(04-07-2015, 06:02 PM)moreno Wrote: Hi

I think you do use a wrong formula.

ifar = t.integer * 100;
ifar += t.fraction;

ifar = ((ifar * 9) / 5) + 3200;
ffar = ifar % 100;
ifar /= 100;

Bye Bye, Moreno
Moreno
thank you it worked perfect.

fred
Reply
28-10-2015, 10:16 PM,
#4
RE: DS18B20 FAHRENHEIT ACCURACY
Moreno
while i was using the the formula you gave which works great until i hit a temp of 96F then my readings go to -33F and never go down until i reach 96F. Any suggestions?
thank you fred warden
Reply
28-10-2015, 11:37 PM,
#5
RE: DS18B20 FAHRENHEIT ACCURACY
Code:
#define ONEWIREBUS    2

int ifar;
int ffar;


void setup() {
  //DS18B20.begin(ONEWIREBUS);
  // put your setup code here, to run once:    
}

void loop() {


TEMPERATURE t;
    ifar = t.integer * 100;
         ifar += t.fraction;

         ifar = ((ifar * 1.8)  + 3200);
         ffar = ifar % 100;  
         ifar /= 100;
     // TEMPERATURE t;
      if (DS18B20.read(ONEWIREBUS, SKIPROM, RES9BIT, &t)) {
     
          CDC.println("");
          CDC.printf("  %d.%d F \r\n", ifar,ffar);
          CDC.printf(" %d.%d C \r\n" ,t.integer,t.fraction);
         
}
}
i figured it out and this works above 150 F and down to 34 F 
Reply
29-10-2015, 10:44 AM,
#6
RE: DS18B20 FAHRENHEIT ACCURACY
Hi


Mmm, I think there is a problem here.


Code:
(ifar * 1.8)

ifar is an integer and you multiply it for a float 1.8, I do not exactly what happens but is possible which the formula give wrong result.
My formula ((ifar * 9) / 5) + 3200; use only integer and is more quick and safe.


Bye Bye, Moreno
Reply
29-10-2015, 02:03 PM,
#7
RE: DS18B20 FAHRENHEIT ACCURACY
C rules say how it will be calculated but surely there should be no need for any kind of float.

John
Reply
29-10-2015, 05:30 PM,
#8
RE: DS18B20 FAHRENHEIT ACCURACY
what is causing the reading to go negative after 95F ?
thank you 
fred
Reply
29-10-2015, 10:57 PM,
#9
RE: DS18B20 FAHRENHEIT ACCURACY
I think it it because you are calculating °F before reading the sensor.
Can you try to move the calculation block just after the DS18B20.read() function?
Luca
Reply
30-10-2015, 12:55 AM,
#10
RE: DS18B20 FAHRENHEIT ACCURACY
(29-10-2015, 10:57 PM)brikker Wrote: I think it it because you are calculating °F before reading the sensor.
Can you try to move the calculation block just after the DS18B20.read() function?
Luca

no it still returns a negative value after 95 F.
thank you 
fred
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)