will be read-only starting December 31st, 2018. For more info please look at this Forum Post

:: Reading from a SMT16030 temperature sensor ::


The SMT16030 is a digital temperature sensor - it can be read with digital inputs - an ADC is not required.

Connect the Output pin of the sensor to a digital input on your Arduino, +Vcc to 5V, and GND to GND.


The sensor generates a square wave signal. The amplitude is the same as the input volage (5V), the frequency varies between 1kHz and 4kHz. The data is encoded in the signal's - the fraction of the output signal that is HIGH.

The duty cycle can then be converted to degrees Celsius by calculating temperature = (dutyCycle) -0.32)/0.0047.

To get the duty cycle, the sensor's output has to be sampled. Because the maximum frequency is 4kHz, the sampling rate should be at least 8kHz for no loss of information. Since a digitalRead only takes one clock cycle, this is no problem for Arduino.

The fewer samples you take, the larger the error will be: You can see that the formula above returns temperatures between -68°C and 145°C - a range of 213K. Now if you only use 100 samples for your calculation, the error of your measurement is at least +/- 2.13K! With 4000 samples you can reduce it to +/- 0.05K.


This sketch prints the HIGH count, sample count and temperature to the serial interface every 500ms. I'm using it to plot temperature over time with Processing. The HIGH count and sample rate in the output is useful for drawing average curves (over 2 seconds, over 4 seconds, ...)

unsigned long now;
unsigned long lastSample;
unsigned int sampleSize;
unsigned int highCount;
unsigned long lastOutput;
float temperature;
float hcf, ssf;

int sensorPin = 2;

void setup()
  pinMode(sensorPin, INPUT);
  digitalWrite(sensorPin, LOW);
  lastSample = 0;
  sampleSize = 0;
  highCount = 0;
  lastOutput = 0;
  temperature = 0;

void loop() 
  now = micros();
  if (now - lastOutput > 500000) {
    hcf = highCount;
    ssf = sampleSize;
    temperature = ((hcf / ssf) -0.32)/0.0047;
    Serial.print(" / "); 
    Serial.print(" temp: "); 
    lastOutput = now;
    sampleSize = 0;
    highCount = 0;
  if (now - lastSample > 100) {
    highCount = highCount + digitalRead(sensorPin);
    lastSample = now;
  } else {