Ks0124 keyestudio EASY plug DS18B20 Temperature Sensor: Difference between revisions

From Keyestudio Wiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
==EASY plug DS18B20 Temperature Sensor==
[[image:ks0124图.jpg|thumb|600px|right|EASY plug DS18B20 Temperature Sensor]]
<br>[[File:ks0124-1.png|500px|frameless|thumb]]<br>


==Introduction==
==Introduction==
This DS18B20 Temperature Sensor Module can be used to quantify environmental temperature testing. The temperature range is -55 ~ +125 ℃, inherent temperature resolution 0.5 ℃. It also support multi-point mesh networking.<br>
The DS18B20 temperature sensor is exactly what it sounds like - a sensor used to measure ambient temperature.
Note: this module needs to be used together with EASY plug control board.<br>
The usable temperature ranges from -55°C to +125°C. It also supports multi-point mesh networking.  
 
While there are many types of temperature sensors available in the market, the DS18B20 temperature sensor is the best choice in applications which require high accuracy and high reliability.
For electronic enthusiasts and hobbyists, the DS18B20 is a good start for learning and developing temperature-dependent prototypes. 
<span style="color: red">'''Note: ''' this module should be used together with EASY plug control board.
<br>




==Specification==
==Specification==
* Interface: Easy plug
* Connector: Easy plug
* Supply Voltage: 3.3V to 5V
* Supply Voltage: 3.3V to 5V
* Temperature range: -55 °C ~ +125 °C
* Temperature range: -55°C to +125°C
* Interface: Digital
* Interface: Digital
* Size: 40*20mm
* Weight: 5g




==Connection Diagram ==
==Technical Details==
<br>[[File:ks0124-2.png|500px|frameless|thumb]]<br>
* Dimensions: 38mm*20mm*18mm
* Weight: 4.4g




