Jump to content
43oh

Internal temperature and state of LED?


Recommended Posts

Hi there, I'm trying to get an internal temperature reading using the follow code

 

float temp = 0;

void setup() {
 Serial.begin(9600);
 Serial.println("Temperature:");  
}

void loop() {
 temp = analogRead(TEMPSENSOR);
 Serial.println(temp);
 delay(200);
}

And my reading is:

 

Temperature:

322.00

324.00

323.00

323.00

323.00

324.00

 

What is this? How do I convert these numbers to celsius?

 

And also, every time I try finding the brightness of my LED, it always returns nothing

 

int BrightnessVal = digitalRead(GREEN_LED);
Serial.println("Green LED brightness: " + BrightnessVal); 

 

Thanks

Link to post
Share on other sites

Do you know the temperature of your room? If those readings were in tenths of a degree (e.g. 322 = 32.2C), and there was a small calibration bias in the sensor, then they seem perfectly reasonable. No clue if that's what is going on, but you could test it out by putting it in the freezer for a minute or two.

Link to post
Share on other sites

Floats should be avoided if possible. Since the MSP430 does not have a floating point unit it need to "emulate" one which makes it very slow. The "emulation" code is about 4k. Rei Vilo has put together an excellent example for how to read the temp sensor.

https://github.com/energia/Energia/blob ... er_430.ino

 

Bare in mind that the temp sensor is not calibrated and might be of a bit.

 

Robert

Link to post
Share on other sites

Temperature offset error is not just a bit as I stated in the previous post. It can be significant as per MSP430x2xx user manual:

The temperature sensor offset error is large. Deriving absolute temperature values in the application requires calibration. See the device-specific data sheet for the parameters."

 

Quickest way to calibrate would be to measure your room temperature with an accurate temperature measurement device or estimate it. Then let the LaunchPad sit there running the temp sense demo for a bit. At the end of that period take average value displayed in the serial console, subtract the actual room temperature and use that as the offset in the Sketch.

 

Robert

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...