DS18B20 and onewire and dallas libraries, from web browser

Hi friends,

I am attempting to use the OneWire lib, and Spark-Dallas-temperature lib from the browser platform to get the DS18B20 water proof temperature sensor to work. The thing is i have it working in a different script than i am working on now, but when i try and copy it over verbatim i get the following error message;

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"

I vaguely remember having a similar issue when i got the sensor working initially but cannot remember how i resolved it. Here is the code i am trying to get to compile. Thanks in advace

// 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/OneWire.h>

// This #include statement was automatically added by the Particle IDE.
#include "blynk.h"

//Relay Stuff
//WHICH IS WHAT??
#define RELAY_OFF 1 
#define RELAY_ON 0
//Declare Relay pins
#define pumpRelay D0
#define nutrientRelay D1
#define waterInRelay D2
#define floodWaterInRelay D3
#define floodBasinRelay D4
#define floodBasinDrainRelay D5
#define heaterRelay D6

#define ONE_WIRE_BUS D7
#define TEMPERATURE_PRECISION 9


int waterTempF = -1;
double InTempC = -1;
//Sensors
    //Water Temperature
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress inWaterThermometer = { 0x28, 0xB6, 0x78, 0x5E, 0x07, 0x0, 0x0, 0x4F };
void update18B20Temp(DeviceAddress deviceAddress, double &tempC);
//Blynk
char auth[] = "omitted"; 

void setup() {
    Blynk.begin(auth);
    //water temperature
    sensors.begin();
    sensors.setResolution(inWaterThermometer, TEMPERATURE_PRECISION);
  //  Particle.variable("WaterTemp",waterTempF);
    
   
 
	//Relays
    pinMode(pumpRelay, OUTPUT);
    pinMode(nutrientRelay, OUTPUT);
    pinMode(waterInRelay, OUTPUT);
    pinMode(floodWaterInRelay, OUTPUT);
    pinMode(floodBasinRelay, OUTPUT);
    pinMode(floodBasinDrainRelay, OUTPUT);
    pinMode(heaterRelay, OUTPUT);



    digitalWrite(pumpRelay, RELAY_OFF);
    digitalWrite(nutrientRelay, RELAY_OFF);
    digitalWrite(waterInRelay, RELAY_OFF);
    digitalWrite(floodWaterInRelay, RELAY_OFF);
    digitalWrite(floodBasinRelay, RELAY_OFF);
    digitalWrite(floodBasinDrainRelay, RELAY_OFF);
    digitalWrite(heaterRelay, RELAY_OFF);

}

void loop() {
    Blynk.run();
   // digitalWrite(pumpRelay, RELAY_OFF);
   // digitalWrite(nutrientRelay, RELAY_OFF);
   //  digitalWrite(waterInRelay, RELAY_OFF);
   // digitalWrite(floodWaterInRelay, RELAY_OFF);
    
   // delay(500);
  //  digitalWrite(pumpRelay, RELAY_ON);
   // delay(500);
   // digitalWrite(nutrientRelay, RELAY_ON);
   // delay(500);
   // digitalWrite(waterInRelay, RELAY_ON);
    //delay(500);
   // digitalWrite(floodWaterInRelay, RELAY_ON);
    
   sensors.requestTemperatures();
   update18B20Temp(inWaterThermometer, InTempC);
   waterTempF = (InTempC * 9)/5 + 32;
    
    //delay(1000);
    
}
void update18B20Temp(DeviceAddress deviceAddress, double &tempC)
{
  tempC = sensors.getTempC(deviceAddress);
}

i changed your

#include “…/OneWire/OneWire.h”

I am still having this issue, i have tried changing the include statement a few different ways.

From the reply i see above the only thing different is the removal of the #include OneWire statement, is this correct?

@jjlee32 I’m using the same lib in a working project and it’s included like this: #include <OneWire.h>

1 Like

yes

2 Likes

i just compiled your sketch
with

#include <OneWire>
#include "spark-dallas-temperature.h" 

i included the spark-dallas-temperature into my sketch see photo


and it compiles

2 Likes

Thank you all, this has fixed my issue

2 Likes