Skip to the content.

MycilaDS18

Latest Release PlatformIO Registry

License: MIT Contributor Covenant

Build GitHub latest commit Gitpod Ready-to-Code

ESP32 / Arduino Library for Dallas / Maxim DS18 sensors using RMT peripheral

Usage

#include <Arduino.h>
#include <MycilaDS18.h>

Mycila::DS18 temp;

void setup() {
  Serial.begin(115200);
  while (!Serial)
    continue;

  temp.begin(18);

  // Listen to temperature changes in a callback
  temp.listen([](float temperature) {
    Serial.printf("Temperature: %.2f\n", temperature);
  });
}

void loop() {
  // non blocking read
  if (!temp.read()) {
    Serial.println("Not ready yet");
  } else {
    Serial.println("Temperature: " + String(temp.getTemperature().value_or(0)));
  }
  delay(500);
}