

If you’re using the LM335 sensor, you also need a variable to hold the temperature in Kelvin. Here, we create a temperatureC and a temperatureF variables to hold the temperature in Celsius and Fahrenheit, respectively. Then, create variables that will store the temperature value. The voltageOut variable will store the actual voltage output value coming from the sensor. const int sensorPin = A0 ĭefine a variable that will hold the analog value read from the sensor: float sensorValue We’re using pin A0, but you can use any other analog pin. You start by defining the pin that is connected to the sensor output. temperatureF = (temperatureC * 1.8) + 32 TemperatureF = (temperatureC * 1.8) + 32

calculate temperature for LM35 (LM35DZ) VoltageOut = (sensorValue * 5000) / 1024 This code is also compatible with LM335 and LM34 – you just need to uncomment some lines in the code to use the right sensor. The following code reads the temperature from the LM35 sensor and displays the readings in the Serial Monitor. The LM35 has only three pins, VCC, Vout and GND. You can go to Maker Advisor to find the Temperature sensors’ best price at different stores: In a similar way, the LM335 outputs 10 mV per degrees Kelvin rise in temperature and the LM34 outputs 10 mV per degrees Fahrenheit rise in temperature.įor example, if the LM35 outputs a voltage of 345 mV, that means we have a temperature value of 34.5✬.įor more information about these sensors, you can consult their datasheet: The LM35 outputs 10 mV per degrees Celsius rise in temperature. These sensors work in a similar way, but are calibrated differently to output a voltage proportional to the different temperature units.

Proportional to temperature in Fahrenheit (✯) Proportional to temperature in Kelvin (ºK) Proportional to temperature in Celsius (✬) The LM35, LM335 and LM34 are linear temperature sensors that output a voltage proportional to the temperature value. Introducing LM35, LM335 and LM34 Temperature Sensors
