Thermal probes DS18B20

You are in luck. I was messing around with a DS18B20 just yesterday. This is for two probes, you can add more as needed. Although, I am not sure on the total amount allowed. Make sure you have the proper libraries installed as well.

You will need to add this,

#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS 14 //pin connected to DS18B20 Sensor(s)


OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

along with this in your setup()

 sensors.begin();

and this in a timer loop

  // request to all devices on the bus
  Serial.print("Requesting temperatures...");
  sensors.requestTemperatures(); // Send the command to get temperatures
  Serial.println("DONE");
  // After we got the temperatures, we can print them here.
  // We use the function ByIndex, and as an example get the temperature from the first sensor only.
  float temp1 = sensors.getTempCByIndex(0);
  float temp2 = sensors.getTempCByIndex(1);
  float temp1F = DallasTemperature::toFahrenheit(temp1);  //convert to F
  float temp2F = DallasTemperature::toFahrenheit(temp2); //convert to F
  Serial.print("Temperature for the device 1 (index 0) is: ");
  Serial.println(temp1F);
  Serial.print("Temperature for the device 1 (index 1) is: ");
  Serial.println(temp2F);
  Blynk.virtualWrite(V21, temp1F); //write to virtual pin for app
  Blynk.virtualWrite(V22, temp2F); //write to virtual pin for app

Hope this helps. Don’t forget to remove all the DHT11 stuff.

1 Like