LM35DZ unstable readings via PowerSupp and perfectly stable via PC usb

Hello, i have arduino mega 2560 working with 3.2" LCD connected on the TFT shield and 1 LM35DZ temperature sensor on analog pin . Everything is great when this setup is connected via PC usb. Readings is stable with oscillations 0.1 degrees C if - middle value of 120+ readings. When i connect it to the power supply 12VDC 3A (http://www.ebay.com/itm/AC-110V-220V-TO-DC-5V-12V-24V-Switch-Power-Supply-Driver-Adapter-LED-Strip-Light-/152134115704?var=&hash=item236be66178:m:mnohYz4NZlT_Dq5l5lWNUMg) it give oscillations of +/- 2 degrees C with middle value of 120+ readings! Than if i feed it to the same power supply brand- but weaker - of 12VDC 2A the oscillations raises more. This became problem after a while (few months of usage), the other weaker power supply is brand new. Again, on pc usb powering mode it is perfect. I tried to power it from different safety fuse (is that the word?, wall jack on different fuse), tried to solder new LM35DZ- some very very little improvements.

It would be ideal if i can get hands on a power supply that is same as usb on pc. This was powered with laptops usb so maybe to use laptop adapter and its battery but a cheaper version? also there is maybe more than only this 2 things in the whole picture? (some filters on motherboard, regulations or something else?) Or maybe ATX power supply with rectifier diodes but little smaller? Or even 2 mobile phone batteries in series for 2x4V and than those 2 batteries always connected to the battery charger?

I can provide pictures and more info if needed.

How far away is the power supply from the cable with the analog signal? Analog signals easily get induced noise signals. Ultra-cheap power supplies ($2.45 for a 25W power supply is more than ultra-cheap) tend to send out a lot noise signals so you should keep the analog signal wires as far way from the power supply as possible. I guess you can reduce the measurement error by reading the analog value many times in a fast repetition and build the average of all measurements By averaging the noise signal you eliminate much of it (usually). If you want a stable signal with your power supply change the temperature sensor to a digital variant (p.e. DS18b20), these are quite immune to such noise signals.

Thank you! Do you know maybe if PT100 (+ arduino interface for it) is immune to such noise signals? The power supply is very near, i also have meanwell APV 12-12 (around 10$ for 12W in my local store) any experience with those?

