NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Support Forum » slowing down the tempsensor

August 16, 2010
by Ralphxyz
Ralphxyz's Avatar

I am getting to many readings how would I read the tempsensor only every minute?

Even with no powered sensor there is always a changing millivoltage (101.1 - 103.5 more or less) on the ADC pin.

If i power on the MCU and the sensor I get a constantly changing 361 to 365 milivolt reading, this is without any voltage coming from the sensor the sensor is just not reading anything (I am using a strain gage not the temperature sensor but milivolts are milivolts so I can just use the same code except for LCD display text).

How can I zero out the readings when there isn't any load? The 360 milivolt is approximately what I get with a 40# weight on the scale so I cannot ignore that voltage range.

I also would like to slow down the sensor reading and only read every minute, whatever I have tried just blanks the LCD.

Thanks again for the help,

Ralph

November 17, 2010
by tkopriva
tkopriva's Avatar

Where you able to slow down the temperature readings? I am having the same issue--my lcd just goes blank no matter what I change it to.

November 30, 2010
by exussum
exussum's Avatar
uint16_t adc_read() {
  // read from ADC, waiting for conversion to finish
  // (assumes someone else asked for a conversion.)
  // wait for it to be cleared
  while(ADCSRA & (1<<ADSC)) {
    // do nothing... just hold your breath.
  }
  // bit is cleared, so we have a result.

  // read from the ADCL/ADCH registers, and combine the result
  // Note: ADCL must be read first (datasheet pp. 259)
  uint16_t result = ADCL;
  uint16_t temp = ADCH;
  result = result + (temp<<8);

  // set ADSC bit to get the *next* conversion started
  ADCSRA |= (1<<ADSC);

  return result;

You would need to modify that section of code.

Maybe putting ADCSRA |= (1<<ADSC); at the top just under uint16_t adc_read() {

That would start the reading each time the function is called. wait for the reading to be finished and return it.

Then add a sleep(600); somewhere in the while (1) {} Statement.

600 comes from 60,000 Milliseconds in a Minute, Need a 100 Sample average so divide 60,000 by 100 gives 600, Which will be give or take a Minute

Post a Reply

Please log in to post a reply.

Did you know that you can make a spooky Halloween Jack-O-Lantern with a microcontroller? Learn more...