Introduction to DS18B20

Hello friends, I hope you all are doing great. In today's tutorial, we are gonna have a look at a detailed Introduction to DS18B20. DS18B20 is a temperature sensor that can measure temperature from -55oC to +125oC with an accuracy of +- 5%. It follows 1 wire protocol which has revolutionized the digital world. Because of its 1 wire protocol, you can control multiple sensors from a single pin of Microcontroller.

DS18B20 is normally used in industrial projects where high accuracy is necessary. I will give you a detailed overview of this temperature sensor in today's post where we will have a look at its Pinout, working, protocol, etc. I will also share some links to projects where I have interfaced it with Arduino or other microcontrollers. If you have any questions, please ask in comments and I will try my best to resolve them all. So, let's get started with a basic Introduction to DS18B20:

Introduction to DS18B20

  • DS18B20 is a digital temperature sensor that follows a 1-wire protocol and can measure temperature from -55oC to +125oC ( -67oF to +257oF ) with an accuracy of +-5%.
  • Data received from the single wire is in the ranges of 9-bit to 12-bit.

  • As DS18B20 follows the 1-wire protocol so we can control this sensor via a single pin of Microcontroller. (We also have to provide GND)
  • 1-wire protocol is an advanced level protocol and each DS18B20 is equipped with a serial code of 64 bit which helps in controlling multiple sensors via a single pin of the microcontroller.
  • In simple words, it assigns different addresses to all sensors attached and by calling the address, you can get that sensor's value.
  • So, now let's have a look at the DS18B20 Pinout:

DS1820 Pinout

  • DS18B20 has 3 pins in total, which are:
    • Pin # 1: Vcc ( We have to provide +5V here ).
    • Pin # 2: Data Pin ( It's the 1-wire from where we will get temperature readings ).
    • Pin # 3: GND ( We have to provide ground here ).
  • It is available in two packages, one is simple while the other one is waterproof DS18B20, both of their pinouts are shown in the below figure:

  • Now let's have a look at some of DS18B20's Characteristics and features:

DS18B20 Features

  • I have assembled a table where I have added all the features and characteristics of DS18B20.
No. Parameter Symbol Value Unit
1. Supply Voltage VDD +3 to 5.5 V
2. Pull-up Supply Voltage VPU +3 to 5.5 V
3. Input Logic Low VIL -0.3 to +0.8 V
4. Input Logic High VIH +2.2 V
5. Sink Current IL 4.0 ma
6. Standby Current IDDS 750 to 1000 na
7. Active Current IDD 1 to 1.5 ma
8. DQ Input Current IDQ  5 ua
9. Drift   +-2 C
10. NV Write Cycle Time tWR  2 to 10 ms
11. EEPROM Writes NEEWR 50k writes
12. EEPROM Data Retention tEEDR 10 years
13 Temperature Conversion Time tCONV 93.75 ms
14. Time to Strong Pullup On

tSPON

10 ms
15. Time Slot

tSLOT

120 us
16. Recovery Time TREC 1 us
17. Write 0 Low Time

tLOW0

120 us
18. Write 1 Low Time tLOW1 15 us
19 Read Data Valid

tRDV

15 us
20. Reset Time High

tRSTH

480 us
21 Reset Time Low

tRSTL

480 us
22. Presence-Detect High

tPDHIGH

60 us
23 Presence-Detect Low tPDLOW 240 us
20. Capacitance

CIN/OUT

25 pf

 

  • Let's have a look at one wire Bus system:

 One Wire Bus System

  • As I told earlier that DS18B20 follows 1 wire protocol, so in order to understand its working, we must have a look at this protocol first.
  • The main advantage of 1 wire protocol is that we can control multiple 1-wire devices via a single pin of Microcontroller.
  • You must have heard of the master-slave system, where 1 master device can control or communicate with all slave devices.
  • 1-wire protocol follows a similar master-slave system, where microcontroller acts as a master and all our 1-wire devices e.g. DS18B20 act as slaves.
  • If we have interfaced only one device with our microcontroller then such a system is called a single drop but if we interface multiple 1-wire devices via a single pin then it's called multidrop system.
  • Now let's have a better understanding of One Wire System from the figure given below:

  • Now let's have a look at DS18B20 Power Supply:

