icon

Voice-Controlled Neo Pixels

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:

 

1..A RISC-V 32-bit single-core processor for efficient performance.

2. A coin-sized design, making it highly portable. 

3. Up to 13 digital I/O ports for various connections. 

4. Onboard battery management for direct lithium battery connection. 

5. Wi-Fi and Bluetooth 5 (LE) support for versatile networking. 

6. Compatibility with Arduino IDE, ESP-IDF, and MicroPython, and supports C and Python programming. 

7. An expansion board for additional power sources and a GDI for screens. 

8.Operates at 3.3V with a Type-C input of 5V DC and a charging current of 400mA

9. Suitable for a wide range of temperatures, from -40 to 105°C.

10. 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.

 

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:

CODE
// 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
  }
}

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.

CODE
// 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();
    }
  }

}

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!

 

License
All Rights
Reserved
licensBg
0