Let's Make Robots!

Sensing temp on picaxe 20x2 with LM335

I just recently purchased a LM335 temperature sensor.

i wired it up to my 20x2 as shown in the datasheet and measured the adc input.

the only data im receiving is a constant 39 on the adc input, any ideas why this isn't working?

and by the way its not 39 degrees as i live in Tasmania. :)


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
What value of resistor did you use for R1 (the resistor feeding the LM335)?
As birdmun has mentioned, you need to compare the voltage from the sensor to the ADC range to get the actual temperature. The value you are reading is 39/255 of the ADC range. According to the PICAXE manuals, the 'readadc' command uses 8bit precision - you can use 'readadc10' for 10bit precision instead, which will give you higher accuracy in reading the temperature.
Also from the PICAXE manuals:
"Using the ‘readadc’ command does not automatically configure the pin as an analogue input. Pins must also be set as inputs (not outputs) for the analogue input to work correctly. The analogue voltage range can be the PICAXE power supply range or an alternate external voltage range."

it looks like the sensor can(?) accept a good deal of input voltage, some of the schematics mention 15v. Another thing, you are working with adc and need it to be compared to the supply voltage. I don't know how PICAXE chips set that up, but, I would think it is worth looking in to to attempt to get good data from the temp sensor.

LM335 sensor circuit

this is my set up on a breadboard, i hope you can understand it.

my code is



readadc c.7,b1


goto main

Yeah, thats even high for Celsius...Take a picture of your setup.