I have two temperature sensors, an MCP9808 and a DS18B20, connected to an arduino and I've read that it could be advantageous to set a small delay between temperature readings. What I wonder is where I should set the delay, in the setup function:
tempsensor.begin(); //initialize communication with mcp9808
sensors.begin(); //initialize communication with dc18b20
readSensors();
or the readSensors function?:
temp = tempsensor.readTempC(); //read current temperature and save value inside "temp"
sensors.requestTemperatures(); // Send the command to get temperatures
temp2 = sensors.getTempCByIndex(0);
As you can probably tell I am very new to all of this, intuition tells me that I should set the delay within the readSensors function.
Any alternative suggestions about how I should be readings temperature data from two different sensors connected to one arduino would be appreciated.
EDIT
after re-reading question and based on first answer I haven't made it unequivocally clear my intention; I want to delay the time between the mcp9808 and the ds18b20 temperature readings, so that it waits X seconds between each. I have read that this may help to reduce noise.