Circuit Playground Classic

Play with it! Please tell us which board you're using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
michaeldbeard
 
Posts: 3
Joined: Tue Nov 23, 2021 2:59 pm

Circuit Playground Classic

Post by michaeldbeard »

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

#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

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: Circuit Playground Classic

Post by dastels »

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

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

Locked
Please be positive and constructive with your questions and comments.

Return to “Circuit Playground Classic, Circuit Playground Express, Circuit Playground Bluefruit”