OneWire and DallasTemperature libraries under 1.0 beta

Hi,

I'm trying to implement an Ethernet attached thermometer (with multiple Dallas temp sensors). I need DNS and DHCP, so have used the new 1.0 beta environment, which for other (Ethernet attached, non onewire) projects is working great.

When using the OneWire and DallasTemperature libraries under 1.0 beta I'm getting a ton of errors at compile time. I think this is down to OneWire calling core code that has moved/ been updated. I can't use a different OneWire as DallasTemperature uses it - and makes it all so simple.

C:\arduino-1.0-beta1\libraries\OneWire\OneWire.cpp:85:24: error: WConstants.h: No such file or directory
C:\arduino-1.0-beta1\libraries\OneWire\OneWire.cpp: In constructor 'OneWire::OneWire(uint8_t)':
C:\arduino-1.0-beta1\libraries\OneWire\OneWire.cpp:93: error: 'digitalPinToBitMask' was not declared in this scope
C:\arduino-1.0-beta1\libraries\OneWire\OneWire.cpp:94: error: 'digitalPinToPort' was not declared in this scope
C:\arduino-1.0-beta1\libraries\OneWire\OneWire.cpp:94: error: 'portInputRegister' was not declared in this scope
C:\arduino-1.0-beta1\libraries\OneWire\OneWire.cpp: In member function 'uint8_t OneWire::reset()':
C:\arduino-1.0-beta1\libraries\OneWire\OneWire.cpp:127: error: 'delayMicroseconds' was not declared in this scope
C:\arduino-1.0-beta1\libraries\OneWire\OneWire.cpp:134: error: 'delayMicroseconds' was not declared in this scope
C:\arduino-1.0-beta1\libraries\OneWire\OneWire.cpp: In member function 'void OneWire::write_bit(uint8_t)':
C:\arduino-1.0-beta1\libraries\OneWire\OneWire.cpp:157: error: 'delayMicroseconds' was not declared in this scope
C:\arduino-1.0-beta1\libraries\OneWire\OneWire.cpp:165: error: 'delayMicroseconds' was not declared in this scope
C:\arduino-1.0-beta1\libraries\OneWire\OneWire.cpp: In member function 'uint8_t OneWire::read_bit()':
C:\arduino-1.0-beta1\libraries\OneWire\OneWire.cpp:185: error: 'delayMicroseconds' was not declared in this scope

Is there a solution other than using the 'new' OneWire library in 1.0 and a much more complex piece of code that doesnt use the lovely DallasTemperature library?

Thanks.

Replace the #include "WConstants.h" with #include "Arduino.h" in OneWire.cpp.

Thanks Paul, but unfortunately I’m now getting more errors from seemingly deep inside the sytem. This is a new development environment installed today (ie not an upgrade from older) and first tested on a few trivial ‘blink’ type sketches:

The DallasTemp example program produces the same errors - fairly sure it isn’t my sketch itself.

In file included from C:\arduino-1.0-beta1\hardware\arduino\cores\arduino/Arduino.h:182,
                 from C:\arduino-1.0-beta1\libraries\OneWire\OneWire.cpp:85:
C:\arduino-1.0-beta1\hardware\arduino\cores\arduino/WString.h:116: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, const char*)' conflicts with
C:\arduino-1.0-beta1\hardware\arduino\cores\arduino/WString.h:115: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, const String&)' here
C:\arduino-1.0-beta1\hardware\arduino\cores\arduino/WString.h:117: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, char)' conflicts with
C:\arduino-1.0-beta1\hardware\arduino\cores\arduino/WString.h:116: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, const char*)' here
C:\arduino-1.0-beta1\hardware\arduino\cores\arduino/WString.h:118: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, unsigned char)' conflicts with
C:\arduino-1.0-beta1\hardware\arduino\cores\arduino/WString.h:117: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, char)' here
C:\arduino-1.0-beta1\hardware\arduino\cores\arduino/WString.h:119: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, int)' conflicts with
C:\arduino-1.0-beta1\hardware\arduino\cores\arduino/WString.h:118: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, unsigned char)' here
C:\arduino-1.0-beta1\hardware\arduino\cores\arduino/WString.h:120: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, unsigned int)' conflicts with
C:\arduino-1.0-beta1\hardware\arduino\cores\arduino/WString.h:119: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, int)' here
C:\arduino-1.0-beta1\hardware\arduino\cores\arduino/WString.h:121: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, long int)' conflicts with
C:\arduino-1.0-beta1\hardware\arduino\cores\arduino/WString.h:120: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, unsigned int)' here
C:\arduino-1.0-beta1\hardware\arduino\cores\arduino/WString.h:122: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, long unsigned int)' conflicts with
C:\arduino-1.0-beta1\hardware\arduino\cores\arduino/WString.h:121: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, long int)' here
In file included from C:\arduino-1.0-beta1\libraries\OneWire\OneWire.cpp:85:
C:\arduino-1.0-beta1\hardware\arduino\cores\arduino/Arduino.h:186: error: declaration of C function 'uint16_t makeWord(byte, byte)' conflicts with
C:\arduino-1.0-beta1\hardware\arduino\cores\arduino/Arduino.h:185: error: previous declaration 'uint16_t makeWord(uint16_t)' here
C:\arduino-1.0-beta1\hardware\arduino\cores\arduino/Arduino.h:196: error: declaration of C function 'long int random(long int)' conflicts with
c:/arduino-1.0-beta1/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:504: error: previous declaration 'long int random()' here
C:\arduino-1.0-beta1\hardware\arduino\cores\arduino/Arduino.h:197: error: declaration of C function 'long int random(long int, long int)' conflicts with
C:\arduino-1.0-beta1\hardware\arduino\cores\arduino/Arduino.h:196: error: previous declaration 'long int random(long int)' here

