Transform any car into a smart vehicle with voice-activated infotainment using the Arduino Leonardo and futuristic hands-free DFRobot DF2301Q offline voice recognition module.
Devices and components
Arduino Leonardo with headers
DFRobot Gravity: Offline Language Learning Voice Recognition Sensor for micro:bit / Arduino / ESP32 - I2C & UART
Jumper wires (generic)
Software and tools
Arduino IDE
Project description
Project Overview
Story
Windows + M opens maps
Windows + N Show notifications
Windows + [ Shows applications running in the background
Windows + B Opens the web browser
Features
Hands-free voice control of infotainment functions
Personalized wake words to activate the system
Custom defined words to trigger keyboard shortcuts
Arduino Leonardo as an HID device to send commands to the Android based infotainment system
Required Components
DFRobot DF2301Q Voice Recognition Module: Played a crucial role in this project by enabling offline voice control without the need for an internet connection. Its personalized wake word and programmable controls allowed for seamless interaction with the car's infotainment system. With its high precision and fast response time, the module ensures smooth hands-free operation, making driving safer and more convenient. Its easy integration with Arduino Leonardo helped us convert voice commands into keyboard shortcuts, bringing smart infotainment features to any car effortlessly! for more information see the $documentation$
Arduino Leonardo was a game changer in this project with its built-in USB HID (Human Interface Device) functionality, allowing it to act as a keyboard. This enabled seamless execution of voice-triggered commands by sending keyboard shortcuts directly to the car's infotainment system. Its reliable performance, easy programmability, and compatibility with the DFRobot DF2301Q voice recognition module made it the ideal microcontroller for implementing hands-free control. With Arduino Leonardo, we transformed a standard infotainment system into an intelligent voice-controlled interface. For more information, see the $documentation$.
Jumper Wires: Jumper wires are insulated wires with connector pins used to make an electrical connection between components.
Relationships
Arduino Leonardo DFRobot DF2301Q Voice Recognition Module VCC to 5v
GND of DFRobot DF2301Q voice recognition module to GND of Arduino Leonardo
C from DFRobot DF2301Q voice recognition module to Arduino Leonardo SCL
D from DFRobot DF2301Q voice recognition module to Arduino Leonardo SDA
How it works
The DFRobot DF2301Q module is configured with a custom wake word ("Hello i10").
The module remains in sleep mode until the wake word is spoken
After waking up, the module listens for a command (for example "Open Maps").
Based on the recognized command, it sends a command ID (CMDID) to the Arduino
The Arduino Leonardo interprets the command and sends the appropriate keyboard shortcut using its HID capabilities
The infotainment system responds by performing corresponding actions
Configuring wake words and commands
Learn the wake word
Use the default wake word to initiate the process.
Say “Learn wake word” and follow the prompts.
Say the desired wake-up word (e.g. “Hello i10”) three times.
Once learning is complete, the system will now respond to “Hello i10”.
Learn command words
Wake up the assistant by saying your custom word in my case it's "Hello i10".
Say “Learn Command Word” to start command learning mode.
Say each command phrase (e.g. “Open Maps”) three times.
The system assigns an ID (CMDID) to each order.
These identifiers will be used in the Arduino program to trigger specific actions.
Deleting a wake word or commands
Say "I want to delete" to enter delete mode.
Choose between Clear Wake Word (removes the learned wake word), Clear Command Words (removes specific learned commands), Clear All (resets all wake words and commands)
Implementing Arduino code
Initializes the DFRobot DF2301Q module.
Listen for command IDs
Sends HID keyboard shortcuts based on the recognized command
#include "DFRobot_DF2301Q.h"
#include "Keyboard.h"
DFRobot_DF2301Q_I2C DF2301Q;
void setup()
{
Serial.begin(115200);
Keyboard.begin(); // Initialize Keyboard functionality
while (!(DF2301Q.begin()))
{
Serial.println("Communication with device failed, please check connection");
delay(3000);
}
Serial.println("Begin ok!");
DF2301Q.setVolume(6);
DF2301Q.setMuteMode(0);
DF2301Q.setWakeTime(15);
Serial.print("WakeTime = ");
Serial.println(DF2301Q.getWakeTime());
}
void loop()
{
uint8_t CMDID = DF2301Q.getCMDID();
if (CMDID != 0)
{
Serial.print("CMDID = ");
Serial.println(CMDID);
switch (CMDID)
{
case 5:
Serial.println("Performing: Windows + M");
Keyboard.press(KEY_LEFT_GUI); // Windows key
Keyboard.press('m');
delay(100);
Keyboard.releaseAll();
break;
case 6:
Serial.println("Performing: Escape");
Keyboard.press(KEY_ESC);
delay(100);
Keyboard.releaseAll();
break;
case 7:
Serial.println("Performing: Windows + [");
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press('[');
delay(100);
Keyboard.releaseAll();
break;
case 8:
Serial.println("Performing: Windows + B");
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press('b');
delay(100);
Keyboard.releaseAll();
break;
case 9:
Serial.println("Performing: Windows + N");
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press('n');
delay(100);
Keyboard.releaseAll();
break;
default:
Serial.println("Unknown CMDID");
break;
}
}
delay(300);
}
Video of this project
Conclusion
Arduino code
1#include "DFRobot_DF2301Q.h"
2#include "Keyboard.h"
3DFRobot_DF2301Q_I2C DF2301Q;
4void setup()
5{
6Serial.begin(115200);
7Keyboard.begin(); // Initialize Keyboard functionality
8while (!(DF2301Q.begin()))
9{
10Serial.println("Communication with device failed, please check connection");
11delay(3000);
12}
13Serial.println("Begin ok!");
14DF2301Q.setVolume(6);
15DF2301Q.setMuteMode(0);
16DF2301Q.setWakeTime(15);
17Serial.print("WakeTime = ");
18Serial.println(DF2301Q.getWakeTime());
19}
20void loop()
21{
22uint8_t CMDID = DF2301Q.getCMDID();
23if (CMDID != 0)
24{
25Serial.print("CMDID = ");
26Serial.println(CMDID);
27switch (CMDID)
28{
29case 5:
30Serial.println("Performing: Windows + M");
31Keyboard.press(KEY_LEFT_GUI); // Windows key
32Keyboard.press('m');
33delay(100);
34Keyboard.releaseAll();
35break;
36case 6:
37Serial.println("Performing: Escape");
38Keyboard.press(KEY_ESC);
39delay(100);
40Keyboard.releaseAll();
41break;
42case 7:
43Serial.println("Performing: Windows + [");
44Keyboard.press(KEY_LEFT_GUI);
45Keyboard.press('[');
46delay(100);
47Keyboard.releaseAll();
48break;
49case 8:
50Serial.println("Performing: Windows + B");
51Keyboard.press(KEY_LEFT_GUI);
52Keyboard.press('b');
53delay(100);
54Keyboard.releaseAll();
55break;
56case 9:
57Serial.println("Performing: Windows + N");
58Keyboard.press(KEY_LEFT_GUI);
59Keyboard.press('n');
60delay(100);
61Keyboard.releaseAll();
62break;
63default:
64Serial.println("Unknown CMDID");
65break;
66}
67}
68delay(300);
69}
Note: Content and images are from: https://projecthub.arduino.cc/, with some modifications.
If you want it removed due to copyright reasons, please leave a comment. Thank you.
I want to share this article more widely so that everyone knows about Arduino and your project.