Example Projects

LM335A Temperature Sensor for Arduino


I was looking for an easy to use temperature sensor for the Attiny85. After doing a lot of searching for a suitable temperature sensor I stumbled upon the LM335A. It's very old-school, and produces 10mV for each degree Kelvin. Here's a closeup photo of the board that I made along with a brief schematic.

Shown on the Arduino is the clixx.io Dock. It's basically an Arduino shield with most of the common configurations broken out into a more useable arrangement. The rightmost connector where the temperature sensor board is plugged in directly corresponds to Analog-Pin-1. The LM335A simply connects in to where the Analag-1 Pin is.

As I didn't really have a board made, of course I took another board and set about to get the LM335A working on that. This was just an experiment to get the basic circuit working and test some software against it. If it all works then of course I will go into Fritzing and design up a proper working production design.

The circuit that I found on the Internet was pretty basic. Just a pullup resistor to VCC. Although the circuit doesn't show it, when I was testing I found that the output signal wasn't stable so I added a 10uF decoupling capacitor to the power pins and that worked incredibly well to stabilise the output.


What is particularly good about the LM335A is that it outputs a predictable analog signal which is ideal for picking up from an Arduino or any other microprocessor with an analog port.

Inside the Arduino examples there is a very handy script called AnalogToSerial.ino. It's very handy for downloading to the Arduino to see the Analog value on the Serial Port. I did some slight modifications to remove the translation so that it outputs only the exact ADC value that it finds on the port.

Here's the code:

void loop() {
  // read the analog in value:
  sensorValue = analogRead(analogInPin);            
  // change the analog out value:
  analogWrite(analogOutPin, outputValue);           

  // print the results to the serial monitor:
  if (sensorValue !=0){
    Serial.print("sensor = " );                       

  // wait 2 milliseconds before the next loop
  // for the analog-to-digital converter to settle
  // after the last reading:

Once the program is compiled and running, the sensor outputs an analog value (a voltage) which is read by the ADC and sent to the PC. The built-in terminal software inside the Arduino IDE then prints these values.


Of course, we don't have our values in Degree's yet so we need to do a conversion.

Whilst sometimes it might seem that clixx.io is some type of proprietary system it's actually not. It's very easy to go on the internet, find a sketch, download it and run on standard Arduino hardware through the standard Arduino IDE.

The Arduino Forum has a great post Library for LM335A Temperature Sensor and I downloaded that. Here is a snippet of the program where the majority of the work is done:

void setup() {
  LM335A InsideTemp(0); //pass the analog input pin number
  void setup() {

void loop() {
  //user must call ReadTemp before any valid temp data is available
  Serial.print("Fahrenheit: ");
  //functions to get the temperature in various unitsfs
  Serial.print("Celsius: ");
  Serial.print("Kelvin: ");


After compiling and uploading that, I get the following on my debug window:


It seemed to work pretty well. I measured the temperature using a handheld thermometer and the results seemed to match to within error tolerances.

Check Temp