| Gravity | Offline Voice Recognition Sensor |
| Gravity | Offline Voice Recognition Sensor |
Offline Voice Recognition Sensor is widely available through online retailers and distributors. For more information on purchasing and availability, please visit the manufacturer's website or authorized resellers.
Datasheet
User Manual
| Library and Code Examples (for micro | bit, Arduino, and ESP32) |
Tutorial and Project Guides
Gravity: Offline Voice Recognition Sensor DocumentationOverviewThe Gravity: Offline Voice Recognition Sensor is a versatile voice recognition module designed for micro:bit, Arduino, and ESP32 boards. It features I2C and UART interfaces, enabling easy integration with a wide range of IoT projects. This sensor allows for offline voice recognition, eliminating the need for internet connectivity, making it an ideal choice for various applications such as home automation, robotics, and more.Technical SpecificationsPower supply: 3.3V - 5V
Communication protocols: I2C, UART
Recognition accuracy: Up to 95%
Support for 255 customizable voice commands
Adjustable sensitivity and threshold settingsCode Examples### Example 1: Using the Gravity Voice Recognition Sensor with micro:bit (MicroPython)In this example, we'll demonstrate how to use the Gravity Voice Recognition Sensor with a micro:bit board to recognize and respond to voice commands.Hardware ConnectionConnect the Gravity Voice Recognition Sensor to the micro:bit board using the I2C interface:
+ VCC to 3V
+ GND to GND
+ SCL to SCL (P19)
+ SDA to SDA (P20)Code```python
import i2c
import microbit# Initialize the Gravity Voice Recognition Sensor
sensor = i2c.I2C(scl=microbit.pin19, sda=microbit.pin20, freq=400000)# Define a list of voice commands and their corresponding actions
commands = {
'hello': lambda: microbit.display.show('Hello!'),
'goodbye': lambda: microbit.display.show('Goodbye!'),
'turn on': lambda: microbit.pin13.write_digital(1),
'turn off': lambda: microbit.pin13.write_digital(0)
}while True:
# Read the recognition result from the sensor
result = sensor.read(0x00, 1)
if result:
# Get the recognized command
command = commands.get(result.decode('utf-8').strip())
if command:
# Execute the corresponding action
command()
```### Example 2: Using the Gravity Voice Recognition Sensor with Arduino (C++)In this example, we'll demonstrate how to use the Gravity Voice Recognition Sensor with an Arduino board to recognize and respond to voice commands.Hardware ConnectionConnect the Gravity Voice Recognition Sensor to the Arduino board using the UART interface:
+ VCC to 5V
+ GND to GND
+ TX to RX (Digital Pin 0)
+ RX to TX (Digital Pin 1)Code```cpp
#include <SoftwareSerial.h>// Define the UART pins for communication with the Gravity Voice Recognition Sensor
SoftwareSerial voiceSensor(D1, D0); // RX, TXvoid setup() {
Serial.begin(9600);
voiceSensor.begin(9600);
}void loop() {
// Read the recognition result from the sensor
if (voiceSensor.available() > 0) {
String command = voiceSensor.readStringUntil('
');
command.trim();// Define a list of voice commands and their corresponding actions
if (command.equals("hello")) {
Serial.println("Hello!");
// Execute the corresponding action
} else if (command.equals("goodbye")) {
Serial.println("Goodbye!");
// Execute the corresponding action
} else if (command.equals("turn on")) {
digitalWrite(LED_BUILTIN, HIGH);
// Execute the corresponding action
} else if (command.equals("turn off")) {
digitalWrite(LED_BUILTIN, LOW);
// Execute the corresponding action
}
}
delay(100);
}
```### Example 3: Using the Gravity Voice Recognition Sensor with ESP32 (MicroPython)In this example, we'll demonstrate how to use the Gravity Voice Recognition Sensor with an ESP32 board to recognize and respond to voice commands.Hardware ConnectionConnect the Gravity Voice Recognition Sensor to the ESP32 board using the I2C interface:
+ VCC to 3.3V
+ GND to GND
+ SCL to SCL (GPIO 22)
+ SDA to SDA (GPIO 21)Code```python
import machine
import utime# Initialize the Gravity Voice Recognition Sensor
i2c = machine.I2C(scl=machine.Pin(22), sda=machine.Pin(21), freq=400000)# Define a list of voice commands and their corresponding actions
commands = {
'hello': lambda: print('Hello!'),
'goodbye': lambda: print('Goodbye!'),
'turn on': lambda: machine.Pin(25, machine.Pin.OUT).value(1),
'turn off': lambda: machine.Pin(25, machine.Pin.OUT).value(0)
}while True:
# Read the recognition result from the sensor
result = i2c.readfrom(0x00, 1)
if result:
# Get the recognized command
command = commands.get(result.decode('utf-8').strip())
if command:
# Execute the corresponding action
command()
utime.sleep(0.1)
```These examples demonstrate the basic usage of the Gravity Voice Recognition Sensor with various microcontrollers. You can customize and extend the code to fit your specific IoT project requirements.