// Include the library to establish communication by means of 1-Wire protocol #include // Include the library to communicate with the sensors #include // Define the Arduino pin that will be used with 1-Wire protocol #define ONE_WIRE_BUS 8 // Create a "oneWire" class to work on the designated pin OneWire oneWire(ONE_WIRE_BUS); // Pass the data from the 1-Wire protocol to the Dallas library in a new class DallasTemperature sensors(&oneWire); void setup() { // Initialize the serial port Serial.begin(9600); // Start message Serial.println("Temperature request example"); // Initialize the 1-Wire protocol and the sensor sensors.begin(); } void loop() { // Query the temperature of the device Serial.print("Requesting temperature..."); sensors.requestTemperatures(); Serial.println(""); // Print the temperature value Serial.print("The plant's temperature is: "); Serial.println(sensors.getTempCByIndex(0)); }