Dallas Temp failure to compile



  • Im trying to build my first sensor and im getting the following error.

    C:\Users\jrich\OneDrive\Documents\Arduino\libraries\DallasTemperature/DallasTemperature.h:249:13: error: 'int16_t DallasTemperature::millisToWaitForConversion(uint8_t)' is private
    
         int16_t millisToWaitForConversion(uint8_t);
    
                 ^
    
    DallasTemperatureSensor:79: error: within this context
    
       int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
    
                                                                                         ^
    
    exit status 1
    within this context
    

    I just downloaded and installed the libraries (i think successfully) but I noticed that towards the top where the libraries are defined the <MySensor.h> is all standard black text where as the <OneWire.h> has OneWire in orange (i assume this is ok, has to do with types of libraries?)

    also the error states that the function is private, which means im not allowed to call it?

    Arduino told me to update some libraries, one of them being the Dallas stuff, but it seems like this is an error with the sensors library not defining the millisToWaitForConversion as a public function?

    hope this is something simple im doing wrong, pretty new to all of this





  • Any news?



  • I'm also having this problem. Doesn't matter if I downgrade to a previous version of DallasTemperature.

    Any progress on this or advice on how to solve this?

    The issue seems to be closed, strange...

    Thanks!



  • I was having way too many problems with the radios and code so I gave up and started to use beagle bone and just use domoticz api



  • Is there any resolution for this?
    I am facing the same problem and i do not know how to fix this.

    Edit, i found something.
    You need to comment out these lines:

    Only this way it compiles and sensors do work.
    I don't know what happens so maybe somebody with knowledge can explain this?

    //int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
      
        // sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater)
      //sleep(conversionTime);```

  • Hardware Contributor

    Edit, i found something.
    You need to comment out these lines:

    If you do that you don't leave enough time for your sensor to compute the temperature, your readings will be wrong.

    There is no problem with MySensors 2, and examples + libraries downloaded from MySensors' GitHub, I just tried and it builds.
    Go there: https://github.com/mysensors/
    Then select "MySensorsArduinoExamples" and download. Then you can copy the libraries directory in your arduino directory (you can override existing files), and the examples directory in [Arduino directory]\libraries\MySensors\ it will override old examples if they are already here.



  • @tlpeter
    This is my function to read all Sensors. You have to give the Sensor time to do the measuring and make the result available.
    I've commented everything out to get the min wait time. It is defined in the Datasheet of the Sensor
    alt text
    If you wait or sleep for 750ms you are save. Depending on the resultion of the sensor you can wait a bit less.

    void readDallasSensors()
    {
      // Fetch temperatures from Dallas sensors
      TempSensors.requestTemperatures();
      // query conversion time and sleep until conversion completed
      //int16_t conversionTime = TempSensors.millisToWaitForConversion(TempSensors.getResolution());
      // sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater)
      sleep(750);
      // Read temperatures and send them to controller
      for (int i = 0; i < numTempSensors && i < MAX_ATTACHED_DS18B20; i++)
      {
        // Fetch and round temperature to one decimal
        float temperature = TempSensors.getTempCByIndex(i);
    #ifdef DEBUG
        SPrint(Temperature: );
        Serial.println(temperature, 1);
    #endif
    
        // Only send data if temperature has changed and no error
        if (abs(lastTemperature[i] - temperature) >= 0.1 && temperature != -127.00 && temperature != 85.00)
        {
          // Send in the new temperature
          send(msg.setSensor(i).set(temperature, 1));
          // Save new temperatures for next compare
          lastTemperature[i] = temperature;
        }
      }
    


  • It does not compile an di am not the only one saying that.
    See this error:

    Arduino: 1.6.9 (Windows 10), Board: "Arduino/Genuino Uno"
    
    In file included from C:\Users\Peter\AppData\Local\Temp\arduino_modified_sketch_224748\DallasTemperatureSensor.ino:37:0:
    
    C:\Users\Peter\Documents\Arduino\libraries\DallasTemperature/DallasTemperature.h: In function 'void loop()':
    
    C:\Users\Peter\Documents\Arduino\libraries\DallasTemperature/DallasTemperature.h:252:13: error: 'int16_t DallasTemperature::millisToWaitForConversion(uint8_t)' is private
    
         int16_t millisToWaitForConversion(uint8_t);
    
                 ^
    
    DallasTemperatureSensor:81: error: within this context
    
       int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
    
                                                                                         ^
    
    exit status 1
    within this context
    
    This report would have more information with
    "Show verbose output during compilation"
    option enabled in File -> Preferences.
    


  • @Hermann-Kaiser said:

    @tlpeter
    This is my function to read all Sensors. You have to give the Sensor time to do the measuring and make the result available.
    I've commented everything out to get the min wait time. It is defined in the Datasheet of the Sensor
    alt text
    If you wait or sleep for 750ms you are save. Depending on the resultion of the sensor you can wait a bit less.

    void readDallasSensors()
    {
      // Fetch temperatures from Dallas sensors
      TempSensors.requestTemperatures();
      // query conversion time and sleep until conversion completed
      //int16_t conversionTime = TempSensors.millisToWaitForConversion(TempSensors.getResolution());
      // sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater)
      sleep(750);
      // Read temperatures and send them to controller
      for (int i = 0; i < numTempSensors && i < MAX_ATTACHED_DS18B20; i++)
      {
        // Fetch and round temperature to one decimal
        float temperature = TempSensors.getTempCByIndex(i);
    #ifdef DEBUG
        SPrint(Temperature: );
        Serial.println(temperature, 1);
    #endif
    
        // Only send data if temperature has changed and no error
        if (abs(lastTemperature[i] - temperature) >= 0.1 && temperature != -127.00 && temperature != 85.00)
        {
          // Send in the new temperature
          send(msg.setSensor(i).set(temperature, 1));
          // Save new temperatures for next compare
          lastTemperature[i] = temperature;
        }
      }
    

    That indeed works but still the example has some kind of an error or is not good enough for beginners like me 🙂
    Thanks, this works fine.


  • Hero Member

    @tlpeter yes there seems to be a problem once you update the library. Even if you roll back the problem persists. If you want to use the MySensors Dallas temp sketch as it is then you need to manually replace the library with the older 3.7.2 and then it will work.

    I have uploaded the library in zip format. @hek I hope that it is OK to upload zip files

    0_1470911411126_DallasTemperature.zip


  • Hardware Contributor

    error: 'int16_t DallasTemperature::millisToWaitForConversion(uint8_t)' is private
    

    You are using an old version of the library, if you get the library from MySensors GitHub then the method is not private (like in the current version of the library you use) and it will compile.



  • Thanks, that works fine.
    How come that i have an old library? i use the 2.0.0 version
    Is this perhaps a known issue which will be fixed soon?


  • Admin

    It's not related to mysensors core library.

    Also, as mentioned before in this thread, the Dallas library that is in the arduino examples repository, is working.

    Are you sure that you are using the right libraries?



  • I tihnk so, i used libraries that i was pointed too as they are moved.
    All other sensors i have been playing with are working fine.


  • Hardware Contributor

    @tlpeter it is because now the libraries which are not managed by MySensors project were moved to another repository. It means if you only updated MySensors, you kept the old libraries.



  • I removed everything and started from scratch and after that i copied the mysensors-master library.


  • Hardware Contributor

    @tlpeter said:

    I removed everything and started from scratch and after that i copied the mysensors-master library.

    "removed everything" in MySensors directory ? That's not enough, as the third party libraries are in the libraries directory of Arduino



  • I uninstalled that too.
    I really removed everything.
    Uninstalled arduino and removed the folders in the program files folder and the my documents folder too.



  • why not put the function millisToWaitForConversion into the example.
    I like to have the latest libary available for sensors. It can be loaded with the arduino studio.
    Read the min wait time is pretty easy. it is just a switch case based on the datasheet.

    // returns number of milliseconds to wait till conversion is complete (based on IC datasheet)
    int16_t DallasTemperature::millisToWaitForConversion(uint8_t bitResolution)
    {
        switch (bitResolution)
        {
        case 9:
            return 94;
        case 10:
            return 188;
        case 11:
            return 375;
        default:
            return 750;
        }
    }
    

  • Admin

    @tlpeter

    Ok, so you are using a newer version of the DallasTemperature library, than the one that we have supplied in our MySensorsArduinoExamples. And yes, it seems that they have made millisToWaitForConversion() a private function there. Or someone has changed the library we included in our repository at some point in time, so it is made public.

    There are 2 options, as I see it 🙂

    1. Use the library that we have supplied in MySensorsArduinoExamples
    2. Make a PR against the original library, found here, and make the millisToWaitForConversion() public, and get them to release a new version of the library.

    🙂


  • Mod

    The millisToWaitForConversion has always been private in milesburton's library, so the answer is the latter: someone has changed the library we included in our repository at some point in time.

    I found the answer in git:

    commit e47e596075282b122ac5d266ec6ad5c60ca8c978
    Author: Robo Print <roboprint@users.noreply.github.com>
    Date:   Sat Jun 27 23:00:37 2015 +0200
    
        Make DallasTemperature::millisToWaitForConversion() publicly available
    

    I agree with tbowmo's options.



  • It's my code 😱

    I changed this method from private to public, this function is used to determine wait time needed for right non-blocking wait call. Seems like I should make PR to original library instead of modifying MYS copy.


Log in to reply
 

Suggested Topics

  • 3
  • 15
  • 3
  • 1
  • 2
  • 2

1
Online

11.2k
Users

11.1k
Topics

112.5k
Posts