==Sample Code==
==Connect It Up ==
http://www.pjrc.com/teensy/arduino_libraries/OneWire.zip
Connect the EASY Plug DS18B20 temperature sensor to control board using an RJ11 cable. Then connect the control board to your PC with a USB cable.
<br>[[File:ks0124.png|500px|frameless|thumb]]<br>
 
 
==Upload the Code==
Copy and paste below code to [http://wiki.keyestudio.com/index.php/How_to_Download_Arduino_IDE Arduino IDE] and upload.  
<pre>
<pre>
#include <OneWire.h>
#include <OneWire.h>
int DS18S20_Pin = 2; //DS18S20 Signal pin on digital pin 2
int DS18S20_Pin = 6; //DS18S20 Signal pin on digital pin 6
//Temperature chip i/o
//Temperature chip i/o
OneWire ds(DS18S20_Pin); // on digital pin 2
OneWire ds(DS18S20_Pin);// on digital pin 6
void setup(void) {
void setup(void) {
Serial.begin(9600);
Serial.begin(9600);
}
}
void loop(void) {
void loop(void) {
float temperature = getTemp();
float temperature = getTemp();
Serial.println(temperature);
Serial.println(temperature);
delay(100); //to slow down the output so it is easier to read
delay(100); //to slow down the output so it is easier to read
}
}
float getTemp(){
float getTemp(){
//returns the temperature from one DS18S20 in DEG Celsius
//returns the temperature from one DS18S20 in DEG Celsius
byte data[12];
byte data[12];
byte addr[8];
byte addr[8];
if ( !ds.search(addr)) {
if ( !ds.search(addr)) {
    //no more sensors on chain, reset search
//no more sensors on chain, reset search
    ds.reset_search();
ds.reset_search();
    return -1000;
return -1000;
}
}
if ( OneWire::crc8( addr, 7) != addr[7]) {
 
    Serial.println("CRC is not valid!");
if ( OneWire::crc8( addr, 7) != addr[7]) {
    return -1000;
Serial.println("CRC is not valid!");
}
return -1000;
if ( addr[0] != 0x10 && addr[0] != 0x28) {
}
    Serial.print("Device is not recognized");
if ( addr[0] != 0x10 && addr[0] != 0x28) {
    return -1000;
Serial.print("Device is not recognized");
}
return -1000;
ds.reset();
}
ds.select(addr);
ds.reset();
ds.write(0x44,1); // start conversion, with parasite power on at the end
ds.select(addr);
byte present = ds.reset();
ds.write(0x44,1); // start conversion, with parasite power on at the end
ds.select(addr);  
byte present = ds.reset();
ds.write(0xBE); // Read Scratchpad
ds.select(addr);
ds.write(0xBE); // Read Scratchpad
for (int i = 0; i < 9; i++) { // we need 9 bytes
 
  data[i] = ds.read();
for (int i = 0; i < 9; i++) { // we need 9 bytes
}
data[i] = ds.read();
ds.reset_search();
}
ds.reset_search();
byte MSB = data[1];
byte MSB = data[1];
byte LSB = data[0];
byte LSB = data[0];
float tempRead = ((MSB << 8) | LSB); //using two's compliment
float tempRead = ((MSB << 8) | LSB); //using two's compliment
float TemperatureSum = tempRead / 16;
float TemperatureSum = tempRead / 16;
return TemperatureSum;
return TemperatureSum;
}
}
</pre>
</pre>
==What You Should See==
Done uploading the code, you should be able to read the temperature your temperature sensor is detecting on the serial monitor in the Arduino IDE.
<br>[[File:ks0124 Result.gif|500px|frameless|thumb]]<br>


==Resources ==
==Resources ==
'''PDF'''
'''PDF'''
https://drive.google.com/open?id=1thhRA_Qcgri0Z0hs8L2zu6FqEyOiLvi3
https://drive.google.com/open?id=1thhRA_Qcgri0Z0hs8L2zu6FqEyOiLvi3


'''Libraries'''
'''Libraries'''
https://drive.google.com/open?id=14ikf_FgLyNAIecA9zvV2A1b3Lmr24hPm


https://drive.google.com/open?id=14ikf_FgLyNAIecA9zvV2A1b3Lmr24hPm


==Buy from ==
==Buy from ==
'''Official Website'''
'''Official Website'''
http://www.keyestudio.com/keyestudio-easy-plug-ds18b20-temperature-sensor-for-arduino.html


http://www.keyestudio.com/keyestudio-easy-plug-ds18b20-temperature-sensor-for-arduino.html


[[category:EASY Plug]]
[[category:EASY Plug]]

Revision as of 09:32, 23 November 2018

EASY plug DS18B20 Temperature Sensor

Introduction

The DS18B20 temperature sensor is exactly what it sounds like - a sensor used to measure ambient temperature. The usable temperature ranges from -55°C to +125°C. It also supports multi-point mesh networking.

While there are many types of temperature sensors available in the market, the DS18B20 temperature sensor is the best choice in applications which require high accuracy and high reliability. For electronic enthusiasts and hobbyists, the DS18B20 is a good start for learning and developing temperature-dependent prototypes. Note: this module should be used together with EASY plug control board.


Specification

  • Connector: Easy plug
  • Supply Voltage: 3.3V to 5V
  • Temperature range: -55°C to +125°C
  • Interface: Digital


Technical Details

  • Dimensions: 38mm*20mm*18mm
  • Weight: 4.4g


Connect It Up

Connect the EASY Plug DS18B20 temperature sensor to control board using an RJ11 cable. Then connect the control board to your PC with a USB cable.
thumb


Upload the Code

Copy and paste below code to Arduino IDE and upload.

#include <OneWire.h>
int DS18S20_Pin = 6; //DS18S20 Signal pin on digital pin 6
//Temperature chip i/o
OneWire ds(DS18S20_Pin);// on digital pin 6
void setup(void) {
Serial.begin(9600);
}
void loop(void) {
float temperature = getTemp();
Serial.println(temperature);
delay(100); //to slow down the output so it is easier to read
}
float getTemp(){
//returns the temperature from one DS18S20 in DEG Celsius
byte data[12];
byte addr[8];
if ( !ds.search(addr)) {
//no more sensors on chain, reset search
ds.reset_search();
return -1000;
}

if ( OneWire::crc8( addr, 7) != addr[7]) {
Serial.println("CRC is not valid!");
return -1000;
}
if ( addr[0] != 0x10 && addr[0] != 0x28) {
Serial.print("Device is not recognized");
return -1000;
}
ds.reset();
ds.select(addr);
ds.write(0x44,1); // start conversion, with parasite power on at the end
byte present = ds.reset();
ds.select(addr);
ds.write(0xBE); // Read Scratchpad

for (int i = 0; i < 9; i++) { // we need 9 bytes
data[i] = ds.read();
}
ds.reset_search();
byte MSB = data[1];
byte LSB = data[0];
float tempRead = ((MSB << 8) | LSB); //using two's compliment
float TemperatureSum = tempRead / 16;
return TemperatureSum;
}


What You Should See

Done uploading the code, you should be able to read the temperature your temperature sensor is detecting on the serial monitor in the Arduino IDE.
thumb


Resources

PDF https://drive.google.com/open?id=1thhRA_Qcgri0Z0hs8L2zu6FqEyOiLvi3

Libraries https://drive.google.com/open?id=14ikf_FgLyNAIecA9zvV2A1b3Lmr24hPm


Buy from

Official Website http://www.keyestudio.com/keyestudio-easy-plug-ds18b20-temperature-sensor-for-arduino.html