SMT172 inaccuarate value and noice

First I set together an UNO, an I2C LCD and the SMT172 using a breadboard. The temperature value shown looks correct and the noice is some 1/100 degree Celsius.
Fulfilling the project an UNO, I2C LCD and another SMT172 was assembled. The major difference is the distance between the sensor and the UNO. Now it is some 1,5 meters, 5 feet. The cable used is a 3 wire shilded cable. The 3 wires in thé Cable carry GND, 5 volt DCC and the signal. The shield is connected to ground to the UNO.
The value shown is almost two degrees Celcius lower and the noice is almost +/- 0,5 degree Celcius.
What additional stuff would You suggest? Pulldown-, pullup-resistors, decoupling capacitors near the UNO and/or near the sensor?

What additional stuff would You suggest? Pulldown-, pullup-resistors, decoupling capacitors near the UNO and/or near the sensor?

The problem is probably the capacitance of the cable from the UNO to the sensor. The longer that cable the higher the capacitance. You can get the capacitance a bit lower by increasing the distance between the wires in the cable (p.e. by using thicker insulation).
Your sensor is submitting it's value by a PWM signal. The ideal case is a square wave but the higher the connected capacitance the smoother the corners will get. This results in less steep edges and that decreases the time the Arduino sees a HIGH signal. So the temperature will be lower. I don't know where the noise has it's source but I guess that it's from EMF in the surrounding (p.e. motors).

Thanks pylon! Encouraged by Your answer I dug deaper in the data sheet and found this:

Supply voltage decoupling/cable compensation     It is common practice for precision analogue ICs to use a decoupling capacitor between Vcc and GND pins.  This capacitor ensures a better overall EMI/EMC performance. When applied, this capacitor should be a ceramic type and have a value of approximately 100nF. The location should be as close to the sensor as possible. The SMT172 has a very accurate output, the positive and negative edges of the output signal are very steep, about 5ns. This means when using longer cables (over 30cm) there can be an effect of the cable inductance and capacitance which means the pulse is “reflected” and will give a spike on the sensors power supply line and the output of the sensor. These spikes can damage the electronics behind this and also the sensor. Therefor we also advise user to put in series with the Vcc line a resistor of 100Ω. This resistor can also damp the spikes on the signal as well on the Vcc line when user forget to apply decoupling capacitor (this helps only for short cable<1m). 
 
   1 
 
 2  
 
 3 
Local electronics 
GND 
OUT 
SMT172 
100nF 
VCC 100Ω 
 
 
The capacitor will enhance the EMC performance and the resistor will also limit the maximum current in case of faults or wrong connections.

And does that work?

Today I soldered a 190 Ohm resistor between Vcc and GND on the UNO board. Then I can run the project powered by an USB power pack. The absolut error is now some 0,2 degrees Celcius but the flickering is quite the same. My intention is to use USB power packs when I have the project running sharpy.
Tomorrow I will buy the 100 nF ceramic capacitor and try that.

Yes, soldering those 100nF directly to the TO220 package did miracles regarding both accurasy and noise. The 100 Ohm in serie for the Vcc, soldered at the UNO board, was applied at the same time. That resistor is supposed to protect the sensor against bouncing voltages using long cables.

You are following the datasheet instructions to sample 8 consecutive cycles and average the
duty cycle over all 8 as explicitly described? They discuss the effect of microcontroller sampling rate
and averaging to the noise performance there too.

You should post your code - I suspect you're not using an ISR as you should be for this kind of sensor.

I just followed the instructions in Forum and compiled the demo file acompanying the downloaded library. I have not checked what or how it is doing. The noice I read is 0.01 degree Celsius and that is low. The specs tell that the acuaracy is 0,35 degrees C at room temperature… 2 different samples differ by 0.1 degree. Look at my code attached earlier in this topic.

Can't see any code...

Look at #2!

Sorry.

#include<arduino.h>
#include <SMT172.h>

//I2C for LCD
//boolean debug = false;

#include <SoftwareSerial.h>

