© 2024 EasyEDA Some rights reserved ISO/IEC
1.Easy to use and quick to get started
2.The process supports design scales of 300 devices or 1000 pads
3.Supports simple circuit simulation
4.For students, teachers, creators
1.Brand new interactions and interfaces
2.Smooth support for design sizes of over 5,000 devices or 10,000 pads
3.More rigorous design constraints, more standardized processes
4.For enterprises, more professional users
STD One Wire Digital Temperature Sensor
Mode: Editors' pick
#include
#include
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
void setup(void)
{
// start serial port
Serial.begin(9600);
Serial.println("Dallas Temperature IC Control Library Demo");
// Start up the library
sensors.begin();
}
void loop(void)
{
Serial.print(" Requesting temperatures...");
sensors.requestTemperatures();
Serial.println("DONE");
Serial.print("Temperature for Device 1 is: ");
Serial.print(sensors.getTempCByIndex(0));
When you have uploaded the sketch, click on the Serial Monitor and you should see output like the following. The temperature is in degrees C
![One Wire Digital Temperature Sensor - DS18B20][2]
[1]: /editor/20151221/5676da6ec7542.JPG
[2]: /editor/20151221/5676dc6b7e4eb.jpgID | Name | Designator | Footprint | Quantity |
---|---|---|---|---|
1 | Arduino MEGA 2560 | U1 | DIP | 1 |
2 | DS18B20 | U2 | DS18B20_SOIC | 1 |
3 | 10k | R1 | R3 | 1 |
Unfold
Loading...
Do you need to add this project to the album?