Error compiling I could not find the solution

Hi,

I’m trying to compile this example but there is an error that I could not fix.

Does anybody knows what’s happen

Thank’s I’m desperate

error:/workspace/lib/spark-dallas-temperature/src/spark-dallas-temperature.h:27:36: fatal error: …/OneWire/OneWire.h: No such file or directory
#include “…/OneWire/OneWire.h”

code:

// This #include statement was automatically added by the Particle IDE.
#include <spark-dallas-temperature.h>

// This #include statement was automatically added by the Particle IDE.
#include <OneWire.h>

int oneWirePins[]={D4,D5};
const int oneWirePinsCount
      =sizeof(oneWirePins)/sizeof(int);
 
OneWire ds18x20[oneWirePinsCount] { D4, D5 };
DallasTemperature sensor[oneWirePinsCount] { &ds18x20[0], &ds18x20[1] };


void setup() {
  Serial.begin(9600);
  Serial.print("============Ready with ");
  Serial.print(oneWirePinsCount);
  Serial.println(" Sensors================");
 
  //Start up the library on all defined pins
  DeviceAddress deviceAddress;
  for (int i=0; i<oneWirePinsCount; i++) {;
    //ds18x20[i].setPin(oneWirePins[i]);
    //sensor[i].setOneWire(&ds18x20[i]);
    sensor[i].begin();
    if (sensor[i].getAddress(deviceAddress, 0)) 
      sensor[i].setResolution(deviceAddress, 12);
  }
void loop(void) {
  Serial.print("Requesting temperatures...");
  for (int i=0; i<oneWirePinsCount; i++) {
    sensor[i].requestTemperatures();
  }
  Serial.println("DONE");
 
  delay(1000);
  for (int i=0; i<oneWirePinsCount; i++) {
    float temperature=sensor[i].getTempCByIndex(0);
    Serial.print("Temperature for the sensor ");
    Serial.print(i);
    Serial.print(" is ");
    Serial.println(temperature);
  }
  Serial.println();
}

Do you have OneWire library in folder?

I had this error some months ago. I downloaded OneWire library and include in the app’s folder.

2 Likes

yes, OneWire an spark dallas library....ok I'm going to copy the library directly to the folder.

Thank's

Actually that’s not the intended way to do it.
First we’d need to know what dev environment you are using and what system version you are targeting.

With this info we may be able to walk you through the intended process.

1 Like

Suriken,

How do I put the library manually, i thought I did but no, still with the errors compiling

Thank's

Haven’t you had luck with importing libraries button?

What I usually do is create 2 files Library.cpp and Library.h where Library is the name of the files I want to copy. Then, I open the files on the online ide and copy&paste the content inside my files.

I usually keep those files in my project folder so you can include with #include “Library.h”

I know this is not the intended way, but when I had to do this, I had no luck with the current way at that time.