// Exercise 01.1 - Connecting a PT100 to an Arduino
// Objective: Create a sketch to continuously read the temperature
// from a PT100 sensor connected to A0 and display it through the Serial output.
// A potentiometer is used to simulate the PT100 voltage input.
// The analog value from the potentiometer is processed as if it were from your PT100 circuit.
// Resources:
// Read analog input: https://www.arduino.cc/reference/en/language/functions/analog-io/analogread/
// Serial output: https://www.arduino.cc/reference/en/language/functions/communication/serial/println/
// Arduino cheat sheet: https://dlnmh9ip6v2uc.cloudfront.net/learn/materials/8/Arduino_Cheat_Sheet.pdf
// Define the analog pin for PT100 connection
int pt100Pin = A0;
void setup() {
// Initialize Serial communication
Serial.begin(9600);
// Initialization code:
// Set up the necessary configurations
}
void loop() {
// Main code:
// Read the analog value from the potentiometer and process it as if it were from your PT100 circuit.
// Use these variables:
int analogValue;
float voltage;
float temperature;
// a) From analogRead, you get a value between 0 and 1023. Set 'analogValue' to this value.
analogValue = analogRead(pt100Pin);
// b) This analog value represents a voltage on pin A0. Calculate the voltage and write it to 'voltage'.
// Hint: The division of two integer values will return an int. To get a precise result, use floats:
// float a = 1/2; will result in 1
// float a = 1.0/2; will result in 0.5
// because 1 is an integer, but 1.0 is a float
voltage = analogValue * (5.0 / 1023.0);
// c) Then you have to convert the voltage to a temperature in Kelvin or Celsius.
// For this, you already have the formula for your specific PT100 circuit. Write the result to 'temperature'.
temperature = voltage * 20 - 20; // <-- this is not the right formula!
// d) Print the results using Serial.print() and Serial.println().
// It should look something like this: "analogValue: xxx, voltage: xxx V, temperature: xxx °C"
Serial.print("analogValue: ");
Serial.print(analogValue);
Serial.print(", voltage: ");
Serial.print(voltage);
Serial.print(" V, temperature: ");
Serial.print(temperature);
Serial.println(" °C");
// Add a delay for better readability and to avoid flooding the Serial monitor
delay(1000);
// You can visualize the outcome using the Serial Monitor
// located in the upper right corner of the Arduino IDE.
// Check if the values in the console match your expectations.
}