Hassanul

Problem with analogRead()

8 posts in this topic

Hello,

 

I have the MSP-EXP430FR5969 Wolverine Launchpad (Rev 1.6) and I'm trying to read the voltage output of a LM35 temperature sensor. I went on and used adafruit's code and adapted it to the launchpad. However, I'm not getting the correct voltage values. I verified the sensor is working as I used a multimeter to measure the voltage and it is working.

 

Here's a snippet of the code

 

static uint8_t analogInPin = A7 ;
int sensorValue = 0;       
int voltage = 0;        
int temp = 0;
 
.
.
.
.
.

 

sensorValue = analogRead(analogInPin);

voltage=sensorValue*(3600/1023.0);
  temp=(voltage-500)/10.0;
  // print the results to the serial monitor:
  Serial.print("Voltage = " );                       
  Serial.print(voltage);
  Serial.print("mV \t"); 
   
  Serial.print("Temp = ");  
  Serial.print(temp);
  Serial.print("C \n"); 
 
 
All I'm getting in the serial monitor is 929mV 41 C , but the room temperature isn't 41C and the multimeter shows around 281.7mV
I even tried changing pins and it still doesn't work. Did I just fry the board?
 
Thanks a lot

Share this post


Link to post
Share on other sites

Are you sure adafruit's directions (and formula) are accurate for the LaunchPad? Keep in mind the Wolverine's max ADC voltage is 3.3V (Vcc) and it's a 12-bit ADC if I'm not mistaken. The fact that other pins report the same results makes me skeptical of the formula.

Hassanul likes this

Share this post


Link to post
Share on other sites

Are you sure adafruit's directions (and formula) are accurate for the LaunchPad? Keep in mind the Wolverine's max ADC voltage is 3.3V (Vcc) and it's a 12-bit ADC if I'm not mistaken. The fact that other pins report the same results makes me skeptical of the formula.

I didn't know that the wolverine has a 12-bit ADC. I just read the specifications and indeed you're right - its 12-bit. Now I got it to work perfectly.. Thanks!!

Share this post


Link to post
Share on other sites

Also, TI is replacing rev 1.6 Wolverine LaunchPads with the new rev 2.0 for free, search around about that :)

Yeah I got an email about that... Can't wait to get my hands on it!! Anyway I just found out that my board isn't fried, although at one time I accidentally splashed some water onto the eZ-FET while it was connected to the computer

Share this post


Link to post
Share on other sites

Yeah I got an email about that... Can't wait to get my hands on it!! Anyway I just found out that my board isn't fried, although at one time I accidentally splashed some water onto the eZ-FET while it was connected to the computer

Nice - PS, have you played around with Capacitive Touch sensing and water levels?  I did a little experiment last week with a cup of water, a GND wire and pin wire and using the Wolverine's captouch... Had some interesting results.  I need to make a more durable test fixture to evaluate this properly but it does seem that the captouch hardware can be used to detect "water level" more or less, although I am curious how its calibration may drift.

Share this post


Link to post
Share on other sites

Nice - PS, have you played around with Capacitive Touch sensing and water levels?  I did a little experiment last week with a cup of water, a GND wire and pin wire and using the Wolverine's captouch... Had some interesting results.  I need to make a more durable test fixture to evaluate this properly but it does seem that the captouch hardware can be used to detect "water level" more or less, although I am curious how its calibration may drift.

I am also experimenting with water level sensing right now... I'm making an aquaponics system that requires monitoring of water levels but I used a SRF05 Ultrasonic sensor placed on the top to detect the water level. I'm gonna try CapTouch someday.. It has a library for it right?

Share this post


Link to post
Share on other sites

I am also experimenting with water level sensing right now... I'm making an aquaponics system that requires monitoring of water levels but I used a SRF05 Ultrasonic sensor placed on the top to detect the water level. I'm gonna try CapTouch someday.. It has a library for it right?

There is an Energia lib for captouch, and TI has their professional C library for captouch... I can't recall if the Energia lib fully supports the Wolverine yet or not.  I was doing it all manually with C code either way.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now