Промышленное производство
Промышленный Интернет вещей | Промышленные материалы | Техническое обслуживание и ремонт оборудования | Промышленное программирование |
home  MfgRobots >> Промышленное производство >  >> Manufacturing Technology >> Производственный процесс

Своя «Алиса»/Echo: Умная колонка на Arduino 101 и 1Sheeld с голосовым управлением

Компоненты и материалы

КомпонентКоличество
Arduino 1011
1Sheeld+ (плата + приложение)1
iPhone (в качестве «мозгов» и звука)1
PVC-труба (корпус)1
RGB LED-лента1
Блок питания 12 В1
Релейный модуль1
3× NPN-транзистора (для LED-ленты)3
Макетная плата, перемычки (30 шт), USB-кабель1 комплект

Инструменты

Приложения

О проекте

Увидел у друга Amazon Echo: музыка, свет, новости, погода, время — всё голосом. Внутри макера закричало: «Почему бы не сделать самому!». Нашёл 1Sheeld — платформу, дающую Arduino доступ к сенсорам и возможностям смартфона по Bluetooth. Плата 1Sheeld ставится на Arduino, общается с Android/iOS-приложением.

Использовано 5 щитов (shields) из 40+:

  1. Voice Recognition — управление голосом. Активация: VoiceRecognition.start();
  2. Music Player — доступ к плееру телефона. MusicPlayer.play();
  3. Text to Speech — голосовые ответы. TextToSpeech.say("time in cairo is");
  4. Clock — время телефона. Clock.queryDateAndTime();
  5. Internet — HTTP-запросы. Погода через OpenWeatherMap API: HttpRequest request1("https://api.openweathermap.org/...");
Своя «Алиса»/Echo: Умная колонка на Arduino 101 и 1Sheeld с голосовым управлением

Пошаговая сборка

  1. Компоненты — список выше (~$260 с iPhone)
  2. Корпус — просверлите отверстия в PVC-трубе для звука, покрасьте в чёрный
  3. Схемотехника:
    • LED-лента → транзисторы → блок питания
    • Лампа → реле → сеть 220 В
    • Реле и лента → Arduino 101 (пины по коду)
    • Всё монтируется внутри трубы с iPhone
  4. Библиотека 1Sheeld: Arduino IDE → Sketch → Include Library → Manage Libraries → «OneSheeld» → Install. Или скачайте ZIP с 1sheeld.com → Add .ZIP Library
  5. Приложение 1Sheeld — установите со стора
  6. Выбор щитов — в туториале 1Sheeld выберите: Voice Recognition, Text to Speech, Clock, Internet, Music Player → нажмите Multiple Shield

Код (Amazon Echo Code)

#define CUSTOM_SETTINGS
#define INCLUDE_INTERNET_SHIELD
#define INCLUDE_VOICE_RECOGNIZER_SHIELD
#define INCLUDE_TEXT_TO_SPEECH_SHIELD
#define INCLUDE_MUSIC_PLAYER_SHIELD
#define INCLUDE_CLOCK_SHIELD
#include <OneSheeld.h>

unsigned long previousMillis = 0;
bool state = 0;

// API погоды (Каир, пример)
HttpRequest request1("https://api.openweathermap.org/data/2.5/weather?q=Cairo,EG&appid=YOUR_KEY");

#define strip1 3
#define strip2 6
#define strip3 5
int lamp = 13;
int hour, minute;
char b[4], c[4];
String strh, strm, noon;

const char mainCommand[] = "alexa";
const char weatherCommand[] = "how is the weather today";
const char playCommand[] = "play music";
const char clockCommand[] = "what time is it";
const char stopCommand[] = "stop";
const char lightonCommand[] = "turn on the lights";
const char lightoffCommand[] = "turn off the lights";

void setup() {
  OneSheeld.begin();
  pinMode(strip1, OUTPUT); pinMode(strip2, OUTPUT);
  pinMode(strip3, OUTPUT); pinMode(lamp, OUTPUT);
  request1.setOnSuccess(&onSuccess1);
  request1.getResponse().setOnJsonResponse(&onJsonReply1);
  VoiceRecognition.setOnNewCommand(&myFunction);
}

void loop() {
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= 5000) {
    previousMillis = currentMillis;
    Clock.queryDateAndTime();
    VoiceRecognition.start();
  }
  hour = Clock.getHours();
  minute = Clock.getMinutes();
  if (hour > 12) { hour -= 12; noon = "P M"; } else { noon = "A M"; }
  strh = String(hour); strm = String(minute);
  strh.toCharArray(b, 4); strm.toCharArray(c, 4);
}

void myFunction(char *commandSpoken) {
  if (!strcmp(mainCommand, VoiceRecognition.getLastCommand())) { alexon(); MusicPlayer.setVolume(5); state = 1; }
  if (!strcmp(playCommand, VoiceRecognition.getLastCommand()) && state == 1) { alexoff(); MusicPlayer.play(); delay(10000); MusicPlayer.stop(); state = 0; }
  else if (!strcmp(weatherCommand, VoiceRecognition.getLastCommand()) && state == 1) { alexoff(); Internet.performGet(request1); OneSheeld.delay(5000); state = 0; }
  if (!strcmp(clockCommand, VoiceRecognition.getLastCommand()) && state == 1) { alexoff(); TextToSpeech.say("time in cairo is"); delay(1300); TextToSpeech.say(b); delay(600); TextToSpeech.say(c); delay(800); TextToSpeech.say(noon); delay(500); state = 0; }
  if (!strcmp(lightonCommand, VoiceRecognition.getLastCommand()) && state == 1) { alexoff(); digitalWrite(lamp, HIGH); TextToSpeech.say("the lights turned on"); delay(6000); state = 0; }
  else if (!strcmp(lightoffCommand, VoiceRecognition.getLastCommand()) && state == 1) { alexoff(); digitalWrite(lamp, LOW); TextToSpeech.say("the lights turned off"); delay(3000); state = 0; }
}

void onSuccess1(HttpResponse & response1) { response1["weather"][0]["main"].query(); delay(200); }
void onJsonReply1(JsonKeyChain & hell, char * output) {
  if (hell == request1.getResponse()["weather"][0]["main"]) {
    TextToSpeech.say("the weather today in cairo is"); delay(2000);
    TextToSpeech.say(output);
  }
}
void alexon() { digitalWrite(strip1, HIGH); delay(200); digitalWrite(strip2, HIGH); delay(200); digitalWrite(strip3, HIGH); }
void alexoff() { digitalWrite(strip1, LOW); digitalWrite(strip2, LOW); digitalWrite(strip3, LOW); }

Схема

Своя «Алиса»/Echo: Умная колонка на Arduino 101 и 1Sheeld с голосовым управлением

Производственный процесс

  1. Передача данных температуры и влажности между двумя Arduino через Firebase
  2. Цифровые кости на Arduino: генератор случайных чисел с LCD-дисплеем и кнопкой
  3. Универсальный Android-пульт на Arduino, 1Sheeld и ИК-управлении
  4. DIY USB-геймпад на Arduino: собственный высокопроизводительный контроллер
  5. Измерение расстояния в реальном времени: Ардуино-сонар с визуализацией в Processing
  6. Pixel Chaser: игра на один тап с NeoPixel Ring и Arduino Nano
  7. Бесшовное управление яркостью светодиодов с помощью Bolt IoT и Arduino UNO
  8. Умная робо-рука на Arduino: простое DIY-руководство
  9. Автономный танк с доставкой пива: Walabot, Arduino, Raspberry Pi и Alexa
  10. Сборка компактного FM-радио на Arduino Nano и RDA5807M