sensor-experiments

Introduction

This experiment demonstrates how to use a temperature sensor to measure the temperature of water using an Arduino.

Components Needed

No Ads Available.

Circuit Setup

  1. Connect the temperature sensor’s VCC and GND pins to the 5V and GND pins on the Arduino.
  2. Connect the data pin of the sensor to a digital pin on the Arduino (e.g., D2).

The temperature sensor measures the temperature of the water, and the Arduino processes this value to give the water temperature.

Code for Water Temperature Measurement

Upload the following code to your Arduino to measure water temperature:


#include 
#include 

#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

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

void loop() {
  sensors.requestTemperatures();
  float temp = sensors.getTempCByIndex(0);
  Serial.print("Water Temperature: ");
  Serial.println(temp);
  delay(1000);
}
            

Explanation

The sensor reads the temperature of the water and sends this value to the Arduino, which processes it and outputs the result to the Serial Monitor.

Troubleshooting

Contact Us

If you have any questions or inquiries, feel free to reach out to us at Microautomation.no@icloud.com .

Follow our Socials for the newest updates!