Dallas Temp failure to compile
-
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. -
@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

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; } }@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

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. -
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);```@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
-
error: 'int16_t DallasTemperature::millisToWaitForConversion(uint8_t)' is privateYou 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? -
I removed everything and started from scratch and after that i copied the mysensors-master library.
@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
-
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; } } -
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 :)
- Use the library that we have supplied in MySensorsArduinoExamples
- 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.
:)
-
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 :)
- Use the library that we have supplied in MySensorsArduinoExamples
- 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.
:)
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 availableI agree with tbowmo's options.
-
It's my code :scream:
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.