Jump to content
Electronics-Lab.com Community

Voice Controlled DHT11 with DFRobot


Recommended Posts

In this tutorial, I will guide you on how to create a temperature and humidity monitoring system that can be controlled by voice using a FireBeetle and a DHT11 sensor. Imagine being able to ask your FireBeetle about the current temperature and getting a visual response! Let's dive into the details.

💡 Components Required:

  • DFRobot FireBeetle 2 ES32 S3
  • DHT11 Temperature and Humidity Sensor
  • DFRobot Gravity Offline Voice Recognition sensor
  • Jumper Cables

🔌 Wiring Diagram:

Connect the DHT11 sensor to the FireBeetle as follows:

  • GND pin: Connect to GND (0V).
  • VCC pin: Connect to VCC (5V or 3.3V).
  • DATA pin: D5
  • If you’re using a DHT11 module, it may have a built-in resistor, eliminating the need for an external one.

Connect the Offline Voice Recognition sensor to the FireBeetle as follows:

  • GND pin: Connect to GND (0V).
  • VCC pin: Connect to VCC (5V or 3.3V).
  • DATA pin: SDA
  • CLOCK pin:SCL
image_1UkVEb20BD.png?auto=compress%2Cfor
 

Finally, connect the TFT screen to the FireBeetle directly via the connector interface.

whatsapp_image_2024-05-04_at_7_51_37_pm_
 

Get PCBs for Your Projects Manufactured

2_sS1dUXE2bz.PNG?auto=compress%2Cformat&
 

You must check out PCBWAY for ordering PCBs online for cheap!

You get 10 good-quality PCBs manufactured and shipped to your doorstep for cheap. You will also get a discount on shipping on your first order. Upload your Gerber files onto PCBWAY to get them manufactured with good quality and quick turnaround time. PCBWay now could provide a complete product solution, from design to enclosure production. Check out their online Gerber viewer function. With reward points, you can get free stuff from their gift shop. Also, check out this useful blog on PCBWay Plugin for KiCad from here. Using this plugin, you can directly order PCBs in just one click after completing your design in KiCad.

1️⃣ Train the custom voice commands:

This DFRobot Gravity Offline Voice Recognition Sensor sensor is designed for Arduino, Raspberry Pi, Python, and ESP32 platforms. It allows you to recognize voice commands without an internet connection and comes with built-in fixed command words as well as the ability to add custom commands.

image_Alq0hLmP1v.png?auto=compress%2Cfor
 

Here are the steps to train custom voice commands:

First, connect the Voice Recognition sensor's VCC pin to 5V and GND to GND. Then wake up the sensor by saying "Hello Robot"

Next, say "Learning command word", this will help us to add our own command words. Once the system ready, train with your custom commands.

image_L0PwO4mgT4.png?auto=compress%2Cfor
 

Here I have created two commands, one is what is the temperature? and the next one is what is the humidity? These commands have some specific ID. Normally the first command id is 5 then the following will be 6,7 and so on.

In my case what is the temperature? is command is 5 and what is the humidity? is command is 6.

image_fLPI7dUjSg.png?auto=compress%2Cfor
 

2️⃣ Install Required Libraries:

In your Arduino IDE or other development environment, install the necessary libraries for the Gravity Voice Recognition Sensor. You can find the library on the DFRobot GitHub repository.

image_PLTIgNrZHo.png?auto=compress%2Cfor
 

As well as the DHT11 sensor.

image_28UyQWoJ87.png?auto=compress%2Cfor
 

3️⃣ Programming the FireBeetle:

Write a program to interface with the sensor. You can use the provided example code or create your own.

This code will get the DHT11 temp and humidity value.

#include <dht11.h>
dht11 DHT;
#define DHT11_PIN 4

void setup(){
  Serial.begin(9600);
  Serial.println("DHT TEST PROGRAM ");
  Serial.print("LIBRARY VERSION: ");
  Serial.println(DHT11LIB_VERSION);
  Serial.println();
  Serial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)");
}

void loop(){
  int chk;
  Serial.print("DHT11, \t");
  chk = DHT.read(DHT11_PIN);    // READ DATA
  switch (chk){
    case DHTLIB_OK:
                Serial.print("OK,\t");
                break;
    case DHTLIB_ERROR_CHECKSUM:
                Serial.print("Checksum error,\t");
                break;
    case DHTLIB_ERROR_TIMEOUT:
                Serial.print("Time out error,\t");
                break;
    default:
                Serial.print("Unknown error,\t");
                break;
  }
 // DISPLAT DATA
  Serial.print(DHT.humidity,1);
  Serial.print(",\t");
  Serial.println(DHT.temperature,1);

  delay(2000);
}

Here is the complete sketch to configure DHT11 for voice recognition.

#include <Wire.h>

#include "DFRobot_GDL.h"

#define TFT_DC D2
#define TFT_CS D6
#define TFT_RST D3

#include <DFRobot_DHT11.h>
DFRobot_DHT11 DHT;
#define DHT11_PIN D5


DFRobot_ST7789_240x320_HW_SPI screen(/dc=/TFT_DC,/cs=/TFT_CS,/rst=/TFT_RST);
#include "DFRobot_DF2301Q.h"

//I2C communication
DFRobot_DF2301Q_I2C DF2301Q;

void setup()
{
  Serial.begin(115200);
  screen.begin();
  Wire.begin();

  // Init the sensor
  while ( !( DF2301Q.begin() ) ) {
    Serial.println("Communication with device failed, please check connection");
    delay(3000);
  }
  Serial.println("Begin ok!");
  DF2301Q.setVolume(7);
  DF2301Q.setMuteMode(0);
  DF2301Q.setWakeTime(15);

  uint8_t wakeTime = 0;
  wakeTime = DF2301Q.getWakeTime();
  Serial.print("wakeTime = ");
  Serial.println(wakeTime);
  DF2301Q.playByCMDID(23);   // Common word ID

}

void loop()
{
  uint8_t CMDID = 0;
  CMDID = DF2301Q.getCMDID();   c

  if (0 != CMDID) {

    Serial.print("CMDID = ");
    Serial.println(CMDID);

        int16_t color = 0x00FF;
        screen.setTextWrap(false);
        screen.setRotation(1);
        screen.fillScreen(COLOR_RGB565_BLACK);
        screen.setTextColor(COLOR_RGB565_GREEN);
        screen.setFont(&FreeMono9pt7b);
        screen.setTextSize(1.5);
        screen.setCursor(0, 30);
        screen.println("CNID:  ");
        screen.setCursor(130, 30);
        screen.setTextColor(COLOR_RGB565_RED);
        screen.println(CMDID);

    if (CMDID == 5) {
      Serial.print("CMDID = ");
      Serial.println(CMDID);

      DHT.read(DHT11_PIN);
      Serial.print("temp:");
      Serial.print(DHT.temperature);
      Serial.print("  humi:");
      Serial.println(DHT.humidity);

      int16_t color = 0x00FF;
      screen.setTextWrap(false);
      screen.setRotation(1);
      screen.fillScreen(COLOR_RGB565_BLACK);
      screen.setTextColor(COLOR_RGB565_GREEN);
      screen.setFont(&FreeMono9pt7b);
      screen.setTextSize(1.8);
      screen.setCursor(20, 50);
      screen.println("Tempearature:  ");

      screen.setTextColor(COLOR_RGB565_RED);
      screen.setCursor(160, 50);
      screen.println(DHT.temperature);
      screen.setCursor(190, 50);
      screen.println(" C");

    }

    if (CMDID == 6) {
      Serial.print("CMDID = ");
      Serial.println(CMDID);

      DHT.read(DHT11_PIN);
      Serial.print("temp:");
      Serial.print(DHT.temperature);
      Serial.print("  humi:");
      Serial.println(DHT.humidity);

      int16_t color = 0x00FF;
      screen.setTextWrap(false);
      screen.setRotation(1);
      screen.fillScreen(COLOR_RGB565_BLACK);
      screen.setTextColor(COLOR_RGB565_GREEN);
      screen.setFont(&FreeMono9pt7b);
      screen.setTextSize(1.8);
      screen.setCursor(20, 50);
      screen.println("Humidity:  ");

      screen.setTextColor(COLOR_RGB565_RED);
      screen.setCursor(160, 50);
      screen.println(DHT.humidity);
      screen.setCursor(190, 50);
      screen.println(" %");
    }
  }
  delay(1000);
}

4️⃣ Testing and Refinement:

Upload your program to the FireBeetle, select the correct COM port, and wait until it finishes the upload.

image_tEvTPPmEfA.png?auto=compress%2Cfor
 

Test the sensor by speaking the fixed command words and your custom commands. And look at the serial terminal for the response.

image_IyUbiFbjRv.png?auto=compress%2Cfor
 

Finally, you can see the DHT11 data on the TFT screen.

image_GBIkDLUA7s.png?auto=compress%2Cfor
 

5️⃣ Use in Your Project:

Now that your sensor recognizes custom voice commands, integrate it into your project. For instance, control home automation devices, trigger specific actions, or create interactive audio experiences.

Remember that the sensor’s self-learning function allows you to train it with various sounds, not just voice. So, get creative! You can use whistles, snaps, or even cat meows as custom commands. 🎙️🔊

For more detailed information, refer to the DFRobot Wiki and explore the Hackster project. Happy hacking! 🚀

Link to comment
Share on other sites


Very good. I came across another PCB based on ESP32 and DHT11 here: https://www.pcbway.com/project/shareproject/ESP32_C6_development_board_79c4da37.html

This is more compact. All parts are accomodated in a single board. It's an ESP32-C6 based development board that can be connected to a breadboard without taking up much space. Has a 3.3V regulator onboard. Features two sensors: LM35 (temperature) and DHT11 (temperature + humidity), as well as a WS2812 neopixel LED.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
  • Create New...