/* DS18B20 1-Wire digital temperature sensor with Arduino example code. More info: https://www.makerguides.com */
// Include the required Arduino libraries:
#include "OneWire.h"
#include "DallasTemperature.h"
// Define to which pin of the Arduino the 1-Wire bus is connected:
#define ONE_WIRE_BUS_4 4
#define ONE_WIRE_BUS_5 5
// Create a new instance of the oneWire class to communicate with any OneWire device:
OneWire oneWire_4(ONE_WIRE_BUS_4);
OneWire oneWire_5(ONE_WIRE_BUS_5);
// Pass the oneWire reference to DallasTemperature library:
DallasTemperature sensors_4(&oneWire_4);
DallasTemperature sensors_5(&oneWire_5);
void setup() {
// Begin serial communication at a baud rate of 9600:
Serial.begin(9600);
// Start up the library:
sensors_4.begin();
sensors_5.begin();
}
void Sensor_4_Ven()
{
sensors_4.requestTemperatures();
// Fetch the temperature in degrees Celsius for device index:
float tempC_4 = sensors_4.getTempCByIndex(0); // the index 0 refers to the first device
// Print the temperature in Celsius in the Serial Monitor:
Serial.print("Temperature 4: ");
Serial.print(tempC_4);
Serial.print(" \xC2\xB0"); // shows degree symbol
Serial.print("C "); Serial.println("");
}
// ------------------------------------------------------------------------------
void Sensor_5_Ven()
{
sensors_5.requestTemperatures();
// Fetch the temperature in degrees Celsius for device index:
float tempC_5 = sensors_5.getTempCByIndex(0); // the index 0 refers to the first device
// Print the temperature in Celsius in the Serial Monitor:
Serial.print("Temperature 5: ");
Serial.print(tempC_5);
Serial.print(" \xC2\xB0"); // shows degree symbol
Serial.print("C "); Serial.println("");
}
void loop() {
// Send the command for all devices on the bus to perform a temperature conversion:
Sensor_4_Ven() ;
delay(5000);
Sensor_5_Ven() ;
// Wait 1 second:
delay(5000);
// ----------------------------------------------------------------------------------------
}
Loading
esp32-s3-devkitc-1
esp32-s3-devkitc-1
Loading
ds18b20
ds18b20
Loading
ds18b20
ds18b20