#include <Wire.h>
#include <hd44780.h>
#include <hd44780ioClass/hd44780_I2Cexp.h>

//#define BACKLIGHT_PIN     13

hd44780_I2Cexp mylcd; // declare lcd object: auto locate & config exapander chip

// LCD geometry
#define LCD_COLS 16
#define LCD_ROWS 2

// The TinyGPS++ object

uint32_t LastSensorUpdate;
unsigned long sec_1_diff_measure_time;
unsigned long sec_10_diff_measure_time;
unsigned long minute_1_diff_measure_time;
unsigned long minute_10_diff_measure_time;
float sec_1_diff_measure_data = -1.1;
float sec_10_diff_measure_data = -1.1;
float minute_1_diff_measure_data = -1.1;
float minute_10_diff_measure_data = -1.1;


//The setup function is called once at startup of the sketch
void setup() {
  unsigned long tmp_millis;
  pinMode(8, INPUT_PULLUP);
  pinMode(12, OUTPUT);
  pinMode(3, OUTPUT);
  digitalWrite(3, LOW);
  Serial.begin(115200);
  Serial.println(F("Demo sketch SMT172"));

  //	The following code fragment sets up phase-correct PWM on pins 3 and 11 (Timer 2).
  //	The waveform generation mode bits WGM are set to to 001 for phase-correct PWM.
  //	The other bits are the same as for fast PWM.

  //  pinMode(3, OUTPUT);
  //  pinMode(11, OUTPUT);
  TCCR2A = _BV(COM2A1) | _BV(COM2B1) | _BV(WGM20);
  // TCCR2B = _BV(CS22); // Output frequency: 16 MHz / 64 / 255 / 2 =  490.196 Hz
  TCCR2B = _BV(CS21); // Output frequency: 16 MHz /  8 / 255 / 2 = 3921.569 Hz
  OCR2A = 237; // Output A duty cycle: 237 / 255 = 92.94%	= 129.58 C	on pin 11
  OCR2B = 28;	 // Output B duty cycle:  28 / 255 = 10.98%	= -45.06 C	on pin 3

  //Send temp via I2C to LCD
  int status;

  status = mylcd.begin(LCD_COLS, LCD_ROWS);
  if (status) // non zero status means it was unsuccesful
  {
    status = -status; // convert negative status value to positive number

    // begin() failed so blink error code using the onboard LED if possible
    hd44780::fatalError(status); // does not return
  }
  mylcd.clear();
  // initalization was successful, the backlight should be on now

  // Print start message to the LCD
  mylcd.print("Started");
  sec_1_diff_measure_time = tmp_millis + 1000;
  sec_10_diff_measure_time =    tmp_millis + 10000;
  minute_1_diff_measure_time =  tmp_millis + 60000;
  minute_10_diff_measure_time = tmp_millis + 600000;
  //  mylcd.setCursor(12, 2); mylcd.print(minute_1_diff_measure_time / 1000);
}

