TINKER PiEDESIGN IN INDIA

Thermometer and fever lightTinkerPieCircuit tutorial 23 of 24 · Intermediate · 20 minutes

Read a temperature sensor, convert volts to degrees Celsius and light a warning LED.

Open this circuit in TinkerPieCircuit (free, runs in your browser)

What you will learn

Parts

TinkerPie V1 board1 temperature sensor1 LED1 resistor, 220 Ω

Steps

  1. Wire the sensor

    V → 3V3, G → GND, OUT → P11.

  2. Convert the reading

    analogRead gives 0 to 4095 for 0 to 3.3 V. So volts = reading × 3.3 ÷ 4095.

  3. Find the temperature

    The sensor gives 0.5 V at 0 °C plus 0.01 V per degree, so °C = (volts − 0.5) × 100.

  4. Warn when hot

    If the temperature is over 40 °C, turn on the LED on S1.

  5. Test

    Press ▶ Start, open the Serial monitor and drag the sensor slider.

The code

function setup() {
  pinMode(S1, OUTPUT);
}

function loop() {
  const volts = analogRead(P11) * 3.3 / 4095;
  const tempC = (volts - 0.5) * 100;
  Serial.println("Temperature = " + tempC.toFixed(1) + " C");
  if (tempC > 40) {
    digitalWrite(S1, HIGH);
  } else {
    digitalWrite(S1, LOW);
  }
  delay(300);
}

Copy this into the Code tab. It is Arduino-style JavaScript. The real board uses the same pin names (S1, P10…) in TinkerPie Studio.

How it works

The sensor outputs a voltage that grows with temperature. The program turns that voltage back into degrees with a simple formula. This is how most analog sensors work.

Challenge: Add a second LED that lights when the temperature is below 15 °C.

← Motion alarm with a PIR sensor · All 24 circuit tutorials · Plant watering helper →