removing the delay out of the dallas temp library

hi there is it possible to remove the delay in the dallas library? i no that the delay is needed but was thinking of doing something like Blink without Delay with in the loop

any ideas? thanks Joe

There are two ways to use the library. One is to not use callbacks. In that case, the delay IS necessary, to give the device time to determine the temperature.

The other is to use callbacks. The device will begin determining the temperature, and the function will return right away. You will be called when the temperature is determined.

Bottom line: No changes to the library are needed. All that is needed is for you to use it properly.

Joes: is it possible to remove the delay in the dallas library?

Which library?

Some time ago I saw a Dallas library which used a "delay against silly programming by pushy programmers".

In case the programmer used the library correctly, there was no delay used.

But in case the programmer wanted to do silly things like requesting a temperature conversion, do no waiting until the temperature is ready and then immediately read the temperature while the conversion is still in progress, the library is outbraking the pushy programmer by inserting a delay() function call. So only ignorant and pushy programmers get the delay(), while other programmers who know how to use the library correctly, will never get a delay() while using the same library.

ok cool the library i am using is: 3.7.2

here is an example of how i have been doing it using a ds18b20, encoder & little OLED:

int encoderPin1 = 2;
int encoderPin2 = 3;

volatile int lastEncoded = 0;
volatile float encoderValue = 30;

long lastencoderValue = 0;

int lastMSB = 0;
int lastLSB = 0;

int led = 13;

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


#define ONE_WIRE_BUS 7 
OneWire ourWire(ONE_WIRE_BUS);
DallasTemperature sensors(&ourWire);


#define _Digole_Serial_UART_  //To tell compiler compile the special communication only, 
//all available are:_Digole_Serial_UART_, _Digole_Serial_I2C_ and _Digole_Serial_SPI_
#include <DigoleSerial.h>
//--------UART setup, if you don't use UART, use // to comment following line
#if defined(_Digole_Serial_UART_)
DigoleSerialDisp mydisp(&Serial, 9600); //UART:Arduino UNO: Pin 1(TX)on arduino to RX on module
#endif

#define LCDCol 16
#define LCDRow 2

const unsigned char fonts[] = {
  6, 10, 18, 51, 120, 123};


void setup() 
{
  pinMode(led,        OUTPUT);
  pinMode(encoderPin1, INPUT); 
  pinMode(encoderPin2, INPUT);

  digitalWrite(encoderPin1, HIGH); //turn pullup resistor on
  digitalWrite(encoderPin2, HIGH); //turn pullup resistor on

  attachInterrupt(0, updateEncoder, CHANGE); 
  attachInterrupt(1, updateEncoder, CHANGE);

  mydisp.begin();
  mydisp.clearScreen(); //CLear screen
  mydisp.setFont(fonts[4]);
  mydisp.drawStr(3, 0, "HELLO"); 
  delay(2000);

  mydisp.clearScreen(); //CLear screen
  delay(500);
  mydisp.setFont(fonts[2]);
  mydisp.drawStr(0, 0, "Temp:");
  mydisp.drawStr(0, 2, "SET :");

  sensors.begin();  //Start up the DallasTemperature library

}


void loop() 
{
  sensors.requestTemperatures();
  // Temp
  mydisp.setFont(fonts[3]);
  mydisp.setPrintPos(8, 0);
  mydisp.print(sensors.getTempCByIndex(0),1);

  // Set temp
  mydisp.setFont(fonts[3]);
  mydisp.setPrintPos(8, 1);
  mydisp.print(encoderValue);  

  if (encoderValue < sensors.getTempCByIndex(0)) {
    digitalWrite(led,    HIGH);
  }
  else {
    digitalWrite(led,    LOW);
  }


}

void updateEncoder(){
  int MSB = digitalRead(encoderPin1); //MSB = most significant bit
  int LSB = digitalRead(encoderPin2); //LSB = least significant bit

  int encoded = (MSB << 2) |LSB; //converting the 2 pin value to single number
  int sum  = (lastEncoded << 2) | encoded; //adding it to the previous encoded value

  if(sum == 0b1101 || sum == 0b0100 || sum == 0b0010 || sum == 0b1011) encoderValue = encoderValue + 0.1;
  if(sum == 0b1110 || sum == 0b0111 || sum == 0b0001 || sum == 0b1000) encoderValue = encoderValue - 0.1;

  lastEncoded = encoded; //store this value for next time
}

where am i going wrong then?

There is a method in the DallasTemperature library, setWaitForConversion(), that you can call to tell the class to wait for the conversion to be complete, or not (the "conversion" being the process of getting the temperature).

There is another method, isConversionAvailable() that will return true or false, depending on whether there is data to be read.

There are other methods that are worth exploring.