This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to use lmt70 with nrf51

Hey everyone, I'm trying to use lmt70 with nrf51822. So, first of all, nrf51 has 10-bits ADC, the data sheet of lmt70 is recommended 12-bits of ADC.

I plugged the sensor, and read the value which is 801, I calculated the value of temperature in C and got 56 degC.

I guess it's a wrong value, cause I measure the temperature of room and I' m sure I have less than 56 degree.

my code is here

#define ADC_BUFFER_SIZE 10
static nrf_adc_value_t       adc_buffer[ADC_BUFFER_SIZE];
static nrf_drv_adc_channel_t channel1 = NRF_DRV_ADC_DEFAULT_CHANNEL(NRF_ADC_CONFIG_INPUT_2);
    float LMT70_AMul = -0.0000000010642;
    float LMT70_BMul = -0.000005759725;
    float LMT70_CMul = -0.1789883;
    float LMT70_DMul = 204.857;
    
    /**
     * @brief ADC interrupt handler.
     */
    static void adc_event_handler(nrf_drv_adc_evt_t const * p_event)
    {
        if (p_event->type == NRF_DRV_ADC_EVT_DONE)
        {
            uint32_t i;
            float delta = 0;
            uint32_t count = p_event->data.done.size;
            for (i = 0; i < count; i++)
            {
                NRF_LOG_INFO("Current sample value: %d -> %d\r\n", i, p_event->data.done.p_buffer[i]);
                delta = p_event->data.done.p_buffer[i];
            }
            float LMT70_reading = ADC_RESULT_IN_MILLI_VOLTS(delta);
            //LMT70_reading *= 2.9;
            float A_val = LMT70_AMul * (LMT70_reading*LMT70_reading*LMT70_reading);
            float B_val = LMT70_BMul * (LMT70_reading*LMT70_reading);
            float C_val = LMT70_CMul * LMT70_reading;
    
            float degC = A_val+B_val+C_val+LMT70_DMul;
            //float tm = ((9/5)*degC)+32;
            NRF_LOG_INFO("My float number: %d\r\n", NRF_LOG_FLOAT(degC));
        }
    }
Parents
  • The read value is from 0 to 1023 for 10 bit ADC, it is not corresponding to millivolt measured. If you read 801 from the ADC, then this equals

    801/1023 * 1.2V ~= 940mV
    

    When using 10 bit resolution and VBG (1.2V) as voltage reference. According to the datasheet this is just over 20 degrees, which should be about correct (right?).

  • That small error could be many things. The multimeter could be inaccurate. The impendance of the circuit may affect the ADC measurements, especially if you have a multimeter connected while you are doing measurements with the ADC.

    For increased accuracy you can also try to use the crystal as the clock source instead by starting it before the measurements. Inaccuracies in the clock may lead to inaccuracies in the measurements.

    You may also have an offset error which can be up to 2% according to the Product Specification.

Reply
  • That small error could be many things. The multimeter could be inaccurate. The impendance of the circuit may affect the ADC measurements, especially if you have a multimeter connected while you are doing measurements with the ADC.

    For increased accuracy you can also try to use the crystal as the clock source instead by starting it before the measurements. Inaccuracies in the clock may lead to inaccuracies in the measurements.

    You may also have an offset error which can be up to 2% according to the Product Specification.

Children
No Data
Related