Using the new Arduino IDE for ESP8266 and found bugs, report them here

Moderator: igrr

User avatar
By Petervdpol
#73748 Hi,

I am not sure if this is the right place for this question, but I get a conflict on OneWire.h while compiling. Appearently there is one in DallasTemperature besides the original OneWire library. Following a post here I renamed the "OneWire¨ directory to OneWireStandard, this did not help. Any help woulbe greatly appreciated.
The Error message I get (using Arduino IDE 1.6.8) is:

Code: Select allArduino: 1.6.8 (Linux), Board: "NodeMCU 0.9 (ESP-12 Module), 80 MHz, 4M (1M SPIFFS), v2 Prebuilt (MSS=536), Disabled, None, 115200"

libraries/DallasTemperature/OneWire.cpp.o: In function `OneWire::depower()':
Multiple libraries were found for "OneWire.h"
 Used: /home/peter/Documenten/Arduino/Sketches/libraries/OneWireStandard
 Not used: /home/peter/Documenten/Arduino/Sketches/libraries/DallasTemperature
/home/peter/Documenten/Arduino/Sketches/libraries/DallasTemperature/OneWire.cpp:163: multiple definition of `OneWire::reset()'
libraries/OneWireStandard/OneWire.cpp.o:/home/peter/Documenten/Arduino/Sketches/libraries/OneWireStandard/OneWire.cpp:163: first defined here
libraries/DallasTemperature/OneWire.cpp.o: In function `OneWire::search(unsigned char*, bool)':
/home/peter/Documenten/Arduino/Sketches/libraries/DallasTemperature/OneWire.cpp:197: multiple definition of `OneWire::write_bit(unsigned char)'
libraries/OneWireStandard/OneWire.cpp.o:/home/peter/Documenten/Arduino/Sketches/libraries/OneWireStandard/OneWire.cpp:197: first defined here
libraries/DallasTemperature/OneWire.cpp.o: In function `OneWire::read_bit()':
/home/peter/Documenten/Arduino/Sketches/libraries/DallasTemperature/OneWire.cpp:225: multiple definition of `OneWire::read_bit()'
libraries/OneWireStandard/OneWire.cpp.o:/home/peter/Documenten/Arduino/Sketches/libraries/OneWireStandard/OneWire.cpp:225: first defined here
libraries/DallasTemperature/OneWire.cpp.o: In function `OneWire::write(unsigned char, unsigned char)':
/home/peter/Documenten/Arduino/Sketches/libraries/DallasTemperature/OneWire.cpp:249: multiple definition of `OneWire::write
Last edited by Petervdpol on Fri Feb 09, 2018 2:17 am, edited 3 times in total.
User avatar
By destroyedlolo
#73758 Hi, it's look to me you're including your libraries twice :
- first as : /home/peter/Documenten/Arduino/Sketches/libraries/OneWireStandard/
- secondly as libraries/ which seems to be really /home/peter/Documenten/Arduino/Sketches/libraries/ . It's strange as on my own system, this directory is located in ~/Arduino/libraries

It's an IDE configuration issue, not related to DallasTemperature itself.

Bye

PS : I made my own library for 1wire probes (not only temperature ones, GPIO as well) : https://github.com/destroyedlolo/OWBus
I would be happy to get some feedback, testing or comment :)
PS2 : by the way, it will not solve your issue.
User avatar
By Petervdpol
#73798 Thank you for your reply, However, I suspect the IDE is confusing things since the OneWire lib is only included once, see below. There is however a OneWire.h in both OneWire (obviously) and the DallasTemperture lib...

Code: Select all#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <WiFiClient.h>
#include <OneWire.h>
#include <DallasTemperature.h>


//------------------------------------------
//DS18B20
#define ONE_WIRE_BUS D3 //Pin to which is attached a temperature sensor
#define ONE_WIRE_MAX_DEV 15 //The maximum number of devices

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
int numberOfDevices; //Number of temperature devices found
DeviceAddress devAddr[ONE_WIRE_MAX_DEV];  //An array device temperature sensors
float tempDev[ONE_WIRE_MAX_DEV]; //Saving the last measurement of temperature
float tempDevLast[ONE_WIRE_MAX_DEV]; //Previous temperature measurement
long lastTemp; //The last measurement
const int durationTemp = 5000; //The frequency of temperature measurement