Power Supply of DS18B20

  • There are two ways to power up this temperature sensor DS18B20, which are:
    • External Power Supply.
    • Parasite Power Supply.
  • Let's discuss both of these power supplies in detail:                                    
External Power supply of DS18B20

  • In this method, we provide power to DS18B20 by conventional method i.e. battery or adapter.
  • This method is applicable for temperature below +100 degree Celsius.
  • The main benefit of this method is, there is no extra load on the resistor which uses in this method and it performs work correctly. 
  •  Let's have a look at the connections in the below figure:

Parasite Power Mode of DS18B20

  • In this method, we do not need a special power supply.
  • This method is used for temperature greater than +100 Celsius.
  • In a normal situation, this method provides efficient current and voltage to DS18B20 
  • But, in special work when DS18B20 convert temperature value into digital then current value increase to such value which can damage resister.
  • To limit current in save the value and good working of DS18B20 it is necessary to use pull up mosfet.
  • As it is used only for specific temperature value there we use an external power supply.

Now, let's have a look at pictures of this method

Working of DS18B20

  • It works on the principle of direct conversion of temperature into a digital value.
  • Its main features are to change its bit numbers according to change in temperature 
  • Like, it changes a bit in 9. 10, 11, and 12  bits as temperature changes in values 0.5 ° C. 0.25°C,1.25 and  0.0625°C respectively.
  • Its default bits value is 12 but it changes values according to Temperature Change
  • It has alarm and LCD as temperature changes alarms work and temperature value changes which we can get from LCD.
  • Now let's have a look at the DS18B20 memory map 

DS18B20 Memory Map

  • There are are two types of memories which have DS18B20
  •  One SRAM  and other is EEPROM.
  • Sram is volatile memory it has data only in on the condition 
  • EEPROM is Non-volatile memory it stores data in the off condition
  • EEPROM also has a low and high alarm trigger 
  • To have a better understanding of Memory Map of DS18B20 look at pictures which gives a better idea of a memory map of ds18b20 

  • Now let's have a look at Function Commands of DS18B20

DS18B20 Function Commands

These are function Commands of DS18B20. These commands allow some to read and write data on DS18B20 scratched memory. Let's discuss them

  • Convert T[44h]: This command starts the single temperature conversion.
  • Write scratched Pad [4Eh]: In this command, we can write data on memory of DS18B20 to three bytes. Data is transferred in the least multiple bits first.
  • Read Scratched Pad[BEh]: In this command, we can read data on a scratched pad memory of DS18B20.
  • Copy Scratchpad [48h]: This command data from the scratched pad and send data to EEPROM in 2, 3 and 4 bytes.
  • Read Power Supply [B4h]: This command tells about the power supply mode of DS18B20.

Now let's have a look at Applications of DS18B20:

Applications of DS18B20

DS18B20 is used for temperature measurement. There are some applications of DS18B20:

  • We can use it in the thermostat controls system.
  • It can be used in industries as a temperature measuring device.
  • It can be used as a thermometer.
  • We can use it in thermally sensitive devices.   
  • It can also use in HVAC systems.

So, that was all about temperature sensor DS18B20. I hope you have enjoyed today's tutorial. IF you have any questions then ask in comments and we will resolve them all. Thanks for reading. Take care !!! :)

Introduction to HC-SR04 (Ultrasonic Sensor)

Hi Friends! I hope you are doing well. Welcome you onboard. Today, I'll discuss the basic Introduction to HC-SR04 Ultrasonic Sensor. It is an ultrasonic sensor, also known as an ultrasonic transducer that is based on a transmitter and receiver and mainly used to determine the distance from the target object. The amount of time it takes to send and receive waves will determine how far the object is placed from the sensor. It mainly depends on the sound waves working on “non-contact” technology. The required distance of the target object is measured without any damage, giving you accurate and precise details. This sensor comes with a range between 2cm to 400cm and is used in a wide range of applications including speed and direction measurement, wireless charging, humidifiers, medical ultrasonography, sonar, burglar alarms, and non-destructive testing. In this post, I'll try to cover basic details related to HC-SR04, so you get an idea what is this about and how it can be used in the major applications as per your needs and requirements. Let's jump right in and get down to the details on this ultrasonic sensor.

