Water Temperature Monitoring using DS18B20 (Digital Temperature Sensor) and Arduino

0
162

Hello, everyone! Today I’m going to show you how to use DS18B20 digital temperature sensor with Arduino, so you can measure the temperature of the air, liquids like water and the temperature of the ground.

Use of the DS18B20 1-Wire Temperature Sensor is one of the simplest and least expensive ways to incorporate temperature sensing into your Arduino project. These sensors are fairly accurate and don’t require any extra parts to operate. So, you can quickly start measuring temperature with just a few connections and some Arduino code!Components Used

  1. Arduino Uno
  2. DS18B20 WATERPROOF TEMPERATURE SENSOR MODULE
  3. 0.96 INCH OLED I2C DISPLAY MODULE
  4. Bread board
  5. 12 V Power Supply
  6. Connecting wires

DS18B20 Temperature Sensor

The ultra-small size, low hardware overhead, powerful anti-interference capability, and high accuracy of the DS18B20 Waterproof Temperature Sensor Module, among other features, have increased its appeal among customers. For electronic enthusiasts and hobbyists who wish to learn about and build temperature-dependent prototypes, the DS18B20 is an excellent place to start.

Specifications

  • Supply Voltage: 3.3V to 5V
  • Interface: Digital
  • Temperature detection range: -55 ° C ~ +125 ° C (-67 ° F ~ +257 ° F)
  • Built-in EEPROM and temperature limit
  • Digital temperature conversion and output
  • Advanced single-bus data communication
  • Maximum 12-bit resolution, accuracy up to ±0.5 degrees Celsius
  • Parasitic mode available
  • Waterproof Temperature Probe
  • Temperature Probe wire length: 1metre
  • Module Board Dimension: 23x12x23mm
  • Total Module Weight: 26g.    

 

0.96 INCH OLED I2C DISPLAY MODULE

This module is a 0.96 inch White OLED display module. The display module can be interfaced with any microcontroller using IIC protocols. It is having a resolution of 128×64. OLED is a self light-emitting technology composed of a thin, multi-layered organic film placed between an anode and cathode. In contrast to LCD technology, OLED does not require a backlight. OLED possesses high application potential for virtually all types of displays and is regarded as the ultimate technology for the next generation of flat-panel displays.

Specifications

  • Resolution: 128X64
  • Size: 0.96
  • Ultra low power: 0.08W
  • Input voltage: 3-5VDC
  • View Angle: > 160°
  • Communication: IIC, only two I / O ports
  • Compatible with a wide range of controlers (Arduino, ARM, STM32, MSP430)
  • Working temperature: -30°C /70°C
  • Serial interface: I2C/IIC (needs only 2IO)
  • Driver: SSD1306
  • Colour: White
  • Backlight: OLED self light, no backlight
  • I2C Address: 0x3C
  • Dimension : 27MM * 27MM * 4.1MM
  • Weight: 4g.

Wiring DS18B20 Temperature Sensor to Arduino

Enough of the theory, Let’s Go Practical! Let’s hook the DS18B20 up to the Arduino.

  • VCC to 5V Output pin on Arduino
  • GND to Arduino GND
  • SIG to Arduino pin no 8

Wiring 0.96 INCH OLED I2C DISPLAY MODULE to Arduino

  • VCC to 5V Output pin on Arduino
  • GND to Arduino GND
  • SCL to Arduino pin no A5
  • STA to Arduino pin no A4

Libraries to Downloads

  1. Adafruit-GFX-Library-master
  2. Adafruit_SSD1306-Library master
  3. One Wire Arduino Library for 18B20
  4. Dallas Temperature Library

 

ARDUINO UNO PROGRAM

#include <OneWire.h>    //////////////////////TEMP SENSOR SECTION
#include <DallasTemperature.h>
#include <Adafruit_GFX.h>//////////////////////OLED SECTION
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4//////////////////////////////OLED
#define WIDTH     128//////// the lower right corner is (X=128, Y=63)
#define HEIGHT     64
#define NUM_PAGE    8
#define NUMFLAKES 10
#define XPOS 0/////////////////Every pixel on the display has a coordinate that is specified with a X and //Y.
#define YPOS 0//////////////////The upper left corner of the screen is (X=0, Y=0)
#define DELTAY 2
#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH  16
Adafruit_SSD1306 display(OLED_RESET);
#define ONE_WIRE_BUS 8////////////////////temp signal wire coonected to 8 D/PIN
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
float Celcius = 0;
int frame_delay =70;
int tt=0;
int xx=0;
int yy=0;
void setup(void)
{
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);///// Call the begin function of the display object by passing our I2C address 0x3C
Serial.begin(9600);
sensors.begin();
display.clearDisplay();/////////////clears the display completely.
display.setTextSize(1);/////////accepts an integer number as a size. The greater the number, the bigger the text would be. Smallest size is 1 which is the default size //of texts.
display.setTextColor(WHITE);///////////////specify the color using display.setTextColor() WHITE/BLACK
display.setCursor(15, 8);//////////////////specify where on the display we're going to display the text.
display.println("Eagle Electronics");////////////We draw something on by calling on our (display) object,
display.setTextSize(1);
display.setCursor(8, 20);//////////////////specify where on the display we're going to display the text.
display.println("DS18B20 Temperature");//
display.display();//////////////////Call the display.display() function to make the actual drawing happen on the hardware level.
delay(4000);
display.clearDisplay();
}
void loop()
{
sensors.requestTemperatures();///////////////getting the actual temperature value.
Celcius = sensors.getTempCByIndex(0);//////////get the temperature in Celsius.we’re using just one sensor its index is 0.
Serial.print(" C  ");
Serial.println(Celcius);
// Print text:
//display.setFont();
// display.setCursor(50,5);  // (x,y)
// display.setTextSize(1);
//display.println("TEMPERATURE");  // Text or value to print
char string[10];  // Create a character array of 10 characters
// Convert float to a string:
dtostrf(Celcius, 3, 0, string);  // (<variable>,<amount of digits we are going to use>,<amount of decimal digits>,<string name>)
display.setTextSize(3);
display.setTextColor(WHITE, BLACK);
display.setCursor(33, 6);
display.println(string);
display.setCursor(100, 6);
display.setTextSize(3);
display.println("C");
display.setCursor(90, 6);
display.setTextSize(1);
display.println("o");
display.fillCircle(18, 25, 5, WHITE);
display.drawRoundRect(16, 1, 6, 22, 6, WHITE);
for (int i = 6; i<=20; i=i+3){
display.drawLine(21, i, 24, i, WHITE); } // Draw line (x0,y0,x1,y1,color)
Celcius = Celcius * 0.43;
display.drawLine(18, 20, 18, 30-Celcius, WHITE);  // Draw line (x0,y0,x1,y1,color)
display.drawLine(19, 20, 19, 30-Celcius, WHITE);
display.drawLine(17, 20, 17, 30-Celcius, WHITE);
display.drawLine(20, 20, 20, 30-Celcius, WHITE);
// display.fillRoundRect(16, 3, 6, 30-Celcius, 6, WHITE);  // Draw rounded rectangle (x,y,width,height,radius,color)
display.display();
delay(2000);
display.clearDisplay();
}

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here