Wednesday, February 8, 2023
Google search engine
HometelecomESP32-ESP8266 – DTH11 SENSOR

ESP32-ESP8266 – DTH11 SENSOR

1. Introduction

Currently, with the continuous development of science and technology, all daily activities are automated, robots gradually take over many positions in our daily lives. In order to have the correct and efficient operation of automation devices, sensors are one of the key components. Motion sensors are one of them, which can help detect the movement of people or objects, thereby helping mechanical devices have the correct control signals.

In this article, we will show you how to connect and operate the PIR motion sensor with ESP32-ESP8266 using visual studio code included with the IO IDE platform. Through this tutorial, you will be able to apply motion sensors to your projects, making your products smarter.

2. SENSOR-MODULE/EXPANSION BOARD PINOUT DIAGRAM

2.1. Hardware Introduction

2.1.1. Module ESP32

In this project, they will need to use the esp32 module, specifically I chose esp32 wroom devkit v1. Picture below

ESP32-WROOM-32 is a powerful, generic Wi-Fi+BT+BLE MCU module that targets a wide variety of applications, ranging from low-power sensor networks to the most demanding tasks, such as voice encoding, music streaming and MP3 decoding.

At the core of this module is the ESP32-D0WDQ6 chip*. The chip embedded is designed to be scalable and adaptive. There are two CPU cores that can be individually controlled, and the CPU clock frequency is adjustable from 80 MHz to 240 MHz. The chip also has a low-power co-processor that can be used instead of the CPU to save power while performing tasks that do not require much computing power, such as monitoring of peripherals. ESP32 integrates a rich set of peripherals, ranging from capacitive touch sensors, Hall sensors, SD card interface, Ethernet, high-speed SPI, UART, I²S and I²C.

2.1.2. ESP8266

Espressif’s ESP8266EX delivers highly integrated Wi-Fi SoC solution to meet users’ continuous demands for efficient power usage, compact design and reliable performance in the Internet of Things industry.
With the complete and self-contained Wi-Fi networking capabilities, ESP8266EX can perform either as a standalone application or as the slave to a host MCU. When ESP8266EX hosts the application, it promptly boots up from the flash. The integrated highspeed cache helps to increase the system performance and optimize the system memory. Also, ESP8266EX can be applied to any microcontroller design as a Wi-Fi adaptor through SPI/SDIO or UART interfaces.

ESP8266EX integrates antenna switches, RF balun, power amplifier, low noise receive amplifier, filters and power management modules. The compact design minimizes the PCB size and requires minimal external circuitries.

Besides the Wi-Fi functionalities, ESP8266EX also integrates an enhanced version of Tensilica’s L106 Diamond series 32-bit processor and on-chip SRAM. It can be interfaced with external sensors and other devices through the GPIOs. Software Development Kit (SDK) provides sample codes for various applications.

Espressif Systems’ Smart Connectivity Platform (ESCP) enables sophisticated features including:

  • Fast switch between sleep and wakeup mode for energy-efficient purpose;
  • Adaptive radio biasing for low-power operation
  • Advance signal processing
  • Spur cancellation and RF co-existence mechanisms for common cellular, Bluetooth, DDR, LVDS, LCD interference mitigation

ESP8266 Specifications

2.1.3. DHT11

DHT11 output calibrated digital signal. It applies exclusive digital-signal-collecting-technique and humidity sensing technology, assuring its reliability and stability. Its sensing elements is connected with 8-bit single-chip computer.

Every sensor of this model is temperature compensated and calibrated in accurate calibration chamber and the calibration-coefficient is saved in type of programmer in OTP memory, when the sensor is detecting, it will cite coefficient from memory.

Small size & low consumption & long transmission distance(100m) enable DHT11 to be suited in all kinds of harsh application occasions. Single-row packaged with four pins, making the connection very convenient.

Operating specifications:

Power and Pins : Power’s voltage should be 3.3-5.5V DC. When power is supplied to sensor, don’t send any instruction to the sensor within one second to pass unstable status. One capacitor valued 100nF can be added between VDD and GND for wave filtering.
Communication and signal: 1-wire bus is used for communication between MCU and DHT11.

2.1.4. LCD 16x2 – I2C

The term LCD stands for liquid crystal display. It is one kind of electronic display module used in an extensive range of applications like various circuits & devices like mobile phones, calculators, computers, TV sets, etc. These displays are mainly preferred for multi-segment light-emitting diodes and seven segments. The main benefits of using this module are inexpensive; simply programmable, animations, and there are no limitations for displaying custom characters, special and even animations, etc.

Features of LCD16x2:

+ The operating voltage of this LCD is 4.7V-5.3V
+ It includes two rows where each row can produce 16-characters.
+ The utilization of current is 1mA with no backlight
+ Every character can be built with a 5×8 pixel box
+ The alphanumeric LCDs alphabets & numbers
+ Is display can work on two modes like 4-bit & 8-bit
+ These are obtainable in Blue & Green Backlight
+ It displays a few custom generated characters

I2C Serial Interface Adapter

It is also known as I2C Module. It has total of 20 male pins. 16 pins are faced to rear side and 4 pins faced towards front side. The 16 pins for connect to 16×2 LCD and the 2 pins out of 4 pins are SDA and SCL. SDA is the serial data pin and SCL is the clock pin. The rest 2 pins for power supply (Vcc and ground).There is a POT on the I2C Module. We can control the contrast of the LCD display by rotating this POT. And there is a jumber fixed on the module. When we remove the jumber, the backlight of the LCD display will go OFF.

2.2. How to connect

Source code:

Source esp32:

#include <Arduino.h>

#include <DHT.h>

#include <Wire.h>

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2);

 const int DHTPIN = 15;

const int DHTTYPE = DHT11;

DHT dht(DHTPIN, DHTTYPE);

 byte degree[8] = {

  0B01110,

  0B01010,

  0B01110,

  0B00000,

  0B00000,

  0B00000,

  0B00000,

  0B00000

};

void setup() {

  lcd.init(); 

  lcd.backlight();

  lcd.print(“Temper: “);

  lcd.setCursor(0,1);

  lcd.print(“Humidity: “);

  lcd.createChar(1, degree);

  dht.begin(); 

}

void loop() {

  float h = dht.readHumidity();

  float t = dht.readTemperature();

  if (isnan(t) || isnan(h)) {

  }

  else { lcd.setCursor(10,0);
 lcd.print(round(t));

    lcd.print(” “);

    lcd.write(1);

    lcd.print(“C”);

 lcd.setCursor(10,1);

    lcd.print(round(h));

    lcd.print(” %”);   

  }

}

Source Code esp8266

#include <Arduino.h>

#include <DHT.h>

#include <Wire.h>

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2);

const int DHTPIN = D4;

const int DHTTYPE = DHT11;

DHT dht(DHTPIN, DHTTYPE);

byte degree[8] = {

  0B01110,

  0B01010,

  0B01110,

  0B00000,

  0B00000,

  0B00000,

  0B00000,

  0B00000

};

 void setup() {

  lcd.init(); 

  lcd.backlight();

  lcd.print(“Temper: “);

  lcd.setCursor(0,1);

  lcd.print(“Humidity: “);

  lcd.createChar(1, degree);

  dht.begin(); 

}

void loop() {

  float h = dht.readHumidity();

  float t = dht.readTemperature();

if (isnan(t) || isnan(h)) {

}

else

{

lcd.setCursor(10,0);

lcd.print(round(t));

lcd.print(” “);

lcd.write(1);

lcd.print(“C”);

lcd.setCursor(10,1);

lcd.print(round(h));

lcd.print(” %”);

}

}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments