CYTHEIA AIOpen the editor

Temperature Monitor

Read temperature sensor and display on serial monitor.

Open this circuit and run it

Opens in your browser with the parts, wiring and code already in place. Press Run to watch it work, then change anything you like.

How it works

The temperature sensor has three pins: 5V, ground, and an output whose voltage rises with temperature, by 10 millivolts for each degree Celsius, like the common LM35 chip. The output is wired to analog pin A0.

loop() reads A0 as a number from 0 to 1023 and converts it to volts by multiplying by 5.0 and dividing by 1024. Because the sensor gives 0.01 volts per degree, multiplying the voltage by 100 gives degrees Celsius. The result prints once a second as “Temp: … C”. Select the sensor in the editor and change its temperature in the properties panel to watch the reading follow.

Parts

Wiring

Arduino code

// Temperature Monitor
void setup() {
  Serial.begin(9600);
}

void loop() {
  int reading = analogRead(A0);
  float voltage = reading * 5.0 / 1024.0;
  float tempC = voltage * 100;
  Serial.print("Temp: ");
  Serial.print(tempC);
  Serial.println(" C");
  delay(1000);
}

Try changing it

Open this circuit and run it

Next challenge

More projects in Sensors