Lm35 DZ and arduino

Hi,

I'm interested in what signal the arduino is recieving from a LM35 temperatue sensor. I have 3 on an arduino all displaying the same temperature within 1 degree of each other. I built the project for a kiln and when fitting into the kiln the thermometer cables were taped to a piece of celetex (metal foil coats the celetex) and I started to get large temperature jumps and decreases. I have untaped and temperatues go back to normal.

Is the arduino receiving a resistant and the foil is having an impact? Should I use more expensive/reliable temperature sensors, if so what? Or should I be using better quality shielded cabling for the sensors?

Appreciate any insight anyone might have.

const int LM35Pin0 = A0;
const int LM35Pin1 = A1;
const int LM35Pin2 = A2;

analogReference(INTERNAL);

  temperature0 = analogRead(LM35Pin0) * 0.1039;
  temperature1 = analogRead(LM35Pin1) * 0.1039;
  temperature2 = analogRead(LM35Pin2) * 0.1039;

  • How did you insulate the component to wire connections ?

Soldered sensor to cable and heat shrinked each pin along with a larger heat shrink over all 3 heat shrinked pins. Onto the arduino I used a screw terminal block shield.

Spend a moment and be sure everything is compatible with the Kiln temperatures such as the heat shrink, wire, and the LM35.

2 Likes

kiln is off at the moment, temperature is 15 degrees, temps are fluctuating between 9 and 22. Cables arent overly long only about 5m

From a LM35 datasheet:
Rated for Full −55°C to 150°C Range
Your kiln isn't getting any hotter than that, is it?

2 Likes

I think of kilns as reaching several hundred degrees or higher. If that is what you have you will be limited to a thermocouple or platinum resistive sensor for that range of temperature.

1 Like

Using the internal reference, the maximum temp measurable will be 103.9 degrees. What is your kiln temperature?

Did the sensor contacts short out against the metal foil, perhaps?

That's more than "expected".

I'm inclined to agree that there's probably some kind of wiring issue (opens, shorts, intermittent connections).

Make sure your power supply is "solid". Any noise or variation from the power supply can be reflected in the analog readings.

That should be OK, but capacitors between the analog inputs and ground (maybe 0.1uF) will help to filter any noise pick-up.

You can also use smoothing to average-out the readings.

...Or maybe you burned-up the sensors in your kiln?

.

Thanks for the replies. Won't get hotter than 100 degrees. I've just taken the readings 64 times and created an average before recording the temp. That seems to have stabilised it, odd that it wasn't doing it on the desk but doesn't seem to be related to the celetex.

Thanks for the detailed reply. I could fit a choke to the power supply and the sensors to try and filter out some noise?

Post your latest code.

#define BLYNK_TEMPLATE_ID "x"
#define BLYNK_TEMPLATE_NAME "Kiln"
#define BLYNK_AUTH_TOKEN "x"
#define BLYNK_PRINT Serial

#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
BlynkTimer timer;


char auth [] = BLYNK_AUTH_TOKEN;

//pins:

// Define the analogue pin used to read the temperature sensor (A0) */
const int LM35Pin0 = A0;
const int LM35Pin1 = A1;
const int LM35Pin2 = A2;


//////////////////


// initialize the library with the numbers of the interface pins
LiquidCrystal_I2C lcd(0x27, 16, 2);


////////////////

//temp 0 = right hand side of kiln, temp 1 = center, temp 2 = left
float temperature0;
float temperature1;
float temperature2;

int lightonetemp;
int lighttwotemp;
int lightthreetemp;
int maxtemp;
int maxtempreached = 0;
int maxtempvariable;
int maxtempalert;
int powertoggle = 0;
int light = 0;
int alreadyalerted = 0;



/////////////////////////

//ethernet setup
IPAddress ip(192, 168, 1, 160);
IPAddress dns(192, 168, 1, 254);
IPAddress gateway(192, 168, 1, 254);
IPAddress subnet(255, 255, 255, 0);


/////////////////////////

