DS1820 temperature sensor Stainless steel package Waterproof

DS1820 Stainless steel package Waterproof DS18b20 temperature probe temperature sensor 18B20


20 ₪

الناشر: متجر القطع الالكترونية

القسم: مستشعرات - سينسور

تاريخ النشر: 2022-10-04





basic



Arduino circuit



ESP32 circuit



ESP8266 circuit



Install Library



arduino-dallas-temperature-library



arduino-onewire-library



code
نسخ
اقتباس
عرض
تنزيل
	
								
/* DS18B20 */ #include <OneWire.h> #include <DallasTemperature.h> const int ds18b20_pin = 4; // ds18b20 is connected to GPIO 4 OneWire oneWire(ds18b20_pin); // setup a oneWire instance DallasTemperature tempSensor(&oneWire); // pass oneWire to DallasTemperature library float tempCelsius; // temperature in Celsius float tempFahrenheit; // temperature in Fahrenheit void setup() { Serial.begin(9600); // initialize serial tempSensor.begin(); // initialize the sensor } void loop() { tempSensor.requestTemperatures(); // send the command to get temperatures tempCelsius = tempSensor.getTempCByIndex(0); // read temperature in Celsius tempFahrenheit = tempCelsius * 9 / 5 + 32; // convert Celsius to Fahrenheit Serial.print("Temperature: "); Serial.print(tempCelsius); // print the temperature in Celsius Serial.print("°C"); Serial.print(" ~ "); // separator between Celsius and Fahrenheit Serial.print(tempFahrenheit); // print the temperature in Fahrenheit Serial.println("°F"); delay(500); }


سلة المشتريات افراغ السلة