// The loop function is called in an endless loop
void loop()
{
  float tmp_temp;
  unsigned long mill_tmp;
  if ((millis() % 100) > 75)
    digitalWrite(3, LOW);
  else
    digitalWrite(3, HIGH);

  // read the sensor every 250 millisecond
  if ((unsigned long) (millis() - LastSensorUpdate) >= 500)
  {
    LastSensorUpdate = millis();

    SMT172::startTemperature(0.002);

repeat:
    switch (SMT172::getStatus()) {
      case 0: goto repeat; // O Dijkstra, be merciful onto me, for I have sinned against you :)
      case 1:
        //		    Serial.print(F("Measuring time   [ms]: "));
        //				Serial.println(SMT172::getTime() * 1e3, 2); // convert to milliseconds
        //				Serial.print(F("Sensor frequency [Hz]: "));
        //				Serial.println(SMT172::getFrequency(), 2);
        //				Serial.print(F("Duty cycle        [%]: "));
        //				Serial.println(SMT172::getDutyCycle() * 100, 2);

        tmp_temp = SMT172::getTemperature();
        mill_tmp = millis();

        //        Serial.print(F("Temperature       [C]: "));
        //        Serial.println(tmp_temp, 2);

        mylcd.setCursor(0, 0);
        mylcd.print(tmp_temp, 2);
        //        mylcd.print(F(" [C]"));
        mylcd.print(" [C]");

        /*        if (tmp_temp > 30.0 )
                {
                  Serial.println(tmp_temp);
                  mylcd.setCursor(0, 0);
                  mylcd.print(F("Err. [C]: "));
                  mylcd.print(tmp_temp, 4);
                }
        */
        if (sec_1_diff_measure_data < 0.0)//Initiate
        {
          sec_1_diff_measure_data = tmp_temp;
          sec_10_diff_measure_data = tmp_temp;
          minute_1_diff_measure_data = tmp_temp;
          minute_10_diff_measure_data = tmp_temp;
          sec_1_diff_measure_time = mill_tmp + 1000;
          sec_10_diff_measure_time = mill_tmp + 10000;
          minute_1_diff_measure_time = mill_tmp + 60000;
          minute_10_diff_measure_time = mill_tmp + 600000;
        }
        else
        {
          if (mill_tmp > sec_1_diff_measure_time )
          {
            //        Serial.print("1  Sec value "); Serial.print(tmp_temp);Serial .print(" ");Serial.println(mill_tmp/1000);
            sec_1_diff_measure_time = mill_tmp + 1 * 1000;//Set next measure time
            mylcd.setCursor(10, 0); mylcd.print("      ");
            mylcd.setCursor(10, 0); mylcd.print(tmp_temp - sec_1_diff_measure_data, 2); // mylcd.print(" ");
            sec_1_diff_measure_data = tmp_temp;
          }

          if (mill_tmp > sec_10_diff_measure_time )
          {
            Serial.print("10 Sec value "); Serial.print(tmp_temp); Serial .print(" "); Serial.println(mill_tmp / 1000);
            sec_10_diff_measure_time = mill_tmp + 10 * 1000;//Set next measure time
            mylcd.setCursor(0, 1); mylcd.print("      ");
            mylcd.setCursor(0, 1); mylcd.print(tmp_temp - sec_10_diff_measure_data, 2);// mylcd.print(" ");
            sec_10_diff_measure_data = tmp_temp;
          }
          if (mill_tmp > minute_1_diff_measure_time )
          {
            Serial.print("1  Min value "); Serial.print(tmp_temp); Serial .print(" "); Serial.println(mill_tmp / 1000);
            minute_1_diff_measure_time = mill_tmp + 60000;//Set next measure time
            mylcd.setCursor(6, 1);  mylcd.print("      ");
            mylcd.setCursor(6, 1); mylcd.print(tmp_temp - minute_1_diff_measure_data, 2);// mylcd.print(" ");
            minute_1_diff_measure_data = tmp_temp;
          }
          if (mill_tmp > minute_10_diff_measure_time )
          {
            Serial.print("10 Min value "); Serial.print(tmp_temp); Serial .print(" "); Serial.println(mill_tmp / 1000);
            minute_10_diff_measure_time = mill_tmp + 600000;//Set next measure time
            mylcd.setCursor(12, 1);  mylcd.print("    ");
            mylcd.setCursor(12, 1); mylcd.print(tmp_temp - minute_10_diff_measure_data, 1);// mylcd.print(" ");
            minute_10_diff_measure_data = tmp_temp;
          }
        }
        //        mylcd.setCursor(0, 3); mylcd.print(mill_tmp / 1000); mylcd.print(" "); mylcd.print(minute_1_diff_measure_time / 1000);
        //        mylcd.setCursor(16, 3); mylcd.print(mill_tmp / 1000);

        //				Serial.print(F("Error            [mK]: "));
        //				Serial.println(SMT172::getError() * 1000, 2);
        //				Serial.println();
        break;
      case 2: Serial.println(F("**** Sensor disconnected ****"));
        Serial.println();
    }
//    delay(500);
  }
}