Introduction to HC-SR04 ( Ultrasonic Sensor )

  • HC-SR04 is an ultrasonic sensor mainly used to determine the distance of the target object.
  • It measures accurate distance using a non-contact technology - A technology that involves no physical contact between sensor and object.
  • Transmitter and receiver are two main parts of the sensor where former converts an electrical signal to ultrasonic waves while later converts that ultrasonic signals back to electrical signals.
  • You can download HCSR04 Datasheet by clicking below button:
Download HC-SR04 Datasheet
  • These ultrasonic waves are nothing but sound signals that can be measured and displayed at the receiving end.
  • Following table shows the main features of this ultrasonic sensor.
 
Parameter Value
Main Parts Transmitter & Receiver
Technology Used Non-Contact Technology
Operating Voltage 5 V
Operating Frequency 4 MHz
Detection Range 2cm to 400cm
Measuring Angle 30º
Resolution 3mm
Operating Current <15mA
Sensor Dimensions 45mm x 20mm x 15mm
 
  • It gives precise measurement details and comes with accuracy (resolution) around 3mm, terming there might be a slight difference in the calculated distance from the object and the actual distance.
HC-SR04 Pinout & Description
  • HC-SR04 contain 4 pins in total.
  • Following table shows the HC-SR04 Pinout  & Description:
 
No. Pin Name Pin Description
1 VCC The power supply pin of the sensor that mainly operates at 5V DC.
2 Trig Pin It plays a vital role to initialize measurement for sending ultrasonic waves. It should be kept high for 10us for triggering the measurement.
3 Echo Pin This pin remains high for short period based on the time taken by the ultrasonic waves to bounce back to the receiving end.
4 Ground This pin is connected to ground.
 
  • I have labelled these HC-SR04 Pinout in below figure for better visualization:
How does it work?
The HC-SR04 Ultrasonic (US) sensor is an ultrasonic transducer that comes with 4 pin interface named as Vcc, Trigger, Echo, and Ground. It is very useful for accurate distance measurement of the target object and mainly works on the sound waves. As we connect the module to 5V and initialize the input pin, it starts transmitting the sound waves which then travel through the air and hit the required object. These waves hit and bounce back from the object and then collected by the receiver of the module. Distance is directly proportional to the time these waves require to come back at the receiving end. The more the time taken, more the distance will be. The waves will be generating if the Trig pin is kept High for 10 µs. These waves will travel at the speed of sound, creating 8 cycle sonic burst that will be collected in the Echo pin. The echo pin remains turned on for the time these waves take to travel and bounce back to the receiving end. This sensor is mainly incorporated with Arduino to measure the required distance. Following formula is used to calculate the distance of the object.

S = (V x t)/2

Where S is the required distance, V is the speed of sound and t is the time sound waves take to come back after hitting the object. We need to divide the value by 2 because time will be double as the waves travel and bounce back from the initial point. Dividing it by 2 will give the actual distance of the target object.
Using HC-SR04 with Arduino Module
In order to get the precise distance measurement, HC-SR04 is mostly used in combination with different Arduino Modules like Arduino Uno and Arduino Mega. You can connect Arduino with this sensor in the following way.
  • First, you need to power up the sensor using 5V DC regulated input to the sensor. Connect the ground pin with the ground of the voltage source. You can also power the sensor module using the Arduino 5V pins as the current drawn by the sensor is less than 15mA, won't be affecting the current ratings of the Arduino Module.
After setting up the initial arrangement, connect both Trig and Echo pins to the I/O pins of the Arduino Board. As mentioned earlier, in order to initialize the measurement process, the Trig pin must be kept high for 10us in the start. The sensor module will start generating sound waves with the frequency around 40,000 Hz per second from the transmitter.
  • As the waves bounce back, consequently, the Echo pin will turn on until the sounds waves are received by the receiver. This time will be calculated using Arduino Module.
This tutorial that will help you How to Interface Ultrasonic Sensor with Arduino Module You can also Interface Multiple Ultrasonic Sensors with Arduino Module
Applications
HC-SR04 comes with a wide range of applications mainly targeting distance and direction measurements. Following are the major applications it can be used for.
  • Speed and direction measurement
  • Wireless charging
  • Humidifiers
  • Medical ultrasonography
  • Burglar alarms
  • Embedded system
  • Depth measurement
  • Non-destructive testing
