Showing posts with label IOT Practicals. Show all posts
Showing posts with label IOT Practicals. Show all posts

Interfacing Liquid Crystal Display (LCD) – display data generated by sensor on LCD.

This project will demonstrate how to configure a 16 × 2 LCD screen to display numerous sensor values.

Hardware components required:-
  • Arduino UNO
  • Adafruit Standard LCD - 16x2 White on Blue
  • Rotary potentiometer (generic)
  • Jumper wires (generic)
  • Solderless Breadboard Full Size
  • RM065 10K ohm 103 Trim 
  • Pot Potentiometer
This project makes use of two potentiometers connected on a breadboard to an Arduino and an LCD. As a result, when both potentiometers are adjusted, the LCD should display their values.
Liquid Crystal Display (LCD)
Before we begin the configuration, let's take a closer look at the LCD and see what the 16 pins are for:
  • GND - Ground Connection
  • VCC - +5V Connection
  • VO - analogue pin used for screen brightness, connects to Potentiometer.
  • RS - tells the LCD what will be written to it.
  • R/W - the read/write pin (normally hardwired to ground).
  • E - tells the LCD the data is ready to be written.
  • D0 to D7 - bus lines for the LCD, this is where your data is passed from the Arduino to the LCD.
  • A - +5V Connection for the backlight of the LCD.
  • K - the ground pin for the backlight of the LCD.
Working:-

