Home / Tutorials / Arduino Tutorial / How to Use the PT100 RTD with Arduino Cloud
pcbway

How to Use the PT100 RTD with Arduino Cloud

Using a PT100 RTD (Resistance Temperature Detector) with an Arduino and connecting it to the Arduino IoT Cloud via Wi-Fi allows you to remotely monitor temperatures with high accuracy and reliability. In this tutorial, we’ll walk you through the process of setting up your PT100 sensor with an Arduino that has Wi-Fi capabilities, and then integrate the data into Arduino Cloud for remote monitoring and logging.

What You’ll Need

  1. PT100 RTD Temperature Sensor
  2. RTD Amplifier/Module – For example, an Adafruit MAX31865 Amplifier, which is specifically designed for RTDs.
  3. Arduino with Wi-Fi capability – Arduino MKR WiFi 1010 , ESP32, or similar.
  4. Jumper wires
  5. Arduino IoT Cloud Account

Understanding the PT100 Sensor and Amplifier

Adafruit PT100 RTD Temperature Sensor Amplifier - MAX31865

The PT100 RTD sensor changes resistance in response to temperature. The PT100’s resistance is 100 ohms at 0°C and changes linearly with temperature. To interface it with the Arduino, you need an amplifier like the MAX31865, which converts the resistance changes into digital signals readable by the Arduino.

Wiring the PT100 RTD and Amplifier

Connect the PT100 RTD to the amplifier. Most RTD amplifiers like the MAX31865 come with labeled inputs for 2-wire, 3-wire, or 4-wire RTD configurations. Here’s how to connect a 3-wire PT100 RTD to a MAX31865 module and then connect the module to the Arduino

PT100 Sensor to MAX31865:

  • Wire one side of the RTD to the RTD+ pin.
  • The other two wires go to the RTD- and RTD Middle connections (follow the specific module’s labeling).

MAX31865 Amplifier to Arduino:

  • VCC of the MAX31865 to 3.3V on the Arduino.
  • GND of the MAX31865 to GND on the Arduino.
  • SDO (MISO) of the MAX31865 to MISO on the Arduino.
  • SDI> (MOSI) of the MAX31865 to MOSI on the Arduino.
  • SCK of the MAX31865 to SCK on the Arduino.
  • CS> of the MAX31865 to any available digital pin on the Arduino (e.g., D5).

Install Required Libraries

To make your Arduino code simpler, install the required libraries:

Adafruit MAX31865 Library:

  • Open the Arduino IDE.
  • Go to Sketch > Include Library > Manage Libraries.
  • Search for Adafruit MAX31865 and install it.

Arduino IoT Cloud Library:

  • Go to Sketch> Include Library> Manage Libraries
  • Search for ArduinoIoTCloud and install it.

Step 4: Create an Arduino IoT Cloud Account and Setup a New Thing

  1. Go to Arduino IoT Cloud and sign in or create an account.
  2. Create a new Thing in the Arduino IoT Cloud, which will be the object holding your temperature data.
  3. Define a variable in the Thing (e.g., temperature of type Float) that will store and display the PT100 sensor’s temperature readings.
  4. Select your device type and configure it to connect to Wi-Fi.

Step 5: Write the Arduino Code

Here’s an example code snippet to read from the PT100 sensor and upload the data to Arduino Cloud.

#include <Adafruit_MAX31865.h>
#include <ArduinoIoTCloud.h>
#include <WiFiNINA.h>

// Wi-Fi credentials
const char* ssid = "Your_SSID";
const char* password = "Your_PASSWORD";

// MAX31865 configuration
#define MAX31865_CS_PIN 5  // Chip Select pin
Adafruit_MAX31865 max31865 = Adafruit_MAX31865(MAX31865_CS_PIN);

// Arduino Cloud variable
float temperature;

// Function to read temperature from the PT100 sensor
float readTemperature() {
  // Configure the RTD sensor type
  max31865.begin(MAX31865_3WIRE);  // Choose the right wiring configuration (2, 3, or 4 wire)
  float temp = max31865.temperature(100, 430);  // 100 ohms for PT100, 430 is the reference resistor
  return temp;
}

// IoT Cloud setup
void initProperties() {
  ArduinoCloud.addProperty(temperature, READ, ON_CHANGE, NULL);
}

void setup() {
  Serial.begin(9600);

  // Initialize MAX31865
  if (!max31865.begin(MAX31865_3WIRE)) {
    Serial.println("Failed to initialize MAX31865!");
    while (1);
  }
  
  // Connect to Wi-Fi
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("Connected to WiFi!");

  // Arduino IoT Cloud setup
  initProperties();
  ArduinoCloud.begin(WiFi.status);
}

void loop() {
  // Update Arduino IoT Cloud
  ArduinoCloud.update();

  // Read temperature and print it to Serial
  temperature = readTemperature();
  Serial.print("Temperature: ");
  Serial.println(temperature);

  // Delay for stability
  delay(2000);
}

Code Explanation

  1. Wi-Fi Configuration: The code connects to your Wi-Fi using WiFiNINA.h.
  2. RTD Setup: The Adafruit_MAX31865 library configures the sensor with max31865.begin(MAX31865_3WIRE).
  3. Temperature Readings: temperature = readTemperature() fetches the temperature and assigns it to the temperature variable created in Arduino Cloud.
  4. Sending Data to the Cloud: ArduinoCloud.update() syncs the temperature data to your Arduino IoT Cloud account.

Monitoring Data on Arduino IoT Cloud

  1. Go back to Arduino IoT Cloud and open the Dashboard for your Thing.
  2. Add a widget (such as a Gauge or Chart) to visualize the temperature variable in real-time.

Deploy and Test

  1. Upload the code to your Arduino board.
  2. Open the serial monitor to verify if temperature readings are displayed correctly.
  3. Check the Arduino IoT Cloud dashboard to ensure the temperature data is streaming and updating in real-time.

Conclusion

This tutorial demonstrated how to connect a PT100 RTD to an Arduino with Wi-Fi capability and integrate it into Arduino IoT Cloud. This setup is suitable for remote monitoring, data logging, and implementing smart temperature monitoring systems. You can further customize the setup by adding more features, such as email alerts or integration with other IoT services.

Check Also

Arduino data types

Converting Between Data Types in Arduino

When writing code for Arduino, you’ll often need to convert between different data types. This …

Leave a Reply

Your email address will not be published. Required fields are marked *