กลับไปหน้ารวมไฟล์
voice-controlled-home-automation-abd0d6-en.md

Image

Arduino MEGA with HC06

Introduction

Most voice-controlled architectures rely heavily on routing data to massive cloud Amazon Alexa server mainframes. The **Voice Controlled Home Automation** project completely severs the internet. It utilizes an Android smartphone's internal offline Google Speech-to-Text engine, outputting pure text strings via Bluetooth straight into an Arduino's heavy-duty relay switching matrix.

Basically in a home automation system we have a wireless switch to control different devices. But in this project we can control devices over our voice. The Mega has 54 digital pins so we can connect a vast number of devices using this board. This project will be helpful for physically challenged people who can use their voice to control anything.

String Parsing the Bluetooth Serial Data

When the user says "Turn on the living room light", the phone's app converts that acoustic waveform into an ASCII character string.

  1. The phone sends the string via Bluetooth into the Arduino's HC-05 or HC-06 RX Pin.
  2. The Buffer Assembly: The Arduino cannot read the whole string at once; it reads one letter at a time ('T', 'u', 'r', 'n'...).
  3. You must write a while(Serial.available()) loop that stitches the individual characters into a complete C++ String object.
  4. The Critical Termination Character: The Android app must be programmed to send a \n (Newline) character at the end of the sentence. The Arduino uses if (incomingChar == '\n') as the trigger to stop listening and start processing the data!

Indexing the Execution Tree (indexOf)

Once the Arduino holds the complete string, for example message = "Turn on the bedroom fan", checking the logic requires a flexible approach.

  • You do NOT want to use if (message == "Turn on the bedroom fan"), because if the phone hears "Turn on the bedroom fan please", the exact match will fail!
  • Instead, use the forgiving .indexOf() function to search for keywords within the string.
if (message.indexOf("bedroom") >= 0 && message.indexOf("on") >= 0) {
  digitalWrite(RelayPin1, LOW); // Trigger the fan!
} else if (message.indexOf("all") >= 0 && message.indexOf("off") >= 0) {
  // Turn off every relay in the house!
}

Relaying Output Hardware

  • Arduino Uno/Mega (The Mega is advantageous due to its larger RAM, which is helpful for buffering long string variables).
  • HC-05 or HC-06 Bluetooth Transceiver Module (as shown in the image above).
  • Multiple 5V Optically Isolated Relays (Capable of routing 120V / 10A AC Mains voltage to lamps and fans).
  • An Android Mobile Phone running a generic "Bluetooth Voice Controller" app or a custom-coded MIT App Inventor interface.

ข้อมูล Frontmatter ดั้งเดิม

apps:
  - "1x Android App"
author: "abhijitbrain"
category: "Home Automation"
components:
  - "2x Relay (generic)"
  - "10x Jumper wires (generic)"
  - "1x Arduino Mega 2560"
  - "1x HC-06 Bluetooth Module"
description: "Vocal telemetry! Bypass massive API cloud servers and integrate a local, offline HC-05 Bluetooth architecture parsing speech-to-text string payloads natively from an Android smartphone to switch 120V relays."
difficulty: "Intermediate"
documentationLinks: []
downloadableFiles: []
encryptedPayload: "U2FsdGVkX1+ytmqcCts7ZDqVnrtdDyB3uDttP31jzouFqtCvd+UBm2S29FrzxFcKxT6q2iI+2kTTFxjn2Ip6BBYZHxm02g/vWvZJ5F0DG/0="
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/voice-controlled-home-automation-abd0d6_cover.png"
lang: "en"
likes: 3
passwordHash: "d9bb46a0e355551810abe1f633444155e68eeb45467791176289048162c7873a"
price: 299
seoDescription: "Build a Voice Controlled Home Automation system using Arduino MEGA and Android APP to control devices with voice commands."
tags:
  - "voice control"
  - "bluetooth"
  - "home automation"
title: "Voice Controlled Home Automation"
tools: []
videoLinks:
  - "https://www.youtube.com/embed/UDMNFxzJZ4I"
views: 30291