Temperature and Humidity Monitoring Using Bharath Pi

by bharatpi in Circuits > Arduino

382 Views, 0 Favorites, 0 Comments

Temperature and Humidity Monitoring Using Bharath Pi

DSC_0725.JPG

 In the rapidly advancing world of the Internet of Things (IoT) and home automation, understanding and controlling the environment around us has become essential. Temperature and humidity are critical parameters that influence our comfort, health, and the behaviour of various systems. In this blog, we will delve into the fascinating world of temperature and humidity sensors, exploring their principles, applications, and how they contribute to creating smarter and more efficient living spaces.

in this project, we will build a temperature and humidity monitoring system using Bharath Pi and two popular sensors: the DHT11 temperature and humidity sensor. This system will display real-time temperature and humidity readings on an LCD display. Let's get started!

Supplies

DSC_0733.JPG
Artboard-1-e1686767346235.jpg

Hardware Component

  • Bharath Pi board (e.g., Bharath Pi)
  • DHT11 temperature and humidity sensor
  • 16x2 LCD display (compatible with the Hitachi HD44780 driver)
  • Breadboard and jumper wires

Software apps and online services

We are going to use Arduino IDE for programming the Bharat Pi. The Bharat Pi can be connected using a USB Type-C connector. Serial drivers are required to be installed for the detection of Bharat Pi. You can download the serial drivers from this depending on the operating system.

·      Arduino IDE

·      CH341 serial drivers for Bharat Pi

Connection

Untitled Diagram.drawio (3).png
aaaaaaaa.jpg
  1. Connect the VCC pin of the DHT11 sensor to the 5V pin on the Bharath Pi.
  2. Connect the GND pin of the DHT11 sensor to the GND pin on the Bharath Pi.
  3. Connect the OUT pin of the DHT11 sensor to digital pin 2 on the Bharath Pi.
  4. Connect the VCC and GND pins of the LCD display to 5V and GND pins on the Bharath Pi, respectively.
  5. Connect the SDA and SCL pins of the LCD display to SCL and SDA pins on the Bharath Pi, respectively.

Explanation:

  1. We include the necessary libraries for the LCD display and the DHT11 sensor.
  2. Define the DHT11 sensor pin and the I2C address of the LCD display.
  3. Initialize the LCD display and print the initial text on it.
  4. In the loop() function, we read temperature and humidity from the DHT11 sensor using the DHT.read() function.
  5. We update the LCD display with the new temperature and humidity readings.


Story

DHT11-Sensor.jpg

What are Temperature and Humidity Sensors?

Temperature sensors, as the name suggests, measure the ambient temperature of the surrounding environment. These sensors can be classified into contact and non-contact types. Contact sensors, like thermocouples and thermistors, physically come in direct contact with the object to be measured. Non-contact sensors, such as infrared temperature sensors (IR sensors), measure temperature remotely by detecting the thermal radiation emitted by the object.

On the other hand, humidity sensors, or hygrometers, measure the moisture content in the air. They are essential in various applications, including weather forecasting, indoor climate control, industrial processes, and even agricultural practices.

2. How do Temperature and Humidity Sensors Work?

Temperature Sensors:

  • Thermocouples work on the principle of the Seebeck effect, where two dissimilar metals produce a voltage proportional to the temperature difference between the hot and cold junctions.
  • Thermistors are resistors whose resistance changes with temperature. They are of two types: negative temperature coefficient (NTC) and positive temperature coefficient (PTC) thermistors.
  • Infrared temperature sensors detect the infrared energy emitted by an object and convert it into an electrical signal, which is then used to calculate the temperature.

Humidity Sensors:

  • Capacitive humidity sensors measure the change in capacitance of a capacitor due to the absorption of water molecules on its surface.
  • Resistive humidity sensors, also known as hygroscopic sensors, use a moisture-absorbing material whose resistance changes with humidity levels.
  • Thermal conductivity humidity sensors measure the cooling effect of water vapor on a heated sensing element.

What is Bharat Pi:

In this project, we are using Bharat Pi which has both ESP32 microcontroller and a SimCom A7672S 4G/LTE module.

Bharat Pi is an IoT prototyping board for students, innovators, startups, and developers. A simplified board with an all-in-one compute, network and storage on a single board to build rapid prototypes.

Bharat Pi bundles the power of ESP32, 4G/LTE module in a Arduino form factor. This makes Bharat Pi compatible with all Arduino and ESP32 programs and shields

Wireless monitoring can be done using WiFi or with a Sim based 4G/LTE connectivity.

Bharat Pi is a rugged board with good quality and could be used even for production and live customer deployments!


Snapshot

DSC_0724.JPG
DSC_0726.JPG
DSC_0727.JPG

Working:

  1. Upload the code to your Bharath Pi board.
  2. The DHT11 sensor will start reading temperature and humidity values.
  3. The LCD display will show the real-time temperature and humidity readings

Code

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include "DHT.h"


// Define the pin and type of DHT sensor
#define DHTPIN 33
#define DHTTYPE DHT11


// Initialize the LCD and DHT objects
LiquidCrystal_I2C lcd(0x27, 16, 2);  // Change to 0x3F if 0x27 doesn't work
DHT dht(DHTPIN, DHTTYPE);


void setup() {
  // Initialize the Serial Monitor
  Serial.begin(115200);
  
  // Initialize the DHT sensor
  dht.begin();
  
  // Initialize the LCD
  lcd.init();
  lcd.backlight();
  
  // Display initial message
  lcd.setCursor(0, 0);
  lcd.print("Welcome to ");
  lcd.setCursor(0, 1);
  lcd.print("Bharat Pi");
  delay(2000);
  lcd.clear();
  
  // Check if LCD is initialized correctly
  Serial.println("LCD initialized and message displayed.");
}


void loop() {
  // Read sensor values
  float humidity = dht.readHumidity();
  float temperature = dht.readTemperature();
  
  // Clear the LCD before displaying new values
  lcd.clear();
  
  // Check if any reads failed and display error message
  if (isnan(humidity) || isnan(temperature)) {
    displayError();
    Serial.println("Error: Failed to read from DHT sensor!");
  } else {
    displayValues(temperature, humidity);
    Serial.print("Temperature: ");
    Serial.print(temperature);
    Serial.println(" °C");
    Serial.print("Humidity: ");
    Serial.print(humidity);
    Serial.println(" %");
  }
  
  // Wait before next reading
  delay(2000);
}


void displayError() {
  lcd.setCursor(0, 0);
  lcd.print("Sensor Error");
}


void displayValues(float temp, float hum) {
  // Display temperature
  lcd.setCursor(0, 0);
  lcd.print("Temp: ");
  lcd.print(temp);
  lcd.print((char)223); // Degree symbol
  lcd.print("C");
  
  // Display humidity
  lcd.setCursor(0, 1);
  lcd.print("Humidity: ");
  lcd.print(hum);
  lcd.print("%");
}

Applications

Weather Monitoring: Temperature and humidity sensors are essential components of weather stations, providing accurate data for forecasting and climatology studies.

Indoor Climate Control: In HVAC systems, these sensors ensure that indoor conditions are optimized for human comfort and energy efficiency.

Agriculture and Greenhouses: Monitoring temperature and humidity levels helps optimize crop growth and yield in controlled environments.

Food Storage and Transport: In the food industry, these sensors are used to maintain ideal conditions for storing and transporting perishable goods.

Healthcare: Temperature and humidity monitoring is crucial in healthcare settings to ensure a safe and comfortable environment for patients.

Home Automation: Smart homes use these sensors to adjust heating, cooling, and ventilation based on environmental conditions.