That's all for today. I hope I have given you everything you needed to know about this sensor. If you are unsure or have any question, you can approach me in the comment section below. I'd love to help you the best way I can. Feel free to keep us updated with your valuable feedback and suggestion, they help us stay above the curve and give you quality content as per your demands. Thanks for reading the article.

Introduction to Laser Sensor

Hello everyone! I hope you all will be absolutely fine and having fun. Today, I am going to provide a detailed discussion on Introduction to Laser Sensor. Laser  sensor is basically an electronic device which we often use for the detection of accurate positions as well as small objects. Laser sensors transmit or radiate laser light. This laser light consists of light waves having same wave length. Due to this fact laser light travels in a parallel direction from the source emitting this light. Due to its travel in parallel direction it can be transmitted over long distances. This light is dangerous for the human beings. We must avoid by looking directly into the light. It causes serious eye damaging effect and even can make anyone blind. As we know optical fiber cables are used for the communication theses days and it uses only light to transmit data. If the communication is for shorter distance, LED will be used as a information transmitting source. If we want to communicate over long distances we must use laser because it has the light waves of same wave lengths and has a capability to be transmitted over long distances. If we use laser for the shorter distance communication, the medium will be overloaded with a lot of information and hence data will be damaged and can not be sent to the receiving end. Laser sensor has basically two wires but if it is attached on a small PCB board, then it has three pins which will be discussed later. The further information about laser sensor module will be provided later in this tutorial.

Introduction to Laser Sensor

Laser Sensor is an electronic device usually used to detect small objects. It is also used to detect the accurate positions. Laser light has light waves of same wave lengths. Due to the fact, laser light travels in a parallel direction. It is dangerous for humans because it can cause serious eye problems, if you look directly into the light when it is ON. It can cause blindness too. It can be used to transmit data over long distances, which is considered to be its major benefit. Laser sensor module is shown in the figure given below.
1. Laser Sensor Pins
  • Laser sensor has basically two pins, usually known as power pins.
  • Both of the pins are provided in the table shown in the figure below.
2. Laser Sensor Pins Description
  • We must know about the functions of all the input/output pins in order to use the device properly.
  • Laser sensor pin descriptions is given in the table provided in the figure given below.
3. Laser Sensor Working Principle
  • Laser radiated a laser beam as shown in the figure below.
  • Receiver lens concentrates the light reflected off the target, and produces an image on a light receiving element.
  • The concentrated light reflects at several different angles, when distance changes.
  • With the change in angle of the concentrated light, position of the image changes correspondingly.
  • I have provided the three visuals at different distances in the figure shown below.
  • From the three figures given below, you can easily understand the working principle of a laser sensor.
  • The laser principle for reference distance is shown in the figure below.
  • The laser principle for shorter distance is shown in the figure given below.
  • Laser principle for longer distance is shown in the figure given below.
4. Laser Sensor Ratings
  • Ratings provides us the basic and general specifications of any electronic device.
  • Laser sensor ratings are given in the table shown in the figure given below.
5. Laser Sensor Applications
  • Most of the times the electronic devices are known on the basis of their applications.
  • Laser sensor has a wide range of real life applications.
  • Some of the common applications are listed in the table shown in the figure given below.
6. Laser Sensor Advantage
  • Advantages are the parameters which can improve the efficiency of the particular device.
  • Laser Sensor advantages are shown in the table given in the figure below.
7. Laser Sensor Disadvantage
  • Like other devices laser sensor also has some serious disadvantages.
  • Few of the main and avoidable disadvantages are listed in the table shown in the figure given below.
In the tutorial Introduction to Laser Sensor, I have explained about the basic parameters associated with the laser sensors and which are important to be known before using it. I hope you have enjoyed the tutorial and hoping for your appreciation. If you have any sort of problem you can ask us in comments any time. Our team is always there to help to help you. I will share different amazing and informative topics in my upcoming tutorial. Till then take care and bye :)
Syed Zain Nasir

I am Syed Zain Nasir, the founder of <a href=https://www.TheEngineeringProjects.com/>The Engineering Projects</a> (TEP). I am a programmer since 2009 before that I just search things, make small projects and now I am sharing my knowledge through this platform.I also work as a freelancer and did many projects related to programming and electrical circuitry. <a href=https://plus.google.com/+SyedZainNasir/>My Google Profile+</a>

Share
Published by
Syed Zain Nasir