[SOVLED] I've been using DS18 (webiDE) but today get "DS18.h: No such file or directory"

I copied (copy/paste to a new sketch in Web IDE) an existing temperature sketch I had to download it to a new photon and start modifying.

I didn’t think I changed anything other than removing a serial.print()

But now I get:

DS18.h: No such file or directory

Anyone have any ideas?
(sorta under the gun)

Use this sketch to read the temperature from 1-Wire devices
you have attached to your Particle device (core, p0, p1, photon, electron)

Temperature is read from: DS18S20, DS18B20, DS1822, DS2438

I/O setup:
These made it easy to just 'plug in' my 18B20

D3 - 1-wire ground, or https://build.particle.io/build/5a8dfd311d761ca686001210#flashjust use regular pin and comment out below.
D4 - 1-wire signal, 2K-10K resistor to D5 (3v3)
D5 - 1-wire power, ditto ground comment.

A pull-up resistor is required on the signal line. The spec calls for a 4.7K.
I have used 1K-10K depending on the bus configuration and what I had out on the
bench. If you are powering the device, they all work. If you are using parasitic
power it gets more picky about the value.

// jeff tapia's configuration parameters:
unsigned int forcePublish = 3600000; // force at least 1 value even if it hasn't changed int he past hour (60*60*1000)
String particleiowebhookname = "wonderware online datasource mysourcepio1";
String devicename = "photon1"; //device id 33002a000c47363330353437 is currently named photon1
const byte sensortablerows = 2;
const byte sensortablecols = 3;
String sensortable[sensortablerows][sensortablecols] = {
    // sensor name, onewire device ID, sensor type

#include "DS18.h"
//#include "OneWire.h""
//#include "math.h"

DS18 sensor(D4);
float lastValue = 0;
float currentValue = 0;
unsigned int lastPublish = 99999999;
int tot = sizeof(sensortable);
int cols = sizeof(sensortable[0]);
int rows = tot / cols;
float lastValueArray[sensortablerows];
unsigned int lastPublishArray[sensortablerows];

void setup() {
    // Set up 'power' pins, comment out if not used!
    pinMode(D3, OUTPUT);
    pinMode(D5, OUTPUT);
    digitalWrite(D3, LOW);
    digitalWrite(D5, HIGH);

void loop() {
    // Read the next available 1-Wire temperature sensor
    if (sensor.read()) {
        unsigned long now = millis();
        Serial.printf("Temperature %.2f C %.2f F ", sensor.celsius(), sensor.fahrenheit());

        currentValue = round(sensor.fahrenheit()*10)/10; //0.1 degree F precision
        // Get sensor unique ID
        uint8_t addr[8];
        String addrs = String::format(
            addr[0], addr[1], addr[2], addr[3], addr[4], addr[5], addr[6], addr[7]
        String sensorname = "sensor";
        String sensortype = "temperature";
        int i = 0;
        while (i < rows) {
            if (addrs == sensortable[i][1]) {
                sensorname = sensortable[i][0];// ie. whitesensor
                sensortype = sensortable[i][2];// ie. temperature
                lastValue = lastValueArray[i];// ie. temperature
                lastPublish = lastPublishArray[i];// ie. milli
                Serial.printf("found at i=%d lastValue=%.1f lastPub=%d now=%d", i, lastValueArray[i], lastPublishArray[i], now);
        //publish every change >=0.1 degree F or at least every hour even if no change
        if ((abs(currentValue - lastValue)>=0.1) or (now - lastPublish>=forcePublish)) {
            // Do something cool with the temperature
            //Particle.publish("temperature", String(sensor.celsius()), PRIVATE);
            char cvs[6];// current value as text
            sprintf(cvs, "%.1f", currentValue);
            Particle.publish("temperature", String(cvs), 3600, PRIVATE);
            if (addrs == "28FF2CE180170588" ) {
                tagname = "white";
            String data = String::format(
                "{ \"tagname\": \"%s.%s.%s\", \"value\": \"%s\" }",
                devicename.c_str(), sensorname.c_str(), sensortype.c_str(), String(cvs).c_str());
            //saved for later: .c_str()
            Particle.publish(particleiowebhookname, data, PRIVATE);
            // Additional info useful while debugging
            // If sensor.read() didn't return true you can try again later
            // This next block helps debug what's wrong.
            // It's not needed for the sensor to work properly
            lastValue = currentValue;
            lastPublish = now;
            if (i<rows) {
                Serial.printf("found at i=%d lastValue=%.1f lastPub=%d now=%d", i, lastValueArray[i], lastPublishArray[i], now);
                lastValueArray[i]=lastValue;        // ie. temperature
                lastPublishArray[i]=lastPublish;    // ie. millis
    } else {
        // Once all sensors have been read you'll get searchDone() == true
        // Next time read() is called the first sensor is read again
        if (sensor.searchDone()) {
            Serial.println("No more addresses.");
            // Avoid excessive printing when no sensors are connected
            // Something went wrong
        } else {

void printDebugInfo() {
  // If there's an electrical error on the 1-Wire bus you'll get a CRC error
  // Just ignore the temperature measurement and try again
  if (sensor.crcError()) {
    Serial.print("CRC Error ");

  // Print the sensor type
  const char *type;
  switch(sensor.type()) {
    case WIRE_DS1820: type = "DS1820"; break;
    case WIRE_DS18B20: type = "DS18B20"; break;
    case WIRE_DS1822: type = "DS1822"; break;
    case WIRE_DS2438: type = "DS2438"; break;
    default: type = "UNKNOWN"; break;

  // Print the ROM (sensor type and unique ID)
  uint8_t addr[8];
    " ROM=%02X%02X%02X%02X%02X%02X%02X%02X",
    addr[0], addr[1], addr[2], addr[3], addr[4], addr[5], addr[6], addr[7]

  // Print the raw sensor data
  uint8_t data[9];
    " data=%02X%02X%02X%02X%02X%02X%02X%02X%02X",
    data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8]

Did you also import the library into your webIDE project using the “libraries” button? I don’t see the typical “this line was added automatically…” message above the #include statement.

1 Like

Thank you @ninjatill .
That is the problem.
It has been a while since I created a NEW project and I’d forgotten about the web IDE Library Import process.

1 Like