Skip to content
Pavel Serikov edited this page Jan 28, 2018 · 32 revisions

Your personal CAR-JARVIS 🚗

We have:

  • Raspberry Pi 3 model 2
  • Arduino Uno
  • Tauch screen
  • USB web-camera Logitech HD WebCam C270 whith microphone
  • Micro SD card holder 16 Gb
  • Power adapter

The mobile computer can be installed and run in either automobile. It based on Raspberry Pi 3 model 2, and includes useful technologies like GSM, Internet connection and voice command block. Although the board has wi -fi, Bluetooth, HDMI screen connection. The contents of this carputer may vary by differ software.

Working stages

###Setting of operation system to Raspberry Pi We used image RASPBIAN JESSIE WITH PIXEL.

Plugging Raspberry Pi to Wi-fi access point

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Adding lines

network={
        ssid="YourSSID"
        psk="password"
        key_mgmt=WPA-PSK
}

Push the buttons Ctrl-X on clip board and don’t forget to save the changes (press Y, then Enter).

For the changes in force may reload:

sudo reboot

and then watch how the connection success:

$ ifconfig  wlan0
 
 wlan0    Link encap:Ethernet  HWaddr 7c:dd:90:04:2f:bc
          inet addr:192.168.0.14  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:9 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1866 (1.8 KiB)  TX bytes:1004 (1004.0 B)

Updating Raspberry Pi

In the beginning you must ensure you use the latest program versions. This problem is solving in two steps. First you need to update available programs list, stored locally on Raspberry Pi. This step you should make before any updates. Input the command:

sudo apt-get update

Then for packages upgrading input:

sudo apt-get upgrade

and press Y for the question Do you want to continue [Y/n]?

The microphone checking

Connect web-camera to Raspberry Pi. Check up the presence of the camera in the list of usb devices:

$ lsusb

 Bus 001 Device 005: ID 046d:c52e Logitech, Inc.
 Bus 001 Device 004: ID 046d:c52e Logitech, Inc. Webcam C720  //Our web-cam!

Check that the webcam microphone is decided as an audio device:

$cat /proc/asound/cards

 0 [ALSA    ]: BRCM bcm2835 ALSbcm2835 ALSA - bcm2835
               bcm2835 ALSA

 1 [Headset ]: USB-audio - Logitech USB Headset
               Logitech Logitech USB Hedset at usb-bcm2708_ucb-1.2.2, full speed

$cat /proc/asound/modules

 0 snd_bcm2835
 1 snd_usb_audio

Volume settings

In the terminal enter the command:

alsamixer

Following the command, a new window will open up:

alt text

Access the UI and there in you can adjust the volume (use up/down arrow keys). Press F6 to select the microphone from the list and after Press F4 to capture device. Control the recording volume by pressing the up/down arrow keys.

Voice recording test

To test the mic, we need record a sound and then play it.  Enter the following command in terminal:

arecord -D plughw:1,0 test.wav

alt text

Do our test record and it will be saved as test.wav

To play the this file, enter in the terminal:

aplay test.wav

Installing the Voice Recognition Software

Download the software from the repository Raspberry PI AUI Suite. Also you can type in terminal:

git clone https://github.com/StevenHickson/PiAUISuite

Before starting work with Raspberry PI AUI Suite we need to instal the dependencies, type in:

sudo apt-get install -y libboost-dev libboost-regex-dev youtube-dl axel curl xterm libcurl4-gnutls-dev mpg123 flac sox

After cloning repository type in to change the directory:

cd PiAUISuite/Install

Then type:

sudo ./InstallAUISuite.sh

During installation many confirmation questions will likely pop up. Read the questions clearly and press y/n to select the preferred option. Wor speech to text recognition we need voicecommand. Once the installation is complete, reboot the Pi. To check whether the application is working or not open up the terminal and type:

sudo voicecommand

After entering the command say hello to your microphone. If its working fine, text hello will be printed on the terminal.

Editing the configuration file

The voice command input is converted to text using google voice API. By configuring the application files accordingly, we can enable the Pi to act upon our voice command. In this example, we control an LED connected to Pi. It can be switched on or off as per the users voice command. For which we would need two programs, one to switch on and the other to switch off. Click here to get the details on how to blink an LED using python script. Save the programs as test12.py and test13.py. This files are presented in repository.

When we say LED ON, the test12.py program should run and the LED glows. And when we say LED OFF, the test13.py should run to switch off the LED. To do this edit the configuration file as follows. Type in:

sudo voicecommand -e 

A new screen will open as shown in figure: alt text

Press the enter key to continue and the new configuration editor file will open up. Enter the commands in the editor as shown in the figure below: alt text

LED ON will be the voice command, when we speech out the same on microphone the software will compare it with the words in the config file. If any word is matched, the corresponding action will processed. In our case, it will go to the pi directory and execute the python code test12.py. alt text

###Communication between Raspberry Pi and Arduino

Connect Arduino USB Plug to Raspberry PI with USB cable and check the connection between Arduino and Raspberry pi by type in Raspberry Pi terminal:

ls /dev/tty*

The result should be content /dev/ttyACM0.

###Arduino programming

Upload serial_test.ino code to Arduino. This file is presented in repository.

int led = 13;
void setup() {
  {
    pinMode(led, OUTPUT);

    Serial.begin(9600);
    Serial.flush();
  }
}

void loop() {
  {
    String input = "";
    while (Serial.available())
    {
      input += (char) Serial.read();
      delay(5);
    }
    if (input == "on") {
      Serial.println("on executed");
      digitalWrite(led, HIGH);
      } else if (input == "off"){
              Serial.println("off executed");
              digitalWrite(led, LOW);
            }
  }
}

##Well done!

After saying the voice command LED ON on microphone the software on Raspberry Pi will compare it with the words in the config file and run script. Script send comands to Arduino and led on!

###This way you can send any commands by adding scripts оn Raspberry Pi!