We may now begin building connections on and to the breadboard. A step-by-step approach is provided below:
  • Connect the 10K Ohm potentiometer (this potentiometer controls the LCD's contrast). The VO pin is linked to the potentiometer's center pin, while the other two wires are connected to +5V and ground on the breadboard.
  • Connect pin-A to the +5V and pin-K to ground on the breadboard.
  • Connect pin-D7 to digital pin 12, pin-D6 to digital pin 11, pin-D5 to digital pin 10 and pin-D4 to digital pin 9. (Digital pins on the Arduino).
  • Connect pin-RS to digital pin 7 on the Arduino.
  • Connect pin-RW to ground on the breadboard.
  • Connect pin-VSS to ground on the breadboard.
  • Connect pin-VDD to +5V on the breadboard.
  • Connect pin-E to digital pin 8 on the Arduino.
  • Place the first potentiometer on the board and connect the center pin to Analog Pin 1 on the Arduino and the other pins to ground and +5V on the breadboard.
  • Place the second potentiometer on the board and connect the center pin to Analog Pin 2 on the Arduino and the other pins to ground and +5V on the breadboard.
Connection Diagram:-

Display data generated by sensor on LCD.

The potentiometers that will be utilized are shown in the image below.


Code:-
  • Upload the code below to your Arduino and make any necessary adjustments to the potentiometers. 
  • The potentiometer values will be displayed on two lines on the LCD display. 
  • The B10K potentiometer can be adjusted to ensure that the contrast of the LCD is optimal for reading the values.
// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7,8,9,10,11,12);

int potPin1 = A1;
int potPin2 = A2;

void setup()
{
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
lcd.clear();

pinMode(potPin1, INPUT);
pinMode(potPin2, INPUT);
}

void loop()
{
lcd.setCursor(0,0); // Sets the cursor to col 0 and row 0
lcd.print("SensorVal1: "); // Prints Sensor Val: to LCD
lcd.print(analogRead(potPin1)); // Prints value on Potpin1 to LCD
lcd.setCursor(0,1); // Sets the cursor to col 1 and row 0
lcd.print("SensorVal2: "); // Prints Sensor Val: to LCD
lcd.print(analogRead(potPin2)); // Prints value on Potpin1 to LCD
}

Output Display:-

Interfacing Liquid Crystal Display



Interfacing DHT11 Temperature and Humidity Sensor with Arduino Uno.

We will learn how to interface the DHT11 temperature and humidity sensor with the Arduino UNO in this tutorial. The acronym for Digital Humidity and Temperature sensor is DHT. The resistive humidity sensor, NTC temperature sensor, and 8-bit microcontroller that make up the DHT11 provide great quality, fast response times, anti-interference capabilities, and affordability.

Components Required:-
  • DHT11 Sensor
  • Arduino Uno
  • 0.96 inch OLED
  • Bread Board
  • Jumper Wires
DHT11 Temperature and Humidity Sensor
DHT11 Sensor
Specifications
  • Operating Voltage : 3V ~ 5.5V
  • Temperature range : 0 ~ 50°C
  • Temperature Accuracy : 2°C
  • Humidity range : 20 – 90 %RH
  • Humidity Accuracy : 5 %RH
  • Maximum Sampling Rate : 1 Hz
  • Pin Out : VCC – Power In, Data – Data Out, NC – No Connection, GND – Ground
VCC pin provides power to the sensor. Despite the fact that the supply voltage ranges from 3.3V to 5.5V, a 5V supply is recommended. With a 5V power supply, the sensor can be placed up to 20 meters away. With 3.3V supply voltage, the sensor can be placed up to 1 meter away; otherwise, the line voltage drop will cause measurement errors.
Data pin is used for communication between the sensor and the microcontroller.
NC Not connected
GND is the ground pin.

Working:-
  • Both an NTC temperature sensor and a humidity measuring component are included with the DHT11 sensor.
  • The component used to measure humidity is made up of two electrodes with a substrate positioned in between.
  • The resistance between the electrodes varies when there is a change in the conductivity of the substrate due to variations in humidity or moisture.
  • As the temperature rises, the NTC thermistor's resistance falls.
  • The inbuilt microcontroller measures, interprets, and transmits the resistance change via the data line.
Circuit Diagram:-
Circuit Diagram DHT11 Temperature and Humidity Sensor with Arduino Uno

Description:-
  • DHT11 VCC pin – 5V output of Arduino Uno
  • OLED VCC pin – 5V output of Arduino Uno
  • DHT11 GND pin – GND of Arduino Uno
  • OLED GND pin – GND of Arduino Uno
  • DHT11 Data pin – Digital pin 2 of Arduino Uno
  • OLED SCL pin – Pin A4 of Arduino Uno
  • OLED SDA pin – Pin A5 of Arduino Uno
Program:-

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "DHT.h"

#define DHTPIN 2     
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

void setup()   {                
    display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C
    display.display(); // show splash screen
    delay(2000);
    display.clearDisplay();   // clears the screen and buffer
    dht.begin();
    delay(2000);
}

void loop() {
    float h = dht.readHumidity();
    // Read temperature as Celsius (the default)
    float t = dht.readTemperature();
    // Read temperature as Fahrenheit (isFahrenheit = true)
    float f = dht.readTemperature(true);

    // Check if any reads failed.
    if (isnan(h) || isnan(t) || isnan(f)) {
        delay(2000);
    } 
    else {
        // routine for converting temp/hum floats to char arrays
        char temp_buff[5]; char hum_buff[5];
        char temp_disp_buff[11] = "Tmp:";
        char hum_disp_buff[11] = "Hum:";
    
        // appending temp/hum to buffers
        dtostrf(t,2,1,temp_buff);
        strcat(temp_disp_buff,temp_buff);
        dtostrf(h,2,1,hum_buff);
        strcat(hum_disp_buff,hum_buff);
    
        // routine for displaying text for temp/hum readout
        display.clearDisplay();
        display.setTextSize(2);
        display.setTextColor(WHITE);
        display.setCursor(0,0);
        display.println(temp_disp_buff);
        display.println(hum_disp_buff);
        display.display();
        delay(2000);
    }
}

Functioning:-
  • The pin that is attached to the OLED reset pin is defined by the Adafruit_SSD1306 display (OLED_RESET).
  • The DHT sensor type and the pin that the data line is attached to are specified by DHT dht(DHTPIN, DHTTYPE).
  • The DHT sensor and the OLED display are initialized with their I2C addresses (0x3C) in the setup() function.
  • We continuously read the temperature and humidity values from the sensor and print them on the OLED display in the loop().
Functioning with circuit diagram

Conclusion

  • I hope you now have a better understanding of how the Arduino Uno and DHT11 temperature and humidity sensor function together. Moreover, regarding the Arduino Uno and SSD1306 OLED display integration. If you have any questions, don't hesitate to leave a remark below.

List of Practicals

Internet of Things (List of Practicals)


Following practicals have to be perform in IOT lab.
  1. Installation of Arduino IDE.
  2. Interfacing Light Emitting Diode (LED)- Blinking LED.
  3. Interfacing Button and LED – LED blinking when button is pressed.
  4. Interfacing Light Dependent Resistor (LDR) and LED, displaying automatic night lamp.
  5. Interfacing Temperature Sensor (LM35) and/or humidity sensor (e.g. DHT11).
  6. Interfacing Liquid Crystal Display (LCD) – display data generated by sensor on LCD.
  7. Interfacing Air Quality Sensor-pollution (e.g. MQ135) - display data on LCD, switch on LED when data sensed is higher than specified value.
  8. Interfacing Bluetooth module (e.g. HC05)- receiving data from mobile phone on Arduino and display on LCD.
  9. Interfacing Relay module to demonstrate Bluetooth based home automation application. (using Bluetooth and relay).
MEANS OF ASSESSMENT
− Assignments and quiz/class tests, mid-term and end-term written tests.
− viva-voice.
− Actual laboratory and practical work exercises.
− Software installation, operation, development .

LIST OF COMPONENTS
  • One kit for 3-4 students : Arduino Uno, sensors(Bluetooth module(HC05), MQ135, DHT11, breadboard , LCD, 2-relay module etc).
  • Consumables : LED, button, connecting wires, LDR, LM35, battery, etc 
Youtube For Videos Join Our Youtube Channel: Join Now