interfacing a temperature sensor

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

 Hi,

   

Iam trying to interface a temperature sensor to the CY8CKIT-050. however, there is a problem with the software below.

   

 

   

#include <project.h>

   

#include "stdio.h"

   

int main()

   

{

   

float T;

   

int32 voltcount;

   

float volt;

   

char str[16];

   

LCD_Start();

   

ADC_Start();

   

ADC_StartConvert();

   

    for(;;)

   

    {

   

ADC_IsEndConversion(ADC_WAIT_FOR_RESULT);

   

        voltcount=ADC_GetResult16();

   

        volt=ADC_CountsTo_Volts(voltcount);

   

 

   

T=85.543*(1.8641-volt);

   

 

   

sprintf(str, "%+1.4f", T);    //pretty sure the problem lies here 🙂

   

        LCD_Position(0u,0u);

   

        LCD_PrintString(str);

   

    }

   

}

   

 

   

the project consists of a LCD and a temperature sensor. the PSOC5 reads the output from the sensor and displays it on the LCD.

   

I did some debugging, triple checked the connections, checked the LCD and it's working. but I am quite sure that the problem lies in the sprintf function.

0 Likes
3 Replies
Anonymous
Not applicable

 never mind, never mind. I have read this subject and it worked like a charm: 

   

http://www.cypress.com/?app=forum&id=2492&rID=86619

   

u know cypress should inform us when making changes like that. I almost gone crazy over this bug.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You are not allone in the dark...

   

www.cypress.com/

   

 

   

Bob

0 Likes
Anonymous
Not applicable

 Thanks Bob.

   

Regards,

   

Mahmood

0 Likes