Simple Library problems with OneWire and spark_Dallas_Temperature libraries

I am embarrassed to ask such a simple question, but I am a newbee Particle Photon programmer and I have really tried hard to get past this problem. I am a retired programmer hoping to use the photon for controlling my remote site Ham Radio Station. I need the temperature sensor to control fans in the outdoor control box.

Whatever I do I cannot seem to get this example program to compile. It is an example in Simon Monk’s beginner book. I am using the Web IDE, I suspect that I must
be doing something wrong in adding these library items to my IDE. In the recent past, I have used the Arduino products. Can anyone help with this? Mike@W8DER.Net

// P_10_thermometer_dallas.ion  from Make:  "Getting Started with the Photon"
// by Simon Monk


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

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

double tempC = 0.0;
double tempF = 0.0;

int tempSensorPin = D2;

OneWire oneWire(tempSensorPin);
DallasTemperature sensors(&oneWire);

void setup() {
    sensors.begin();
    Spark.variable("tempc", &tempC, DOUBLE);
    Spark.variable("tempf", &tempF, DOUBLE);
}

void loop() {
  sensors.requestTemperatures();
  tempC = sensors.getTempCByIndex(0);
  tempF = tempC * 9.0 / 5.0 + 32.0;
}

AND THIS IS THE COMPILE ERROR I GET: (I tried the obvious putting " " around the OneWire.h)

lib/spark-dallas-temperature/spark-dallas-temperature.h:27:36: ../OneWire/OneWire.h: No such file or directory

(I tried the obvious putting " " around the OneWire.h) and much more!
In Arduino, the difference is between <> and " " is the file location to search.

OneWire.cpp is version 2.0.1
Spark_Dallas_Temperature is version 0.0.5


Since you are new to Particle devices, did you actually add these libraries to your project? It is a particular nuance to this environment. There is a button in the bar on the left to manage libraries, and you need to add them in to your project that way. Just copying the #include statements is not enough.

Another thing to look out for is versions. In ParticleBuild (the Web IDE), check to make sure you have selected your Photon as the device you are programming and you are building your firmware to a suitable system firmware version. That being said, you should check to make sure your Photon system firmware is up to date; do “particle update” if you have the CLI installed (recommend to do so).

My suggestions are just overviews. Take a closer look at the documentation or in these forums for detailed instructions. Be sure to come back here and ask if you get stuck or something is not clear.

7-3 (VE3TSD)

The problem with spark_dallas_temperature library is this unaddressed issue

You may rather want to go with another library like ds18b20

Thanks for your help ScruffR. I switched to DS18B20 Library and that compiles and flashes. I also have one of the library examples running. I really appreciate your help. mIke@W8DER.Net

1 Like