I don’t know if it matters, but the returned value is a float
, not int
Index(0)
is only one sensor, you’ll need an Index(1)
for the second sensor.
To speed up readings (and to know which is where) I’m accessing the sensors by their unique ID instead. Setup like this:
const byte ONE_WIRE_BUS = 3;
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
byte sensor1E[] = { 0x28, 0xFF, 0x65, 0x5B, 0x90, 0x15, 0x3, 0x1E };
byte sensor4B[] = { 0x28, 0xFF, 0x9C, 0x5B, 0x90, 0x15, 0x3, 0x4B };
And my function is something like this:
float temp1E = DS18B20.getTempC(sensor1E);
float temp4B = DS18B20.getTempC(sensor4B);
Blynk.virtualWrite(6, temp1E);
Blynk.virtualWrite(5, temp4B);
The DS18B20:s EEPROM is specified to handle +50.000 rewrites (it stores the data before sending) without failure, but reading the sensors once every 2 seconds equals 43.200 readings a day! So I recommend that you ease up on frequency as a precaution.
Good luck!