Interface LM35 temperature sensor

Solving Approach:

How do you plan to solve it?

  • Add voltage divider circuit on ground to shift the ground voltage
  • compensate the voltage shift in calculation

 

Code

/*Paste your code here*/
const int lm35_pin = A0;   /* LM35 O/P pin */
const int offset_pin = A1; /* LM35 GND pin */
float offset_voltage = 0;  /* offset voltage stored in milli-volts */

int temp_adc_val;
float temp_val;

void setup() {
  Serial.begin(9600);
}

void loop() {
  temp_adc_val = analogRead(lm35_pin);
  offset_voltage = analogRead(offset_pin) * (5000 / 1024); /* read offset voltage on A1 pin and convert it to milli-volts */

  temp_val = temp_adc_val * (5000 / 1024); /* Convert adc value to equivalent voltage (milli-volts) */
  temp_val = temp_val - offset_voltage;    /* remove the offset voltage */
  temp_val = (temp_val / 10);              /* LM35 gives output of 10mv/°C */

  Serial.print("Temperature = "); /* Print the temprature*/
  Serial.print(temp_val);
  Serial.println(" Degree Celsius");
  delay(1000);
}


 

Output

Video

Add video of output (know more)

 

 

 

 

 

Photo of Output

Add a photo of your hardware showing the output.

 

 

 

 

Upvote
Downvote

Submit Your Solution

Note: Once submitted, your solution goes public, helping others learn from your approach!