Jump to content
Indian_villager

LM35 on the energia.

Recommended Posts

Hey all,

 

I'm relatively new to all this and I have been trying to get a temperature sensor to work with the launchpad. As in my previous posts I was trying for the DS18b20. I have the port of the code project on the back burner because there is a hell of a lot I need to learn to be able to port that over.

 

So just to get something off the ground I have been trying to use the LM35 to read some temps.

 

Here is the code I'm running

 

float tempC;

float tempF;

 

void setup()

{

Serial.begin(9600);

}

 

void loop()

{

tempC = analogRead(6); //read the value from the sensor hooked up to pin 6

tempC = (3.3 * tempC * 100.0)/1024.0; //convert the analog data to temperature (Assuming 10bit ADC and 3.3v ref voltage

I suspect this is where I'm screwing up)

tempF = ((9.0*tempC)/5.0)+32.0;

Serial.println(tempC);

Serial.println("");

Serial.println(tempF);

Serial.println("");

delay(1000);

}

 

The issue is that It is showing very high values. Like the order of 178 c?

I also tried chaning the tempC calculation to

 

tempC = (tempC*100.0)/1024.0

 

It gets closer but still not quite.

 

(I'm monitoring through the serial monitor and I have not made any changes to the jumper position to my 1.4 board)

 

 

Any and all help is appreciated.

 

 

Regards,

Alex

Share this post


Link to post
Share on other sites

So here is something screwy.

 

When I try to use pins 4 or 5 as the input i see random outputs

 

when I use 15 or 14 the temp read 0C or 32F...... I have no idea what is going on. I checked my lines and I dont have anything shorted.

 

FYI I am using a MSP430G2452

 

Regards,

 

Alex J

Share this post


Link to post
Share on other sites

After a bit of digging I have found 2 issues.

 

The LM35 needs a minimum of 4V so I dont think the rail is waking it up.

 

Also the chip I have does not have a proper Hardware UART setup, so I think I am going to have to switch up to a the G2553. Any thoughts?

 

Ref:

https://github.com/energia/Energia/wiki/Serial-Communication#wiki-Hardware_UART_on_Launchpad_14

 

Regards,

 

Alex J

Share this post


Link to post
Share on other sites

Is your temperature reading improved if you connect LM35 to the phisical pin 2 and read it with analogread(A0)?

You can supply the sensor with 5V from TP1(USB 5V) and TP3(GND).

Share this post


Link to post
Share on other sites

I've already seen that and it is what I have been using, what I think the issue is, is that the G2452 does not have an onboard UART. I am hoping that someone can confirm or deny.

 

That's correct. The serial port is managed by the software UART TimerSerial library. See an example at https://github.com/energia/Energia/blob/master/examples/4.Communication/Serial_430/Serial_430.ino

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...