LM35 Issue

Hi, I'm developing a project for the school with Arduino Uno.
I have several connected sensors including a servo motor, a temperature sensor (LM35) and a water level sensor. Also I connected an I2C LCD and several status LEDs.
Testing all the components individually works properly, but when I put it all together, problems arise.
I use a 12 Volt 2 A DC power supply for Arduino and to power the components, I use GND of Arduino and +5 volts of an ATX power supply of a PC.

The LM35 sensor can not give the exact temperature when I immerse the water level sensor. For example, if the ambient temperature is 18 ° C, when I immerse the water level sensor, the temperature rises to 40-50 ° C.

What could be the problem?

Please provide a diagram of how everything is connected and powered (particularly all the ground connections) and post the code you're using, as described in "How to use this forum - please read" which you can find at the top of every forum.

Just guessing about a problem with an LM35 and a "water level sensor" of unknown type apparently connected to 12V and 5V is a bit tricky.

Steve

Sorry for that, this is the Water Sensor that I use (I can't find its name)


All components are connected to +5V.
I paste the code and the diagram as soon possible.
Thanks.

Here is the Code and the diagram:

// Include Inseguitore
#include <Servo.h>
// Include Sensore Acqua e Display
#include <Wire.h>
#include <LiquidCrystal_I2C.h> // libreria di gestione display lcd
// Include Bluetooth
#include <SoftwareSerial.h>
// Define Bluetooth
#define RXD 0
#define TXD 1
SoftwareSerial bt (RXD, TXD); //TXD 0, RXD 1 
#define RELE 2 // PIN RELE VENTOLA
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // tipologia del display // addr en,rw,rs,d4,d5,d6,d7,bl,blpol LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
// VARIABILI
int livello = 0; // variabile di memorizzazione del livello dell'acqua
int valoremin = 500; // variabile in cui viene memorizzato il valore minimo rilevabile dal sensore (definito sperimentalmente, con la bacinella vuota)
int valoremax = 700; // variabile in cui viene memorizzato il valore massimo rilevabile dal sensore (definito sperimentalmente, con la bacinella piena di acqua)
int i = 0; // indice utilizzato nel ciclo for per lo spegnimento preventivo dei led
// PIN INSEGUITORE
int sensorPin = A0;
int servoPin = 5;
// VARABILI INSEGUITORE
int sensorValue = 0;
int servoGrad = 90;
int tolleranza = 40;
Servo myservo;

void setup()
{
  // Inizializzazione Monitor Seriale
  Serial.begin(9600);
 // analogReference(EXTERNAL);
  // Inizializzazione Display
  lcd.begin(16, 2); // 16 Caratteri, 2 Righe
  for (int i = 0; i < 3; i++) // Accende l'illuminazione e fa lampeggiare 3 volte lo schermo
  {
    lcd.backlight();
    delay(250);
    lcd.noBacklight();
    delay(250);
  }
  lcd.backlight(); // Termina lo show mantenendo illuminato lo sfondo
  // PinMode
  pinMode(RELE, OUTPUT); // RELE Ventola
  pinMode (10, OUTPUT); // led verde collegato alla porta 9
  pinMode (11, OUTPUT); // led verde collegato alla porta 10
  pinMode (12, OUTPUT); // led giallo collegato alla porta 11
  pinMode (13, OUTPUT); // led rosso collegato alla porta 12
  digitalWrite (13, HIGH); // accende la spia rossa di livello basso (rimane sempre accesa) livello acqua <20%
  pinMode(4, OUTPUT);
  pinMode(6, OUTPUT);
  //pinMode(RXD, INPUT); // Non usarlo
  //pinMode(TXD, OUTPUT); // Non usarlo
  // Inizializzazione Bluetooth
  Serial.println("Bluetooth Connesso");
  bt.begin(9600); // Bluetooth Connected
  // INSEGUITORE
  pinMode(sensorPin,INPUT);
  myservo.attach(servoPin);
  myservo.write(servoGrad);
  // INSEGUITORE
}
void loop()
{
  // TEMPERATURA
  int aRead = 0;
  aRead = analogRead(1);
  delay(1000);
  int temperatura = aRead * 0.48875;
 
  Serial.print("Temperatura = ");
  Serial.print(aRead);
  Serial.print(" - ");
  Serial.print(temperatura);
  Serial.println("C" );
  
  delay(500);
  if(temperatura > 40)
  {
    digitalWrite(RELE, HIGH);
  }
  else
  {
    digitalWrite(RELE, LOW);
  }
  // TEMPERATURA
  // SENSORE ACQUA
  livello = analogRead (2); //acquisisce il segnale dal sensore livello acqua sull'analogico A2
  delay(500);
  Serial.print ("Livello = ");
  Serial.print (livello);
  if (livello < 500) // se il segnale e’ sotto il minimo
    livello = 500; // lo porta al minimo
  if (livello > 700) // se il segnale e’ sopra il massimo
    livello = 700; // lo riporta al massimo
  livello = map(livello, valoremin, valoremax, 0, 100); // Remap livello con scala 0 - 100
  Serial.print (" - ");
  Serial.print(livello); // espone sul monitor seriale la % di riempimento
  Serial.println ("%");
  lcd.clear ();
  lcd.setCursor(0, 0); // posiziona il cursore all'inizio della prima riga
  lcd.print ("Livello: ");
  lcd.print (livello); // espone il livello sul display lcd
  lcd.print ("%");
  lcd.setCursor(0, 1);
  lcd.print ("Temperatura:");
  lcd.print(temperatura);
  lcd.print ((char)223);
  lcd.print ("C");
  for (i = 10; i <= 12; i ++)
    digitalWrite (i, LOW); // Spegne preventivamente i led giallo e verdi
  if (livello > 20)
    digitalWrite (12, HIGH); // se il livello e' piu' del 20% accende la spia gialla (LIVELLO Medio/BASSO)
  if (livello > 50)
    digitalWrite (11, HIGH); // se il livello e' piu' del 50% accende la prima spia verde (Livello MEDIO/ALTO)
  if (livello > 80)
    digitalWrite (10, HIGH); // se il livello e' piu' del 80% accende la seconda spia verde (Livello ALTO)
  delay (1250); // attende circa un secondo prima di effettuare una nuova rilevazione
  // SENSORE ACQUA
  // BLUETOOTH
while(bt.available())
{
  char info = bt.read();
  switch(info)
  {
    case 'I':
  {
   digitalWrite(4, HIGH); // RELE' LUCI INTERNE
   Serial.print("INFO: ");
   Serial.println("LUCI INTERNE ON");
   break;
  }
  case 'i':
   {
    digitalWrite(4, LOW);
    Serial.print("INFO: ");
    Serial.println("LUCI INTERNE OFF");
    break;
   }
    case 'E':
  {
   digitalWrite(6, HIGH); // RELE' LUCI ESTERNE
   Serial.print("INFO: ");
   Serial.println("LUCI ESTERNE ON");
   break;
  }
  case 'e':
   {
    digitalWrite(6, LOW); 
    Serial.print("INFO: ");
    Serial.println("LUCI ESTERNE OFF");
    break;
   }
  }
}
// BLUETOOTH
// INSEGUITORE
  sensorValue = analogRead(sensorPin);
  if(sensorValue < (512-tolleranza))
  {
    if(servoGrad < 180) servoGrad++;
  }
  if(sensorValue > (512+tolleranza))
  {
    if(servoGrad > 0) servoGrad--;
  }
  myservo.write(servoGrad);
  // INSEGUITORE
}

Hi,
I've had a quite similar problem using a "pro mini" (chip is the same). It has to do with the output impedance of the sensors: it should not excess 10 kOhm (desirably 5 kOhm). Otherwise, not only the AX to which the -defective- sensor is attached, but all of the other analog inputs started to give wrong readouts.
If the water level sensor is causing the problem, the academic advice is to connect it through an impedance adapter. I'd rather look for a different one (sensor).
Any case, you have to determine if the level sensor is causing your problem (The LM35 is correct). Perhaps trying with a potentiometer to test ...
A 100 nF in every analog input will help too (and a 4,7 kOhm resistor forming a RC filter).
Saluti

When I put a resistor in series with one led, the sensor can't show the correct temp, I would not want it to be a problem related to the current.

For the LM35, use the more stable internal reference for the analog port - more details here. This will improve resolution and overall stability a lot.

There's a chance your water sensor messes up the readings by affecting Vcc, though this shouldn't happen if used correctly. Do mind that you should not leave this sensor powered on - best to completely disconnect it when not in use, as otherwise it will corrode away within weeks as the copper is in contact with the water.

Another potential issue with this water sensor is ground loops as you make direct contact with the water. I don't know if the LM35 is susceptible to this.

I see you try to do an analog reading on that sensor: this won't work reliably. A small change in the mineral content of your water will totally mess up your level readings. It's only really suitable for digital (water/no water) readings.

Other than that no obvious issues.

OP's circuit diagram:

I added the internal reference and used a 100nF capacitor between the Analog pin and the ground but didn't work.
Someone can help me?

Please explain "didn't work" in detail.

wvmarle:
Please explain "didn't work" in detail.

There is no change, the values found are always wrong

How does the new circuit look like exactly?

Did you remember to change the calculation of the temperature?

What are the actual values the analogRead() call returns?

Are the values consistently wrong (a certain amount too high/too low) or all over the place? The internal reference has a tolerance of +-10%.

Thanks to all, I resolved my problem putting a 100nF capacitor between GND and LM35 Analog Signal, then I modified some values in the sketch and I also added a diode in the LM35.

Hi, I am in the same situation but I'm new with electronic components. Could you specify which diode you used? And in what position did you put it? I attach a fritzing pic which I presume it's not right.
Thanks!