BLYNK_CONNECTED()
{
  Blynk.syncVirtual(V1);
  Blynk.syncVirtual(V2);
  Blynk.syncVirtual(V3);
  Blynk.syncVirtual(V4);
  Blynk.syncVirtual(V5);
  Blynk.syncVirtual(V6);
  Blynk.syncVirtual(V7);
  Blynk.syncVirtual(V9);
}



BLYNK_WRITE(1)

{ if ( param.asInt() == 0 )

  {
    digitalWrite(5, HIGH); //right socket

  }
  else
  {
    digitalWrite(5, LOW);

  }
}

BLYNK_WRITE(2)

{ if ( param.asInt() == 0 )

  {
    digitalWrite(2, HIGH); //middle socket

  }
  else
  {
    digitalWrite(2, LOW);

  }
}

BLYNK_WRITE(3)

{ if ( param.asInt() == 0 )

  {
    digitalWrite(3, HIGH); //left socket

  }
  else
  {
    digitalWrite(3, LOW);

  }
}

BLYNK_WRITE(9)

{ if ( param.asInt() == 1 )

  {
    powertoggle = 0;


  }
  else
  {
    powertoggle = 1;
    Blynk.virtualWrite(V8, "Kiln Off");
    Blynk.virtualWrite(V1, 0);
    Blynk.virtualWrite(V2, 0);
    Blynk.virtualWrite(V3, 0);
    digitalWrite(5, HIGH);
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);


  }
}

BLYNK_WRITE(10)

{ 
  if ( param.asInt() == 1 )

  {
    light = 0;
    maxtempreached = 0;
    alreadyalerted = 0;
    Blynk.virtualWrite(V8, "Reset Temps"); //info box
    Blynk.virtualWrite(V1, 0);
    Blynk.virtualWrite(V2, 0);
    Blynk.virtualWrite(V3, 0);
    digitalWrite(5, HIGH);
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);

  }

}

BLYNK_WRITE(V4) //temp to turn light one on
{
  lightonetemp = param.asInt(); // Get value as integer
}

BLYNK_WRITE(V5) //temp to turn light one on
{
  lighttwotemp = param.asInt(); // Get value as integer
}

BLYNK_WRITE(V6) //temp to turn light one on
{
  lightthreetemp = param.asInt(); // Get value as integer
}

BLYNK_WRITE(V7) //temp to turn lights off
{
  maxtemp = param.asInt(); // Get value as integer
}

/////////////////////////


void setup()
{
  Serial.begin(9600);
  delay(10);

  pinMode(5, OUTPUT); //right hand socket
  pinMode(2, OUTPUT); //middle socket
  pinMode(3, OUTPUT); //left socket


  analogReference(INTERNAL);


  Ethernet.begin(ip, dns, gateway, subnet);
  Blynk.begin(auth, "blynk.cloud", 8080);

  timer.setTimeout(3600000L, [] () {} ); // dummy/sacrificial Function timers with ID 0 cannot be turned on/off
  timer.setInterval(10000, UpdateTemp); // Miliseconds to seconds


  //LCD setup
  lcd.init();  //initialize the lcd
  lcd.backlight();  //open the backlight

    Blynk.virtualWrite(V8, "Waiting Light one Temp");
    Blynk.virtualWrite(V1, 0);
    Blynk.virtualWrite(V2, 0);
    Blynk.virtualWrite(V3, 0);

    digitalWrite(5, HIGH); //sockets off
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);

}

void loop()
{
  Blynk.run();
  timer.run();
}


