Jump to content
43oh

ADC problems or code problems? Please help !


Recommended Posts

Hello everyone ! 

     

         I started to use Energia to create simple projects using MSP430G2553 LaunchPad and somehow I've succeded until now! Today I encountered a problem as I was trying to read values from a HIH-4000-001 humidity sensor.The sensor is powered with 5V and can return a value ranging from 0.826 V to 3.976V coresponding to 0 - 100 % RH. Because 3.976 V is much more than the MSP430 can manage I used a 1:2 resistive divider to scale down the signal.Moreover the sensor needs an load resistance of minimum 80kohms so the resistors I used for my divider were R1= 36kohms and R2=68kohms.NOW comes the error :

           

        Regarding that , the RH level is normally around 50% that would corespond to a value of 1.3 V after the scale-down so in terms of ADC readings that would be around 445 and that is the value I get but, if I take multiple readings 1 sec apart of each other this is what happens : 

 

                                                                                      445

                                                                                      442

                                                                                      443

                                                                                        0

                                                                                        0

                                                                                        0 

                                                                                      443

                                                                                      440

                                                                               .....................

Why 0 ? Can anyone tell me ? If I measure for some period of time the output of the sensor, the multimeter indicates a constant value of 1.3 V so I assume that the ADC is the problem! Please help me solve this issue as I need to create a functional project for my Bachelor Degree ! Thanks in advance ! 

Link to post
Share on other sites

Posting your code would be helpful since it looks like that is where the problem may reside.

 

Also, you may want to check this post for additonal information to include:  http://forum.43oh.com/topic/4824-information-to-provide-when-asking-for-help/

 

Having all the information greatly increases the possiblity that someone can identify the problem and provide the assistance you are looking for.

Link to post
Share on other sites

Posting your code would be helpful since it looks like that is where the problem may reside.

 

Also, you may want to check this post for additonal information to include:  http://forum.43oh.com/topic/4824-information-to-provide-when-asking-for-help/

 

Having all the information greatly increases the possiblity that someone can identify the problem and provide the assistance you are looking for.

The function that transforms adc readings into RH % is listed below :

 

int Read_RH(int pin , int temperature){

           int temp_compensated_RH=0;
           int RH=0;
           float Vcc=5.0;
           float Vout=0;
   
   Vout=analogRead(pin)*(3.0/1023);  // transforming adc readings into voltage values;
 
   RH=((Vout/Vcc) - 0.16)/0.0062; // RH formula for T= 25 Celsius - derived from HIH-4000-001 datasheet;  
   temp_compensated_RH=RH/(1.0546-(0.00216*temperature)); // temperature compensation acording to HIH-4000-001 datasheet ; 
  return temp_compensated_RH; 
}

 

But when I call this function the values returned are odd positive or negative values so I tried to see what does the ADC return by simply calling Serial.print( analogRead( P1_6 ))  because P1_6 is the pin for my sensor.So when I call the Serial.print function the values returned are similar to what I first posted ! 

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