#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 2 // визначаємо номер піна для зчитування даних з датчиків
OneWire oneWire(ONE_WIRE_BUS); // створюємо об'єкт OneWire
DallasTemperature sensors(&oneWire); // створюємо об'єкт DallasTemperature
void setup() {
Serial.begin(9600); // ініціалізуємо зв'язок з комп'ютером
sensors.begin(); // ініціалізуємо датчики
}
void loop() {
sensors.requestTemperatures(); // запитуємо температури з датчиків
float temp1 = sensors.getTempCByIndex(0); // зчитуємо температуру з першого датчика
float temp2 = sensors.getTempCByIndex(1); // зчитуємо температуру з другого датчика
Serial.print("Temperature 1: ");
Serial.print(temp1);
Serial.print("C, Temperature 2: ");
Serial.print(temp2);
Serial.println("C");
delay(1000); // затримка 1 секунда
}
Loading
ds18b20
ds18b20
Loading
ds18b20
ds18b20