void UpdateTemp()
{


  maxtempvariable = maxtemp - 2;
  maxtempalert = maxtemp + 3;

  // Read the analog value from the LM35 sensor

  temperature0 = analogRead(LM35Pin0) * 0.1039; //throw away, I don't believe this is required but just incase it helps make a difference smoothing results between different analogue pins

  for (int x = 0; x < 64; x++) // 64(max) analogue readings for averaging
  {
    temperature0 = temperature0 + analogRead(LM35Pin0); // add each value
  }

  temperature1 = analogRead(LM35Pin1) * 0.1039; //throw away

  for (int x = 0; x < 64; x++)
  {
    temperature1 = temperature1 + analogRead(LM35Pin1);
  }

  temperature2 = analogRead(LM35Pin2) * 0.1039; //throw away

  for (int x = 0; x < 64; x++)
  {
    temperature2 = temperature2 + analogRead(LM35Pin2);
  }


    temperature0 = temperature0 * 0.1039 / 64; //calibration to degress c divide by number of readings
    temperature1 = temperature1 * 0.1039 / 64;
    temperature2 = temperature2 * 0.1039 / 64;


  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print(("Center Temp:") + String(temperature1) + ("C"));
  lcd.setCursor(0, 1);
  lcd.print(("Left Temp:") + String(temperature2) + ("C"));

  Blynk.virtualWrite(V20, temperature0);
  Blynk.virtualWrite(V21, temperature1);
  Blynk.virtualWrite(V22, temperature2);


  if (powertoggle == 0)
  {
    if (temperature2 > lightonetemp && maxtempreached == 0 && light == 0)
    {
      light = 1;
      digitalWrite(3, LOW); //left socket on
      Blynk.virtualWrite(V8, "Light 1 on"); //info box
      Blynk.virtualWrite(V3, 1);
    }

    if (temperature2 > lighttwotemp && maxtempreached == 0 && light == 1)
    {
      light = 2;
      digitalWrite(2, LOW); //middle socket on
      Blynk.virtualWrite(V8, "Light 1 and 2 on");
      Blynk.virtualWrite(V2, 1);
      Blynk.logEvent("update", "Light 2 is now on!");
    }

    if (temperature2 > lightthreetemp && maxtempreached == 0 && light == 2)
    {
      light = 3;
      digitalWrite(5, LOW); //right socket on
      Blynk.virtualWrite(V8, "Light 1, 2 and 3 on");
      Blynk.virtualWrite(V1, 1);
      Blynk.logEvent("update", "Light 3 is now on!");
    }

    if (temperature2 > maxtemp)
    {
      maxtempreached = 1;
      digitalWrite(5, HIGH);
      digitalWrite(2, HIGH);
      digitalWrite(3, HIGH);
      Blynk.virtualWrite(V8, "Max Temp reached, idling");
      Blynk.virtualWrite(V1, 0);
      Blynk.virtualWrite(V2, 0);
      Blynk.virtualWrite(V3, 0);
      
      if (alreadyalerted == 0)
      {
        Blynk.logEvent("update", "Kiln has reaced max Temperature! Record the time");
        alreadyalerted = 1;
      }
    }

    if (temperature2 < maxtempvariable && maxtempreached == 1)

    {
      digitalWrite(5, LOW);
      digitalWrite(2, LOW);
      digitalWrite(3, LOW);
      Blynk.virtualWrite(V8, "Reheating to max temp");
      Blynk.virtualWrite(V1, 1);
      Blynk.virtualWrite(V2, 1);
      Blynk.virtualWrite(V3, 1);
    }



  }

  if (temperature0 > maxtempalert)
  {
    Blynk.logEvent("update", "Kiln Temp 0 too Hot!");
  }

  if (temperature1 > maxtempalert)
  {
    Blynk.logEvent("update", "Kiln Temp 1 too Hot!");
  }

  if (temperature2 > maxtempalert)
  {
    Blynk.logEvent("update", "Kiln Temp 2 too Hot!");
  }


}

Hi, @Breazle

I assume it is an electric kiln, if you remove power from the kiln, does the noise problem disappear?

Tom... :smiley: :+1: :coffee: :australia:

When I started to see the fluctuations the kiln was off. I have added chokes to the sensor cables and will add one to the transformer for good measure. Since I've added the 64 times smoothing the problem seems to have been averaged out and now not visible. I'll take a laptop up tomorrow and get the 64 readings to see how many of the 64 are wrong and see if it was only the first reading that was wrong to see if the first reading dump I put in helped at all.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.