If nothing, i will try this sensor but its range is to +125 degrees C, while it would be perfect if i have +135 degrees C since this setup is used in some kind of oven that once in a year works at 130 degrees C (+/- 2'C of the heat inertia) for a few hours so it has to have that capabilities. Thanks again pylon.

As you didn't provide a link to your PT100 I tell you the result of a google search: No, that's just another resistive temperature sensor that will give you an analog signal. The wires between the sensor and the Arduino pick up that noise not the sensor itself. Either take a sensor with a digital interface or remove the noise source.

If you measure the oven temperature a temperature accuracy of +/-2°C is a problem?

The ADT7311 (http://www.analog.com/en/products/analog-to-digital-converters/integrated-special-purpose-converters/digital-temperature-sensors/adt7311.html#product-overview) has an I2C interface and measures up to 150°C.

You must use 2.56volt Aref with an LM35DZ (and a Mega). Then your measurements should become stable and independent of the supply. Post your code if you want help with that. Leo..

This is the link of pt100 + interface idea (PT100 and PT1000 Breakout Board with MAX31865 – Charles's Blog), the price is about 15$ for the interface on ebay. I honestly do not have good experience with max31865 module.

“If you measure the oven temperature a temperature accuracy of +/-2°C is a problem?”

yes because:

  1. it was +/- 0.3 °C when brand new, now it raises to +/- 2°C → that is in both + and - every second so its actually 4°C difference AND with 120 readings per sec which effects the timer by few sec per minute (CountUpDownTimer.h), later who knows
  2. the relay turns the heaters on/off on 1.5°C difference for the better accuracy because it sometimes works on low as 20°C and the product is better quality if temperature curve is followed more precisely
  3. the contactors have set amount of closings (2-3 milion) before they become garbage (it is much before if closings are made in time period less than few seconds) and they are not cheap!

I will look into ADT7311 - again, thank you pylon!

Wawa:
You must use 2.56volt Aref with an LM35DZ (and a Mega).
Then your measurements should become stable and independent of the supply.
Post your code if you want help with that.
Leo…

the code is simple:

float measureTemp()
{
  float Temp=0, analogTemp=0;
  for(int z=0; z<1000; z++)
  {
    analogTemp=analogRead(A8);
    analogTemp=(analogTemp/1023.0)*5000.0;
    analogTemp=analogTemp*0.1;
    Temp=Temp+analogTemp;                  //this code can be shorten?
  }
  Temp=Temp/1000.0;
  return Temp;
}

//This is edited code for higher precision after the incident, i want to aim at <50 readings per sec
....     // code where this function is called optionally

RajoAlfa:
the code is simple:

And wrong.
That (partial) sketch seems to use default Aref, which is potentially unstable.
A bit of averaging is ok, but 1000 analogue reads is not going to do any better.

You normally would use 1.1volt Aref to get the highest resolution (most A/D values),
but that limits temp readout to 100C.
This sketch uses the 2.56volt Aref (Mega only) that has a theoretical limit with an LM35 of 256C.
The sensor however shouldn’t be used above ~150C.

Make sure the sensor gets it’s own (not shared) direct ground to the Mega.

Try this (untested).
Leo…

// LM35 temp sensor connected A8

unsigned int total; // A/D readings
float tempC; // Celcius
float tempF; // Fahrenheit

void setup() {
  analogReference(INTERNAL2V56); // use the internal 2.56volt reference of a Mega
  Serial.begin(9600);
}

void loop() {
  // read the sensor
  for (int x = 0; x < 64; x++) { // 64(max) analogue readings for averaging
    total = total + analogRead(A8); // add each value
  }
  // temp conversion
  tempC = total / 256.0; // Calibrate here
  tempF = tempC * 1.8 + 32; // Celcius to Fahrenheit

  Serial.print("The temperature is  ");
  Serial.print(tempC, 1); // one decimal place
  Serial.print(" Celcius  ");
  Serial.print(tempF, 0); // no decimal places
  Serial.println(" Fahrenheit");

  total = 0; // reset total
  delay(1000); // slows readings | remove in final code
}

Wawa:
Make sure the sensor gets it’s own (not shared) direct ground to the Mega.

you mean his own ground from power supply 12V that power the arduino?

what does (analogReference(INTERNAL2V56):wink: do?
note that i have tft lcd connected to the same board with active libraries :

#include <UTFT.h>
#include <URTouch.h>
#include<CountUpDownTimer.h>
#include <UTFT_Geometry.h>
....

what does (analogReference(INTERNAL2V56);) do?

It switches the reference voltage of the internal analog digital converter to the internal reference voltage generator that provides 2.56V. The standard reference is Vcc, on a classic Arduino this is 5V.

I doubt this helps because even if the power supply doesn't give you stable 12V the linear voltage regulator of the Arduino will stabilize this quite smoothly, but it's worth a try as it costs you almost nothing.

you mean his own ground from power supply 12V that power the arduino?

No, this usually means that you provide a direct wire from the sensor to one of the ground pins of the Mega and not connecting other devices to the same wire.

RajoAlfa: what does (analogReference(INTERNAL2V56);) do?

If you had to measure the length of something accurately.. Would you rather use a floppy rubber ruler with an inch scale, or a sturdy metal ruler with a centimeter scale.

Measuring 1volt (an LM35 @ 100C) with 2.56volt Aref will return an A/D value of 1/2.56 * 1024 = 400. Resolution (temp steps) = 100C / 400 A/D values = 0.25C.

If USB suppy is ~4.8volt under load, you will get an A/D value of 1/4.8 * 1024 = 213. If external supply is 5.1volt, you will get 1/5.1 * 1024 = 201. A difference of 12 A/D values. That's six degrees C variation (around 100C) if the supply only varies 0.3volt... Resolution also gets worse with default Aref. Only ~200 values at 100C, so resolution is 100C / ~200 A/D values = 0.5C.

I'm not saying that changing to 2.56volt Aref fixes your problem. But I think you should fix this first, before looking any further. Leo..

Wawa: I'm not saying that changing to 2.56volt Aref fixes your problem. But I think you should fix this first, before looking any further. Leo..

I have just tried this and no significant improvements.

I also have tried to put the power supply to some distance and no improvements either! But the wires that come to power supply (220VAC) and the wires of the sensor touch each other. Those same wires that supply the power supply are drawn from contactor which is near other contactor that does the closings. Can this be the problem?

Yes.