I noticed similar problems with trying to use the “new” OneWire library (v2.1) and the TCL3.7.1 library to read the Dallas Semiconductors temperature sensor chip.

I’ve noticed that, in the least, “WConstants.h” is missing as well as “wiring.h” from <install_dir>\arduino\hardware\cores\arduino
There may be other files missing also.

When i copied both of these files from an old version of the Arduino software (arduino022), the compiles worked fine.

Mark

Quick and dirty but helps:

Modify Onewire.cpp to

#include "Arduino.h"

extern "C" {
//#include "WConstants.h"
#include "Arduino.h"
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
}

and DallasTemperature to

#include "DallasTemperature.h"
#include "Arduino.h"
extern "C" {
  //#include "WConstants.h"
#include "Arduino.h"
}

Pay attention to the additional #include “Arduino.h” at the top of extern “C” {

Hello, I have read this forum and others and I have used the resources presented here: http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html. I am a college student working on a project so I am sure that I am not nearly as knowledgeable as most others on here but I am getting these errors even after altering the code in the suggested way:

E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp:92: error: 'OneWire' has not been declared E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp:92: error: ISO C++ forbids declaration of 'OneWire' with no type E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp: In function 'int OneWire(uint8_t)': E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp:94: error: 'bitmask' was not declared in this scope E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp:95: error: 'baseReg' was not declared in this scope E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp: At global scope: E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp:115: error: 'OneWire' is not a class or namespace E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp: In function 'uint8_t reset()': E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp:117: error: 'bitmask' was not declared in this scope E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp:118: error: 'baseReg' was not declared in this scope E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp: At global scope: E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp:149: error: 'OneWire' is not a class or namespace E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp: In function 'void write_bit(uint8_t)': E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp:151: error: 'bitmask' was not declared in this scope E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp:152: error: 'baseReg' was not declared in this scope E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp: At global scope: E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp:177: error: 'OneWire' is not a class or namespace E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp: In function 'uint8_t read_bit()': E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp:179: error: 'bitmask' was not declared in this scope E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp:180: error: 'baseReg' was not declared in this scope E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp: At global scope: E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp:202: error: 'OneWire' is not a class or namespace E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp: In function 'void write(uint8_t, uint8_t)': E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp:206: error: 'OneWire' is not a class or namespace E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp:210: error: 'baseReg' was not declared in this scope E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp:210: error: 'bitmask' was not declared in this scope E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp: At global scope: E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp:219: error: 'OneWire' is not a class or namespace E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp: In function 'uint8_t read()': E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp:224: error: 'OneWire' is not a class or namespace E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp: At global scope: E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp:232: error: 'OneWire' is not a class or namespace E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp: In function 'void select(uint8_t*)': E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp:202: error: too few arguments to function 'void write(uint8_t, uint8_t)' E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp:236: error: at this point in file E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp:202: error: too few arguments to function 'void write(uint8_t, uint8_t)' E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp:238: error: at this point in file E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp: At global scope: E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp:244: error: 'OneWire' is not a class or namespace E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp: In function 'void skip()': E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp:202: error: too few arguments to function 'void write(uint8_t, uint8_t)' E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp:246: error: at this point in file E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp: At global scope: E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp:249: error: 'OneWire' is not a class or namespace E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp: In function 'void depower()': E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp:252: error: 'baseReg' was not declared in this scope E:\Arduino\arduino-1.0\libraries\OneWire\OneWire.cpp:252: error: 'bitmask' was not declared in this scope

