Reputation: 11
I'm trying to gather temperature from my temperature sensor and i'm facing this error :
/home/myuser/sketchbook/libraries/DallasTemperature/DallasTemperature.cpp: In member function ‘void DallasTemperature::blockTillConversionComplete(uint8_t)’: /home/myuser/sketchbook/libraries/DallasTemperature/DallasTemperature.cpp:446:13: error: ‘yield’ was not declared in this scope yield(); ^
/home/myuser/sketchbook/libraries/DallasTemperature/DallasTemperature.cpp: In member function ‘bool DallasTemperature::recallScratchPad(const uint8_t*)’: /home/myuser/sketchbook/libraries/DallasTemperature/DallasTemperature.cpp:543:11: error: >‘yield’ was not declared in this scope yield();
This is my code, based on https://www.instructables.com/id/How-to-use-DS18B20-Temperature-Sensor-Arduino-Tuto/ :
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 8
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature tempSensor(&oneWire);
void setup()
{
Serial.begin(9600);
}
void loop()
{
tempSensor.requestTemperatures();
float temperatureC = tempSensor.getTempCByIndex(0);
Serial.println(temperatureC);
}
Librairies versions:
Code in DallasTemperature.cpp where the error seems to refer :
// Sends command to one or more devices to recall values from EEPROM to scratchpad
// If optional argument deviceAddress is omitted the command is send to all devices
// Returns true if no errors were encountered, false indicates failure
bool DallasTemperature::recallScratchPad(const uint8_t* deviceAddress) {
if (_wire->reset() == 0)
return false;
if (deviceAddress == nullptr)
_wire->skip();
else
_wire->select(deviceAddress);
_wire->write(RECALLSCRATCH,parasite);
// Specification: Strong pullup only needed when writing to EEPROM (and temp conversion)
unsigned long start = millis();
while (_wire->read_bit() == 0) {
// Datasheet doesn't specify typical/max duration, testing reveals typically within 1ms
if (millis() - start > 20) return false;
yield();
}
return _wire->reset() == 1;
}
I'm here because I found nothing about an error involving "yield()" and DallasTemperature on Google...
Upvotes: 1
Views: 2117
Reputation: 11
DallasTemperature-3.9.0 came out on 2020-09-02, my project was a little older, I first created it before and I couldn't finish it since. I was using 3.8.0 version, I re-installed it and it worked again.
Upvotes: 0
Reputation: 5331
Some platforms do not implement yield
so you can remove the call to it from the code of the library. Calling yield
passes control to other tasks, if you do not have other tasks, it is redundant anyway.
Removing it can be done by providing an empty implementation at the top of the file.
If you are sure that your board should support it. Than it is possible that you are using a wrong software stack. Try to download the official Arduino IDE.
Upvotes: -1