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:
- OneWire-2.3.5
- DallasTemperature-3.9.0
(I've tried to re-import them of course)
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...