I am just trying to learn how to get the temperature from a Maxim DS18B20 1-wire digital thermometer. I apologize in advance for any idiot mistakes I have made and thank you for the assistance.

Nevermind, I don't exactly know how it all went down but it works now. Thank you.

I had an issue getting Onewire library to compile after Arduino 1.0 was released. I got it to work by adding this to the top of DallasTemperature.cpp

#include "DallasTemperature.h"

extern "C" {
#if ARDUINO >= 100       // if Arduino version 1.0+
#include "Arduino.h"      // for delayMicroseconds,digitalPinToBitMask, etc
#else
#include "WProgram.h"      // for delayMicroseconds
#include "pins_arduino.h"  // for digitalPinToBitMask, etc
#endif
}

Wizzzz:
Quick and dirty but helps:

Modify Onewire.cpp to

#include "Arduino.h"

extern “C” {
//#include “WConstants.h”
#include “Arduino.h”
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
}




and DallasTemperature to



#include “DallasTemperature.h”
#include “Arduino.h”
extern “C” {
  //#include “WConstants.h”
#include “Arduino.h”
}




Pay attention to the additional #include "Arduino.h" at the top of extern "C" {

:stuck_out_tongue: It does work.

OneWire\OneWire.cpp.o: In function OneWire::reset()': C:\Users\CLOUD\Documents\Arduino\libraries\OneWire-master/OneWire.cpp:143: multiple definition ofOneWire::reset()' OneWire.cpp.o:C:\Users\CLOUD\AppData\Local\Temp\build1972404149517919556.tmp/OneWire.cpp:143: first defined here OneWire\OneWire.cpp.o: In function OneWire::reset()': C:\Users\CLOUD\Documents\Arduino\libraries\OneWire-master/OneWire.cpp:143: multiple definition ofOneWire::write_bit(unsigned char)' OneWire.cpp.o:C:\Users\CLOUD\AppData\Local\Temp\build1972404149517919556.tmp/OneWire.cpp:143: first defined here OneWire\OneWire.cpp.o: In function OneWire::reset()': C:\Users\CLOUD\Documents\Arduino\libraries\OneWire-master/OneWire.cpp:143: multiple definition ofOneWire::read_bit()' OneWire.cpp.o:C:\Users\CLOUD\AppData\Local\Temp\build1972404149517919556.tmp/OneWire.cpp:143: first defined here OneWire\OneWire.cpp.o: In function OneWire::reset()': C:\Users\CLOUD\Documents\Arduino\libraries\OneWire-master/OneWire.cpp:143: multiple definition ofOneWire::write(unsigned char, unsigned char)' OneWire.cpp.o:C:\Users\CLOUD\AppData\Local\Temp\build1972404149517919556.tmp/OneWire.cpp:143: first defined here OneWire\OneWire.cpp.o: In function OneWire::reset()': C:\Users\CLOUD\Documents\Arduino\libraries\OneWire-master/OneWire.cpp:143: multiple definition ofOneWire::write_bytes(unsigned char const*, unsigned int, bool)' OneWire.cpp.o:C:\Users\CLOUD\AppData\Local\Temp\build1972404149517919556.tmp/OneWire.cpp:143: first defined here OneWire\OneWire.cpp.o: In function OneWire::reset()': C:\Users\CLOUD\Documents\Arduino\libraries\OneWire-master/OneWire.cpp:143: multiple definition ofOneWire::read()' OneWire.cpp.o:C:\Users\CLOUD\AppData\Local\Temp\build1972404149517919556.tmp/OneWire.cpp:143: first defined here OneWire\OneWire.cpp.o: In function OneWire::reset()': C:\Users\CLOUD\Documents\Arduino\libraries\OneWire-master/OneWire.cpp:143: multiple definition ofOneWire::read_bytes(unsigned char*, unsigned int)' OneWire.cpp.o:C:\Users\CLOUD\AppData\Local\Temp\build1972404149517919556.tmp/OneWire.cpp:143: first defined here OneWire\OneWire.cpp.o: In function OneWire::reset()': C:\Users\CLOUD\Documents\Arduino\libraries\OneWire-master/OneWire.cpp:143: multiple definition ofOneWire::select(unsigned char const*)' OneWire.cpp.o:C:\Users\CLOUD\AppData\Local\Temp\build1972404149517919556.tmp/OneWire.cpp:143: first defined here OneWire\OneWire.cpp.o: In function OneWire::reset()': C:\Users\CLOUD\Documents\Arduino\libraries\OneWire-master/OneWire.cpp:143: multiple definition ofOneWire::skip()' OneWire.cpp.o:C:\Users\CLOUD\AppData\Local\Temp\build1972404149517919556.tmp/OneWire.cpp:143: first defined here OneWire\OneWire.cpp.o: In function OneWire::reset()': C:\Users\CLOUD\Documents\Arduino\libraries\OneWire-master/OneWire.cpp:143: multiple definition ofOneWire::depower()' OneWire.cpp.o:C:\Users\CLOUD\AppData\Local\Temp\build1972404149517919556.tmp/OneWire.cpp:143: first defined here OneWire\OneWire.cpp.o: In function OneWire::reset()': C:\Users\CLOUD\Documents\Arduino\libraries\OneWire-master/OneWire.cpp:143: multiple definition ofOneWire::reset_search()' OneWire.cpp.o:C:\Users\CLOUD\AppData\Local\Temp\build1972404149517919556.tmp/OneWire.cpp:143: first defined here OneWire\OneWire.cpp.o: In function OneWire::reset()': C:\Users\CLOUD\Documents\Arduino\libraries\OneWire-master/OneWire.cpp:143: multiple definition ofOneWire::OneWire(unsigned char)' OneWire.cpp.o:C:\Users\CLOUD\AppData\Local\Temp\build1972404149517919556.tmp/OneWire.cpp:143: first defined here OneWire\OneWire.cpp.o: In function OneWire::reset()': C:\Users\CLOUD\Documents\Arduino\libraries\OneWire-master/OneWire.cpp:143: multiple definition ofOneWire::OneWire(unsigned char)' OneWire.cpp.o:C:\Users\CLOUD\AppData\Local\Temp\build1972404149517919556.tmp/OneWire.cpp:143: first defined here OneWire\OneWire.cpp.o: In function OneWire::reset()': C:\Users\CLOUD\Documents\Arduino\libraries\OneWire-master/OneWire.cpp:143: multiple definition ofOneWire::target_search(unsigned char)' OneWire.cpp.o:C:\Users\CLOUD\AppData\Local\Temp\build1972404149517919556.tmp/OneWire.cpp:143: first defined here OneWire\OneWire.cpp.o: In function OneWire::reset()': C:\Users\CLOUD\Documents\Arduino\libraries\OneWire-master/OneWire.cpp:143: multiple definition ofOneWire::search(unsigned char*, bool)' OneWire.cpp.o:C:\Users\CLOUD\AppData\Local\Temp\build1972404149517919556.tmp/OneWire.cpp:143: first defined here OneWire\OneWire.cpp.o: In function OneWire::reset()': C:\Users\CLOUD\Documents\Arduino\libraries\OneWire-master/OneWire.cpp:143: multiple definition ofOneWire::crc8(unsigned char const*, unsigned char)' OneWire.cpp.o:C:\Users\CLOUD\AppData\Local\Temp\build1972404149517919556.tmp/OneWire.cpp:143: first defined here OneWire\OneWire.cpp.o: In function OneWire::reset()': C:\Users\CLOUD\Documents\Arduino\libraries\OneWire-master/OneWire.cpp:143: multiple definition ofOneWire::crc16(unsigned char const*, unsigned int, unsigned int)' OneWire.cpp.o:C:\Users\CLOUD\AppData\Local\Temp\build1972404149517919556.tmp/OneWire.cpp:143: first defined here OneWire\OneWire.cpp.o: In function OneWire::reset()': C:\Users\CLOUD\Documents\Arduino\libraries\OneWire-master/OneWire.cpp:143: multiple definition ofOneWire::check_crc16(unsigned char const*, unsigned int, unsigned char const*, unsigned int)' OneWire.cpp.o:C:\Users\CLOUD\AppData\Local\Temp\build1972404149517919556.tmp/OneWire.cpp:143: first defined here collect2.exe: error: ld returned 1 exit status Multiple libraries were found for "OneWire.h" Used: C:\Users\CLOUD\Documents\Arduino\libraries\OneWire-master Not used: C:\Program Files (x86)\Arduino\libraries\OneWire-master Erreur lors de la compilation.

Multiple libraries were found for "OneWire.h"

Why? Fix that problem!