//------------------------------------------
//WIFI
const char* ssid = "";
const char* password = "";

//------------------------------------------
//HTTP
ESP8266WebServer server(80);

//------------------------------------------
//Convert device id to String
String GetAddressToString(DeviceAddress deviceAddress) {
  String str = "";
  for (uint8_t i = 0; i < 8; i++) {
    if ( deviceAddress[i] < 16 ) str += String(0, HEX);
    str += String(deviceAddress[i], HEX);
  }
  return str;
}

//Setting the temperature sensor
void SetupDS18B20() {
  DS18B20.begin();

  Serial.print("Parasite power is: ");
  if ( DS18B20.isParasitePowerMode() ) {
    Serial.println("ON");
  } else {
    Serial.println("OFF");
  }

  numberOfDevices = DS18B20.getDeviceCount();
  Serial.print( "Device count: " );
  Serial.println( numberOfDevices );

  lastTemp = millis();
  DS18B20.requestTemperatures();

  // Loop through each device, print out address
  for (int i = 0; i < numberOfDevices; i++) {
    // Search the wire for address
    if ( DS18B20.getAddress(devAddr[i], i) ) {
      //devAddr[i] = tempDeviceAddress;
      Serial.print("Found device ");
      Serial.print(i, DEC);
      Serial.print(" with address: " + GetAddressToString(devAddr[i]));
      Serial.println();
    } else {
      Serial.print("Found ghost device at ");
      Serial.print(i, DEC);
      Serial.print(" but could not detect address. Check power and cabling");
    }

    //Get resolution of DS18b20
    Serial.print("Resolution: ");
    Serial.print(DS18B20.getResolution( devAddr[i] ));
    Serial.println();

    //Read temperature from DS18b20
    float tempC = DS18B20.getTempC( devAddr[i] );
    Serial.print("Temp C: ");
    Serial.println(tempC);
  }
}

//Loop measuring the temperature
void TempLoop(long now) {
  if ( now - lastTemp > durationTemp ) { //Take a measurement at a fixed time (durationTemp = 5000ms, 5s)
    for (int i = 0; i < numberOfDevices; i++) {
      float tempC = DS18B20.getTempC( devAddr[i] ); //Measuring temperature in Celsius
      tempDev[i] = tempC; //Save the measured value to the array
    }
    DS18B20.setWaitForConversion(false); //No waiting for measurement
    DS18B20.requestTemperatures(); //Initiate the temperature measurement
    lastTemp = millis();  //Remember the last time measurement
  }
}

//------------------------------------------
void HandleRoot() {
  String message = "Number of devices: ";
  message += numberOfDevices;
  message += "\r\n<br>";
  char temperatureString[6];

  message += "<table border='1'>\r\n";
  message += "<tr><td>Device id</td><td>Temperature</td></tr>\r\n";
  for (int i = 0; i < numberOfDevices; i++) {
    dtostrf(tempDev[i], 2, 2, temperatureString);
    Serial.print( "Sending temperature: " );
    Serial.println( temperatureString );

    message += "<tr><td>";
    message += GetAddressToString( devAddr[i] );
    message += "</td>\r\n";
    message += "<td>";
    message += temperatureString;
    message += "</td></tr>\r\n";
    message += "\r\n";
  }
  message += "</table>\r\n";

  server.send(200, "text/html", message );
}

void HandleNotFound() {
  String message = "File Not Found\n\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += (server.method() == HTTP_GET) ? "GET" : "POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";
  for (uint8_t i = 0; i < server.args(); i++) {
    message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
  }
  server.send(404, "text/html", message);
}


//------------------------------------------
void setup() {
  //Setup Serial port speed
  Serial.begin(115200);

  //Setup WIFI
  WiFi.begin(ssid, password);
  Serial.println("");

  //Wait for WIFI connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  server.on("/", HandleRoot);
  server.onNotFound( HandleNotFound );
  server.begin();
  Serial.println("HTTP server started at ip " + WiFi.localIP().toString() );

  //Setup DS18b20 temperature sensor
  SetupDS18B20();

}

void loop() {
  long t = millis();

  server.handleClient();
  TempLoop( t );
}