The MKE-S15 DS18B20 Waterproof Temperature Sensor is a precision digital thermometer that provides temperature readings which indicate the temperature of the device. Encased in a stainless steel housing, this sensor is waterproof and ideal for measuring temperature in liquids and harsh environments. It uses the DS18B20 sensor chip and communicates over a 1-Wire bus that by design requires only one data line (and ground) for communication with a central microprocessor.
Pin Number | Description | Color |
---|---|---|
1 | Ground (GND) | Black |
2 | Data (DQ) | Yellow |
3 | Power Supply (VDD) | Red |
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature sensor
DallasTemperature sensors(&oneWire);
void setup(void)
{
// Start serial communication for debugging purposes
Serial.begin(9600);
// Start up the library
sensors.begin();
}
void loop(void)
{
// Call sensors.requestTemperatures() to issue a global temperature
// request to all devices on the bus
sensors.requestTemperatures();
// Fetch the temperature in degrees Celsius for device index 0
float tempC = sensors.getTempCByIndex(0);
// Check if reading was successful
if(tempC != DEVICE_DISCONNECTED_C)
{
Serial.print("Temperature: ");
Serial.print(tempC);
Serial.println("°C");
}
else
{
Serial.println("Error: Could not read temperature data");
}
delay(1000); // Wait 1 second before next reading
}
Serial.begin
setting in your code.OneWire
library's search function to confirm device presence on the bus.Q: Can I connect multiple DS18B20 sensors to the same microcontroller? A: Yes, the DS18B20 supports multiple devices on the same 1-Wire bus.
Q: How long can the sensor cable be? A: The cable length can be up to 100 meters, but it may require a lower pull-up resistor value for longer distances.
Q: Is calibration required for this sensor? A: The DS18B20 is factory-calibrated and does not typically require additional calibration.