Jump to content
Electronics-Lab.com Community

Search the Community

Showing results for tags 'voice control'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Electronics Forums
    • Projects Q/A
    • Datasheet/Parts requests
    • Electronic Projects Design/Ideas
    • Power Electronics
    • Service Manuals
    • Theory articles
    • Electronics chit chat
    • Microelectronics
    • Electronic Resources
  • Related to Electronics
    • Spice Simulation - PCB design
    • Inventive/New Ideas
    • Mechanical constructions/Hardware
    • Sell/Buy electronics - Job offer/requests
    • Components trade
    • High Voltage Stuff
    • Electronic Gadgets
  • General
    • Announcements
    • Feedback/Comments
    • General
  • Salvage Area

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Yahoo


Skype


Location


Interests

Found 4 results

  1. Let’s create an offline voice-controlled LED system using the DFRobot Beetle ESP32 C6 and the DFRobot Offline Voice Learning Sensor. This project combines hardware components and programming to create an interactive system that responds to voice commands. Here’s a detailed step-by-step guide: 1️⃣Project Overview We’ll build a voice-controlled LED system that turns on and off NeoPixel lights based on spoken commands. The DFRobot Gravity Offline Voice Recognition Sensor will listen for voice input, and the Beetle ESP32 C6 will process the commands and control the LED. 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. 2️⃣Components Needed DFRobot Beetle ESP32 C6: This compact ESP32 board will serve as our microcontroller. DFRobot Gravity Offline Voice Recognition Sensor: An offline voice recognition module with built-in command words and self-learning capabilities. Breadboard and Jumper Wires: For connecting the components. 3️⃣Wiring Diagram Connect the DFRobot Gravity Sensor to the Beetle ESP32 C6 using jumper wires. 4️⃣ Install the Arduino IDE : If you haven’t already, download and install the Arduino IDE. 5️⃣Add the ESP32 Board to Arduino IDE: Follow these steps to add the ESP32 board to your Arduino IDE: Open the Arduino IDE. Go to File > Preferences. In the “Additional Boards Manager URLs” field, add the following URL: https://dl.espressif.com/dl/package_esp32_index.json Click OK. Go to Tools > Board > Boards Manager. Search for “esp32” and install the “esp32” package. Select the Beetle ESP32 C6 as your board under Tools > Board. 6️⃣Download the DFRobot Voice Recognition Library: Visit the DFRobot Voice Recognition Sensor tutorial for detailed steps. Download the DFRobot Voice Recognition Library from the DFRobot website. 7️⃣Write the Arduino Sketch: Create a new Arduino sketch (File > New). Copy and paste the following sample code into your sketch: #include "DFRobot_DF2301Q.h" DFRobot_DF2301Q_I2C DF2301Q; int led = 15; void setup() { Serial.begin(115200); pinMode(led, OUTPUT); 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(); Serial.print("CMDID = "); Serial.println(CMDID); if (CMDID == 5) { digitalWrite(led, HIGH); } if (CMDID == 6) { digitalWrite(led, LOW); } } 8️⃣Voice Commands: The DFRobot Gravity Sensor comes with 121 built-in fixed command words. You can also add 17 custom command words. For example: “Turn on the lights” “Change color to blue” “Dim the lights” 9️⃣Upload the Sketch: Connect your Beetle ESP32 C6 to your computer via USB. Select the Arduino IDE's appropriate COM port and board (ESP32 Dev Module). Click the Upload button to upload the sketch to your Beetle ESP32 C6. 🔟Test Your Voice-Controlled LED System: Power up your system. Speak the predefined voice commands to control the led ✅Conclusion With this setup, you’ll have an offline voice-controlled LED system that responds to your spoken commands. Feel free to expand the project by adding more custom commands or integrating other devices!
  2. As our population ages, ensuring the safety and well-being of seniors becomes increasingly important. A voice-controlled SOS system can provide peace of mind for both elders and their caregivers. In this project, we’ll create a personalized emergency response system that allows seniors to call for help using voice commands. Additionally, we’ll integrate Telegram alerts to notify caregivers or family members instantly. Project Components⚙️ Voice Recognition Module: We’ll use a voice recognition chip or module that responds to specific voice commands. When the user says a predefined phrase (e.g., “Help” or “Emergency”), the system will activate. Microcontroller (M5StickC): The brain of our system, responsible for processing voice commands and triggering alerts. Telegram Bot: We’ll set up a Telegram bot to send alerts to designated contacts. Telegram provides a secure and reliable platform for notifications. 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. Step 1️⃣:Voice Recognition Module Setup🔊: Connect the voice recognition module to the M5StickC via the Grove interface. The Grove interface consists of a standardized 4-pin connector (GND, VCC, SDA, SCL). Connect the voice recognition module’s pins (VCC, GND, SDA, SCL) to the corresponding Grove pins on the M5StickC. Train the module with the chosen SOS phrases. In my case, I'm going to use the default wake word as a SOS command. Step 2️⃣:Microcontroller Configuration⌨️: First, we need to install the Voice Learning sensor's library to the Arduino IDE. Here is the simple Arduino sketch that can read the voice learning sensor's command and print the command ID. #include "DFRobot_DF2301Q.h" DFRobot_DF2301Q_I2C DF2301Q; void setup() { Serial.begin(115200); 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(); if(0 != CMDID) { Serial.print("CMDID = "); Serial.println(CMDID); } delay(3000); } Here is the serial terminal response. Step 3️⃣:Setting up the Telegram Bot 🤖: Go to Google Play or App Store, download, and install Telegram. In my case, I'm using telegram web. First, search for “botfather” and click the BotFather as shown below. Next, start the BotFather, and use /newbot to create a new bot. Next, name your bot. Then, mention the username. Finally, it will show you the API key. Step 4️⃣: Creating a user for Telegram Bot 👤: Anyone that knows your bot username can interact with it. To make sure that we ignore messages that are not from our Telegram account (or any authorized users), you can get your Telegram User ID. In your Telegram account, search for “IDBot” Start a conversation with that bot and type /getid. You will get a reply with your user ID. Save that user ID, because you’ll need it later in this tutorial. Step 5️⃣:System Deployment🛜: Finally, upload the following sketch to the M5StickC and change the credentials as per your Bot setup. #include <WiFi.h> #include <WiFiClientSecure.h> #include <UniversalTelegramBot.h> #include <ArduinoJson.h> #include "DFRobot_DF2301Q.h" #include <M5StickC.h> DFRobot_DF2301Q_I2C DF2301Q; // Replace with your network credentials const char* ssid = "ELDRADO"; const char* password = "amazon123"; // Initialize Telegram BOT #define BOTtoken "6897873881" // your Bot Token (Get from Botfather) #define CHAT_ID "" WiFiClientSecure client; UniversalTelegramBot bot(BOTtoken, client); void setup() { Serial.begin(115200); M5.begin(); M5.Lcd.setRotation(3); M5.Lcd.fillScreen(BLACK); M5.Lcd.setSwapBytes(true); M5.Lcd.setTextSize(1); M5.Lcd.setCursor(7, 20, 2); M5.Lcd.setTextColor(TFT_GREEN, TFT_BLACK); // Attempt to connect to Wifi network: Serial.print("Connecting Wifi: "); Serial.println(ssid); WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); client.setCACert(TELEGRAM_CERTIFICATE_ROOT); // Add root certificate for api.telegram.org while (WiFi.status() != WL_CONNECTED) { Serial.print("."); delay(500); } Serial.println(""); Serial.println("WiFi connected"); Serial.print("IP address: "); Serial.println(WiFi.localIP()); bot.sendMessage(CHAT_ID, "Bot started up", ""); 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(); if (0 != CMDID) { Serial.print("CMDID = "); Serial.println(CMDID); bot.sendMessage(CHAT_ID, "Alarm Triggered !!", ""); M5.Lcd.fillScreen(BLACK); M5.Lcd.setCursor(3, 2); M5.Lcd.print("Alarm Triggered !!"); } delay(5000); M5.Lcd.fillScreen(BLACK); M5.Lcd.setCursor(1, 3); M5.Lcd.print("System Online"); } Once you have uploaded the sketch look for the serial terminal response. Now let's test the system, just say the command word and look for the response. Here is the Telegram response. Conclusion✅ By combining voice control, Telegram alerts, and a user-friendly interface, our Voice-Controlled SOS System provides a simple yet effective solution for seniors. Whether they’re at home or outdoors, they can call for help with ease. Caregivers and family members can rest assured knowing that they’ll receive immediate notifications in case of an emergency. Let’s build a safer and more connected environment for our elders! 🗣️🆘📲
  3. 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 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! 🚀
  4. Creating a voice-controlled lighting system can add a touch of magic to any environment. In this blog, we’ll explore how to integrate the DFRobot Gravity: Offline Language Learning Voice Recognition Sensor with a Neo Pixel light strip, all controlled by a Beetle ESP32 C3 microcontroller. Introduction to DFRobot Gravity Voice Recognition Sensor The DFRobot Gravity: Offline Voice Recognition Sensor is a powerful module designed for voice command projects. Here are its key features: Offline Operation: Unlike cloud-based solutions, this sensor works without an internet connection. It’s built around an offline voice recognition chip, making it ideal for applications where internet connectivity is not available or desired. Built-in Command Words: The sensor comes with 121 fixed command words preloaded. These cover a wide range of common instructions, eliminating the need for users to record their voices. Custom Commands: Additionally, the sensor supports the addition of 17 custom command words. This flexibility allows you to train it to recognize specific sounds or phrases, such as whistling, snapping, or even cat meows. Self-Learning Function: The self-learning feature enables you to teach the sensor new commands. For example, you could use it in an automatic pet feeder. When your cat emits a meow, the sensor recognizes it and triggers the feeder to provide food promptly. User-Friendly Design: With its straightforward interface, the sensor simplifies voice interaction projects. Whether you’re building smart home appliances, toys, lighting fixtures, or robotics, this sensor provides a flexible solution. Key Features: Offline Operation: Works without the need for an internet connection. Custom Commands: Supports adding custom voice commands. Compatibility: Can be used with Arduino, Raspberry Pi, Python, and Beetle ESP32 C3. 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. Neo Pixel: A Symphony of Lights Neo Pixel LEDs are individually addressable RGB LEDs, which means each LED’s color and brightness can be controlled independently. This makes them ideal for creating dynamic and colorful lighting effects. Why Choose Neo Pixel? Individual Addressability: Control each LED separately. Vibrant Colors: Create a spectrum of colors with RGB LEDs. Energy Efficient: Low power consumption with bright output. The Beetle ESP32 C3 Controller: The Brain Behind the Operation The Beetle ESP32 C3 is a small, powerful development board ideal for IoT projects. It features: A RISC-V 32-bit single-core processor for efficient performance. A coin-sized design, making it highly portable. Up to 13 digital I/O ports for various connections. Onboard battery management for direct li-ion battery connection. Wi-Fi and Bluetooth 5 (LE) support for versatile networking. Compatibility with Arduino IDE, ESP-IDF, and MicroPython, and supports C and Python programming. An expansion board for additional power sources and a GDI for screens. Operates at 3.3V with a Type-C input of 5V DC and a charging current of 400mA. Suitable for a wide range of temperatures, from -40 to 105°C. It’s a compact yet feature-rich board that’s adaptable for a variety of applications. Advantages of Beetle ESP32 C3: Connectivity: Wi-Fi and Bluetooth ready. Powerful: Enough processing power to handle complex tasks. Versatile: Compatible with various programming environments. Bringing It All Together To create a voice-controlled Neo Pixel light system, we’ll need to connect the DFRobot Gravity sensor to the Beetle ESP32 C3 and then to the Neo Pixel strip. The Beetle ESP32 C3 will listen to voice commands through the sensor and control the Neo Pixel lights accordingly. Adding Custom Commands in DFRobot Gravity Voice Recognition Sensor Let’s dive into the process of adding custom command words: First, let's upload the following sketch to the Beetle board, this sketch will show you the exact command ID which is related to the custom voice instructions. /*! * @file i2c.ino * @brief Control the voice recognition module via I2C * @n Get the recognized command ID and play the corresponding reply audio according to the ID; * @n Get and set the wake-up state duration, set mute mode, set volume, and enter the wake-up state * @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com) * @licence The MIT License (MIT) * @author [qsjhyy]([email protected]) * @version V1.0 * @date 2022-12-30 * @url https://github.com/DFRobot/DFRobot_DF2301Q */ #include "DFRobot_DF2301Q.h" //I2C communication DFRobot_DF2301Q_I2C DF2301Q; void setup() { Serial.begin(115200); // Init the sensor while( !( DF2301Q.begin() ) ) { Serial.println("Communication with device failed, please check connection"); delay(3000); } Serial.println("Begin ok!"); /** * @brief Set voice volume * @param voc - Volume value(1~7) */ DF2301Q.setVolume(4); /** * @brief Set mute mode * @param mode - Mute mode; set value 1: mute, 0: unmute */ DF2301Q.setMuteMode(0); /** * @brief Set wake-up duration * @param wakeTime - Wake-up duration (0-255) */ DF2301Q.setWakeTime(15); /** * @brief Get wake-up duration * @return The currently-set wake-up period */ uint8_t wakeTime = 0; wakeTime = DF2301Q.getWakeTime(); Serial.print("wakeTime = "); Serial.println(wakeTime); /** * @brief Play the corresponding reply audio according to the command word ID * @param CMDID - Command word ID * @note Can enter wake-up state through ID-1 in I2C mode */ // DF2301Q.playByCMDID(1); // Wake-up command DF2301Q.playByCMDID(23); // Common word ID } void loop() { /** * @brief Get the ID corresponding to the command word * @return Return the obtained command word ID, returning 0 means no valid ID is obtained */ uint8_t CMDID = 0; CMDID = DF2301Q.getCMDID(); if(0 != CMDID) { Serial.print("CMDID = "); Serial.println(CMDID); } delay(3000); } Now let's talk to our sensor and add custom voice commands. First, we need to use this "Learning command word" command to add a new command. Here I have added 4 different commands. These are the commands and their related command IDs. Lights on = 5 Lights off = 6 Lights to red = 8 Lights to green = 7 Integrate Neo Pixels with Voice Sensor Here’s a simple example that tests our neo pixel led: // NeoPixel Ring simple sketch (c) 2013 Shae Erisson // Released under the GPLv3 license to match the rest of the // Adafruit NeoPixel library #include <Adafruit_NeoPixel.h> #ifdef __AVR__ #include <avr/power.h> // Required for 16 MHz Adafruit Trinket #endif // Which pin on the Arduino is connected to the NeoPixels? #define PIN 0 // On Trinket or Gemma, suggest changing this to 1 // How many NeoPixels are attached to the Arduino? #define NUMPIXELS 8 // Popular NeoPixel ring size // When setting up the NeoPixel library, we tell it how many pixels, // and which pin to use to send signals. Note that for older NeoPixel // strips you might need to change the third parameter -- see the // strandtest example for more information on possible values. Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); #define DELAYVAL 500 // Time (in milliseconds) to pause between pixels void setup() { // These lines are specifically to support the Adafruit Trinket 5V 16 MHz. // Any other board, you can remove this part (but no harm leaving it): #if defined(__AVR_ATtiny85__) && (F_CPU == 16000000) clock_prescale_set(clock_div_1); #endif // END of Trinket-specific code. pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) } void loop() { pixels.clear(); // Set all pixel colors to 'off' // The first NeoPixel in a strand is #0, second is 1, all the way up // to the count of pixels minus one. for(int i=0; i<NUMPIXELS; i++) { // For each pixel... // pixels.Color() takes RGB values, from 0,0,0 up to 255,255,255 // Here we're using a moderately bright green color: pixels.setPixelColor(i, pixels.Color(0, 150, 0)); pixels.show(); // Send the updated pixel colors to the hardware. delay(DELAYVAL); // Pause before next pass through loop } } Here is the neo-pixel response. Finally, let's integrate the voice sensor with our neo-pixel. #include "DFRobot_DF2301Q.h" #include <Adafruit_NeoPixel.h> #define PIN 0 // Neo Adafruit_NeoPixel strip = Adafruit_NeoPixel(8, PIN, NEO_GRB + NEO_KHZ800); //I2C communication DFRobot_DF2301Q_I2C DF2301Q; void setup() { Serial.begin(115200); strip.begin(); strip.setBrightness(100); strip.show(); 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(); if (0 != CMDID) { Serial.print("CMDID = "); Serial.println(CMDID); } if (CMDID == 5) { strip.clear(); // Set all pixel colors to 'off' for (int i = 0; i < 12; i++) { // For each pixel... strip.setPixelColor(i, strip.Color(255, 255, 255)); strip.show(); } } else if (CMDID == 6) { strip.clear(); for (int i = 0; i < 12; i++) { // For each pixel... strip.setPixelColor(i, strip.Color(0, 0, 0)); strip.show(); } } else if (CMDID == 7) { strip.clear(); for (int i = 0; i < 12; i++) { // For each pixel... strip.setPixelColor(i, strip.Color(255, 0, 0)); strip.show(); } } else if (CMDID == 8) { strip.clear(); for (int i = 0; i < 12; i++) { // For each pixel... strip.setPixelColor(i, strip.Color(0, 255, 0)); strip.show(); } } } This script sets up the Beetle ESP32 C3 to control a Neo Pixel strip and changes the color based on voice commands received from the DFRobot Gravity sensor. Conclusion Integrating the DFRobot Gravity Voice Recognition Sensor with Neo Pixel lights controlled by a Beetle ESP32 C3 offers endless possibilities for creating interactive and responsive environments. Whether it’s for home automation, art installations, or educational purposes, this combination of technology brings both functionality and creativity to your projects. I hope this blog post inspires you to create your voice-controlled lighting system. If you have any questions or need further guidance, feel free to reach out!
×
  • Create New...