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

nrf9160 adc

Dear Sir.

adc configured  like

#define ADC_DEVICE_NAME DT_ADC_0_NAME
#define ADC_RESOLUTION 10
#define ADC_GAIN ADC_GAIN_1_6
#define ADC_REFERENCE ADC_REF_INTERNAL
#define ADC_ACQUISITION_TIME ADC_ACQ_TIME(ADC_ACQ_TIME_MICROSECONDS, 10)

#define ADC_1ST_CHANNEL_ID 0
#define ADC_1ST_CHANNEL_INPUT NRF_SAADC_INPUT_AIN0

#define ADC_2ND_CHANNEL_ID 7
#define ADC_2ND_CHANNEL_INPUT NRF_SAADC_INPUT_AIN7

routine to read the ADC

int adc(void)
{
int ret;

const struct adc_sequence sequence = {
.channels = BIT(ADC_1ST_CHANNEL_ID) |
BIT(ADC_2ND_CHANNEL_ID),
.buffer = m_sample_buffer,
.buffer_size = sizeof(m_sample_buffer),
.resolution = ADC_RESOLUTION,
};

if (!adc_dev) {
return -1;
}

ret = adc_read(adc_dev, &sequence);
if(ret = 0)
printk("ADC read err: %d\n", ret);

temperature[0] = m_sample_buffer[0];
temperature[1] = m_sample_buffer[1];

return ret;
}

In hardware NTC is connected in series with 100kohm 1% , 3.3v to gnd.

the tap of NTC and 100k is connected to adc channel 0.

The routine adc() is called every 1 sec.

Yet the reading of temperature[0] is fluctuates like

Body temp = 431

Body temp = 440

Body temp = 423

Body temp = 416

Body temp = 473

Body temp = 482

Body temp = 478

Body temp = 419

Body temp = 430

Body temp = 413

Body temp = 475

Body temp = 419

Body temp = 486

Body temp = 475

Body temp = 424

Body temp = 413

Body temp = 419

Body temp = 473

Body temp = 409

Body temp = 481

Body temp = 413

Body temp = 470

Body temp = 421

Body temp = 415

adc0 input is tested 1.5v in ambient temperature.

Please Advise

Related