Due to high demand expect some shipping delays at this time, orders may not ship for 1-2 business days.
0

Circuit Playground Classic
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Circuit Playground Classic

by michaeldbeard on Wed Nov 24, 2021 3:01 pm

I have a Circuit Playground Classic RevC1 that I bought a few years ago. I plugged it into my Windows 10 computer, downloaded the Arduino 1.8.16 and ran this code ...

Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_CircuitPlayground.h>

float tempC, tempF;

void setup() {
  Serial.begin(9600);
  CircuitPlayground.begin();
}

void loop() {
  tempC = CircuitPlayground.temperature();
  tempF = CircuitPlayground.temperatureF();

  Serial.print("tempC: ");
  Serial.print(tempC);
  Serial.print("  tempF: ");
  Serial.println(tempF);

  delay(1000);
}

... with temp readouts of ...

12:54:50.986 -> tempC: 28.81 tempF: 83.85

... varying only slightly throughout the time that I was looking at the Serial Monitor.

The problem is that a friend of mine brought in a handheld digital thermister that read the temperature at 78.16° F. What can I do to recalibrate the thermometer on the Circuit Playground Classic to be more accurate?
Last edited by dastels on Wed Nov 24, 2021 3:14 pm, edited 1 time in total.
Reason: Added code tags

michaeldbeard
 
Posts: 3
Joined: Tue Nov 23, 2021 2:59 pm

Re: Circuit Playground Classic

by dastels on Wed Nov 24, 2021 3:35 pm

I took the liberty of splitting your post off to a new topic. It's good manners not to hijack other threads, and new topics are more likely to get noticed.

The temperature sensor simply reflects an analog reading of the thermister. as such there's no way to calibrate the sensor (which there can be with a more advanced sensor).

You have two options IMO: using the result from CircuitPlayground.temperature() (temperaturF is based on that() or the raw analogRead(CPLAY_THERMISTORPIN) (which is what temperature is based on).

Both involve taking readings with your trusted device throughtout the desired range alongside the CircuitPlayground's reading and writing a conversion function to produce an accurate value fro whichever type of reading you used.

For reference, here's the temperature() function from the library:
Code: Select all | TOGGLE FULL SIZE
float Adafruit_CircuitPlayground::temperature(void) {
  // Thermistor test
  double reading;
  reading = analogRead(CPLAY_THERMISTORPIN);

  // Serial.print("Thermistor reading: "); Serial.println(reading);

  // convert the value to resistance
  reading = ((1023.0 * SERIESRESISTOR) / reading);
  reading -= SERIESRESISTOR;

  // Serial.print("Thermistor resistance: "); Serial.println(reading);

  double steinhart;
  steinhart = reading / THERMISTORNOMINAL;          // (R/Ro)
  steinhart = log(steinhart);                       // ln(R/Ro)
  steinhart /= BCOEFFICIENT;                        // 1/B * ln(R/Ro)
  steinhart += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To)
  steinhart = 1.0 / steinhart;                      // Invert
  steinhart -= 273.15;                              // convert to C

  return steinhart;
}

My thought is that converting the result of temperature() would be more straightforward and less work.

Dave

dastels
 
Posts: 7962
Joined: Tue Oct 20, 2015 3:22 pm

Please be positive and constructive with your questions and comments.