Skip to main content
Explorer
April 14, 2023
Solved

NDEF_WriteText function read a temperature signal

  • April 14, 2023
  • 39 replies
  • 4627 views

I want to read the sensor signal with NDEF_WriteText function,How do you read a temperature signal instead of a temperature text?

NDEF_WriteText funtion is printf funtion,so what should I do to read signal?

    This topic has been closed for replies.
    Best answer by Schuyler

    Hi,@Rene Lenerve​ 

    I found that the problem is caused by incorrect SPI initialization settings, which causes the data to be garbled.

    39 replies

    ST Employee
    May 17, 2023

    Hi @帅 罗​​,

    25 is not the correct value expected from the sensor.

    From the Datasheet :

    "The first bit, D15, is a dummy sign bit and is always

    zero. Bits D14–D3 contain the converted temperature in

    the order of MSB to LSB. Bit D2 is normally low and

    goes high when the thermocouple input is open. D1 is

    low to provide a device ID for the MAX6675 and bit D0

    is three-state.


    _legacyfs_online_stmicro_images_0693W00000bkGrnQAE.pngIf you don't know the value read from the sensor you cannot determine if the error is coming from the conversion, or from the SPI read or other things.

    Please use debug session or a console log to get the RAW value coming from the sensor.

    Kind Regards.

    SchuylerAuthor
    Explorer
    May 17, 2023

    Hi,@Rene Lenerve​ 

    As far as I know, the data is composed of 12-bit precision and transmitted by SCK. As long as the data bits are needed, the 12-bit precision data will be transformed as follows to obtain accurate temperature data.

    float MAX6675_ReadTemperature(void)
    {
     return (MAX6675_ReadRawValue() *1024.0/4096);
    }

    ST Employee
    May 22, 2023

    Hi @帅 罗​,

    Yes the temperature sensor is an ADC and data are transmitted through the SO line as the SCK is the clock, and what I'm asking since last messages is the value of the RAW value gets from the SO line.

    Without it, I couldn't be of any help.

    Thank You.

    Kind Regards.

    SchuylerAuthor
    Explorer
    May 22, 2023

    Hi,@Rene Lenerve​ 

    I checked the instructions and I knew it was made up of 12 bits of data, but the actual raw value fluctuated between 0 and 0xff, so the MAX6675_ReadTemperature function converted it to a temperature measurement

    ST Employee
    May 22, 2023

    Hi @帅 罗​​,

    The raw value may be of 16 bit so you miss half of the data.

    "D15, is a dummy sign bit and is always zero", "Bit D2 is normally low and

    goes high when the thermocouple input is open. D1 is

    low to provide a device ID for the MAX6675 and bit D0

    is three-state.

    Max value "should be something like 0x7FF9.

    Kind Regards.

    SchuylerAuthor
    Explorer
    May 22, 2023

    Hi,@Rene Lenerve​ 

    The ADC adds the cold-end diode voltage to the amplified thermocouple voltage and outputs the result of 12bit to the SO pin. For a series of zeros, the temperature is 0 ° C, and for a series of ones, the temperature is +1023.75 ° C.

    SchuylerAuthor
    Explorer
    May 23, 2023

    Hi,@Rene Lenerve 

    I have successfully solved my problem, so thank you for your help�?

    ST Employee
    May 23, 2023

    Hi @帅 罗​,

    Great that you were able to solve your problem, could you briefly explain what was wrong so that it may be useful for the community?

    Kind Regards.

    SchuylerAuthorAnswer
    Explorer
    May 23, 2023

    Hi,@Rene Lenerve​ 

    I found that the problem is caused by incorrect SPI initialization settings, which causes the data to be garbled.