Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Issue with Dallas Temperature / One Wire library example

  1. #1
    Senior Member Constantin's Avatar
    Join Date
    Nov 2012
    Location
    In the yard with a 17' Dia. Ferris Wheel
    Posts
    1,408

    Issue with Dallas Temperature / One Wire library example

    Hi guys and gals,

    I found a bug in the Dallas Temperature library example and I wonder if anyone here has a suggestion how to fix it. If you have the Dallas Temperature Library, load the Multibus_simple example.

    If you try to compile, the compiler throws the following errors:
    Code:
    Multibus_simple:7: error: no matching function for call to 'OneWire::OneWire()'
     OneWire ds18x20[oneWirePinsCount];
                                     ^
    In file included from D:\Arduino\libraries\DallasTemperature\examples\Multibus_simple\Multibus_simple.ino:1:0:
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\OneWire/OneWire.h:269:5: note: candidate: OneWire::OneWire(uint8_t)
         OneWire( uint8_t pin);
         ^
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\OneWire/OneWire.h:269:5: note:   candidate expects 1 argument, 0 provided
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\OneWire/OneWire.h:254:7: note: candidate: constexpr OneWire::OneWire(const OneWire&)
    
     class OneWire
           ^
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\OneWire/OneWire.h:254:7: note:   candidate expects 1 argument, 0 provided
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\OneWire/OneWire.h:254:7: note: candidate: constexpr OneWire::OneWire(OneWire&&)
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\OneWire/OneWire.h:254:7: note:   candidate expects 1 argument, 0 provided
    
    Multibus_simple: In function 'void setup()':
    Multibus_simple:22: error: 'class OneWire' has no member named 'setPin'
         ds18x20[i].setPin(oneWirePins[i]);
                    ^
    Using library OneWire at version 2.3.2 in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\OneWire 
    Using library DallasTemperature at version 3.7.6 in folder: D:\Arduino\libraries\DallasTemperature 
    no matching function for call to 'OneWire::OneWire()'
    Is this a simple matter of going through the One-Wire library, note the changed functions, and then update the Dallas Temperature library?

    I hope I'm using the latest version of every library. Had the same issue with Arduino 1.8.6 on a different machine.

    Happy 4th everyone, Constantin
    Last edited by Constantin; 07-03-2017 at 02:17 PM.

  2. #2
    Senior Member Constantin's Avatar
    Join Date
    Nov 2012
    Location
    In the yard with a 17' Dia. Ferris Wheel
    Posts
    1,408
    Ok, so there may be more elegant solutions to the problem, but the below worked for me. Credit goes to the arduino forums.

    Change the top portion of the Multibus example from:

    int oneWirePins[]={3,7};//OneWire DS18x20 temperature sensors on these wires
    const int oneWirePinsCount=sizeof(oneWirePins)/sizeof(int);

    OneWire ds18x20[oneWirePinsCount];
    DallasTemperature sensor[oneWirePinsCount];
    to:

    int oneWirePins[]={3,7};//OneWire DS18x20 temperature sensors on these wires
    OneWire ds18x20[2]= {OneWire(oneWirePins[0]),OneWire(oneWirePins[1])};
    DallasTemperature sensor[2] = {DallasTemperature (&ds18x20[0]),DallasTemperature (&ds18x20[1])};
    Note, this is not as elegant as the original solution (simply define a array of DS18x20 pins and the program takes care of the rest) but it actually works, creating instances of the OneWire routine in an array that makes repetitive manipulation much easier. For example, I am working on a node system in my home where one LC manages 12 one-wire buses and 2 counters each. Very simple little system, but being able to address all those inputs in one for() loop makes it much easier to code.

  3. #3
    Senior Member KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    2,831
    I did a search and found the code, but wondered whose version of oneWire library they were using, as a lot of them all appear to be based off of Paul's code.

    My quick look through Paul's code that ships with Teensyduino (https://github.com/PaulStoffregen/OneWire)

    It looked like it would not be hard to get add an empty contructor and a new method: setPin which does what the other constructor does...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •