Story
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:
1.DFRobot FireBeetle 2 ES32 S3
2.DHT11 Temperature and Humidity Sensor
3.DFRobot Gravity Offline Voice Recognition sensor
4.Jumper Cables
🔌 Wiring Diagram:
Connect the DHT11 sensor to the FireBeetle as follows:
1.GND pin: Connect to GND (0V).2.VCC pin: Connect to VCC (5V or 3.3V).3.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:
1.GND pin: Connect to GND (0V).2.VCC pin: Connect to VCC (5V or 3.3V).3.DATA pin: SDA4.CLOCK pin:SCL
Finally, connect the TFT screen to the FireBeetle directly via the connector interface.
Get PCBs for Your Projects Manufactured
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.
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.
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.
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.
As well as the DHT11 sensor.
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.
Test the sensor by speaking the fixed command words and your custom commands. And look at the serial terminal for the response.
Finally, you can see the DHT11 data on the TFT screen.
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! 🚀