Indian_villager 0 Posted November 2, 2012 Share Posted November 2, 2012 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 Quote Link to post Share on other sites
Rei Vilo 695 Posted November 2, 2012 Share Posted November 2, 2012 There is an interesting tutorial about the LM35 and related formulas and problems at http://learn.adafrui...perature-sensor Quote Link to post Share on other sites
Indian_villager 0 Posted November 3, 2012 Author Share Posted November 3, 2012 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 Quote Link to post Share on other sites
calinp 24 Posted November 3, 2012 Share Posted November 3, 2012 For analogread use the analog input number: 6 is the same as A6, but is on pin 14, not 6. Quote Link to post Share on other sites
Indian_villager 0 Posted November 5, 2012 Author Share Posted November 5, 2012 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 Quote Link to post Share on other sites
Rei Vilo 695 Posted November 5, 2012 Share Posted November 5, 2012 For the mapping of the pins, see the hi-res pictures at https://github.com/energia/Energia/wiki/Hardware Each picture takes into account the MSP430 model and the revision of the board, 1.4 or 1.5. I hope this could help you. Quote Link to post Share on other sites
Indian_villager 0 Posted November 5, 2012 Author Share Posted November 5, 2012 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. Regards, Alex J Quote Link to post Share on other sites
cde 334 Posted November 5, 2012 Share Posted November 5, 2012 It does not have the usci uart/spi/i2c, it has a usi spi/i2c. Energia compiles a software uart for it instead (using a timer). Quote Link to post Share on other sites
Indian_villager 0 Posted November 5, 2012 Author Share Posted November 5, 2012 .....Well then. I am at a loss. Quote Link to post Share on other sites
traxman 23 Posted November 6, 2012 Share Posted November 6, 2012 ...The LM35 needs a minimum of 4V so I dont think the rail is waking it up. Try LM61, pinout is identical, but LM61 works with lower supply > 2,7V Quote Link to post Share on other sites
calinp 24 Posted November 6, 2012 Share Posted November 6, 2012 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). Quote Link to post Share on other sites
Rei Vilo 695 Posted November 6, 2012 Share Posted November 6, 2012 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 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.