Need help with DS1820 firmware

I have written a small test code for reading temp and publishing.

Every second read fails for some reason and I cannot see why from the code.

Program print output…

Attempting Sample
20.12
Attempting Sample
No Reading
Attempting Sample
20.12
Attempting Sample
No Reading
Attempting Sample
No Reading
Attempting Sample
20.12

I have the DS1820 permanently connected to 5V supply and have a 4k7 pull up to +3.3V on D4.

Any help much appreciated. Code below

#include "DS18.h"

DS18 sensor(D4);

#define led D7

char message[20];

unsigned long lastUploadTime = 0UL; //publish time var
const unsigned long updateFrequency = 600000UL;    // Update frequency in milliseconds (10 mins).
unsigned long lastSampleTime = 0UL; //sample time var
const unsigned long sampleFrequency = 5000UL;    // Update frequency in milliseconds (5 seconds).

void setup() {
   Serial.begin(115200);
   pinMode(led,OUTPUT);
   sprintf(message,"0.0");
}

void loop() {
  unsigned long now = millis();
  if(now-lastSampleTime > sampleFrequency){
    Serial.println("Attempting Sample");
    lastSampleTime = now;

    if(sensor.read()){
       sprintf(message,"%3.2f",sensor.celsius());
       Serial.println(message);
    }

    else{
      Serial.println("No Reading");
    }
    
    digitalWrite(led, HIGH);  //Blink D7 to show sample taken
    delay(50);
    digitalWrite(led, LOW);
  }

  if(now - lastUploadTime > updateFrequency)
  {
    lastUploadTime = now;
    Serial.print("Published");
    Particle.publish("f",message);
  }
}

Can you include the “DS18.h” library you’re using?
The reason you’re seeing “No Reading” periodically is because sensor.read() is occasionally returning 0 or false. Without the library though, I can’t say what the criteria are for not reading the sensor.
Also, try placing your resistor to 5V instead of 3.3V. That’s how I have my DS18B20’s hooked up. Pin D4 is 5V tolerant so hooking up the resistor in parallel to 5V and the data line could help more easily define the logic 0 and 1 from the sensor.