Google Assistant Using Raspberry Pi and Bluetooth Speaker

by Apr 14, 2020Raspberry Pi projects

This tutorial is going to show how to set up Google Assistant using a Raspberry Pi 4 and Bluetooth Speaker.

I] Parts Required:

  • 1x Raspberry Pi ( I have used Raspberry Pi 4 Model B)
  • 1x Bluetooth Speaker
  • 1x USB Microphone ( You can try using a Bluetooth headset with a mic)
  • 1x 8GB or above MicroSD card
  • 1x 5V USB power adapter
  • 1x USB type C power cable (Raspberry Pi 4 uses type C, lower versions use micro USB)
  • 1x Ethernet Cable

The above parts are sufficient for using the Raspberry Pi with a laptop.

If you have a HDMI Monitor, USB keyboard and mouse, you can use that as well. Basic setup instructions can be found on the official website -(https://projects.raspberrypi.org/en/projects/raspberry-pi-setting-up)


II] Setup the SD card: 

Start with a fresh version of the Raspberry Pi Operating System. The latest version at the time of writing this article is the Raspbian Buster OS.

  • Install the latest version here – Download
  • Install Balena Etcher to flash the OS onto the SD card (BalenaEtcher )
  • Eject the Sd card once you flash the downloaded OS image.

III] Set up your Pi

Insert the flashed SD card into the Pi.  Use the 5V USB power cable to power up the Pi and connect it to your laptop using the ethernet cable. 
Install Putty ( free SSH client) – Putty                                                                                                  Open Putty and type the IP address of your Pi. Alternatively, typing raspberrypi.local should also work. 

The default username is pi and the password is raspberry.                                                      In the first SSH session, type   sudo raspi-config    to change your Pi’s password. 

To use the Graphical interface, install the remote desktop client.                                      sudo apt-get install xrdp

Open Remote Desktop Connection in your Windows. Type your Pi’s IP address and login. You should see the graphical interface. 

Raspberry Pi Graphical Interface

IV] Disable HDMI and Analog Audio

Start a terminal using Ctrl+Alt+T and edit boot/config.txt

sudo nano /boot/config.txt

Disable both HDMI and analog audio by placing ‘#’ in front of:

#dtparam=audio=on

Reboot the Pi using      sudo reboot


V] Connect Bluetooth Speaker

  • Click on the Bluetooth icon on the top right of the screen to pair the Bluetooth speaker. 
  • If the above method does not work, open a terminal and type  bluetoothctl
  • Type connect xx:xx:xx:xx:xx:xx(xx:xx:xx:xx:xx:xx is the MAC address of your Bluetooth speaker)
  • Click on the Bluetooth icon again and you will see the Bluetooth speaker has a green tick in front of its name. 
Bluetooth Connections

VI] USB Microphone 

  • Connect the USB microphone to one of the Pi’s USB ports. 
  • arecord -l   should list the microphone.
  • In case a Bluetooth headset with mic is used as the input for the Google Assistant, follow the above steps used to connect the Bluetooth speaker.

VII] Change the .asoundrc configuration file

Once the Bluetooth speaker and the USB Microphone/Bluetooth Headset is connected, a .asoundrc will be generated which will look like the following:

pcm.!default {
type plug
slave.pcm {
type bluealsa device "xx:xx:xx:xx:xx"
profile "a2dp"
}
}
ctl.!default {
type bluealsa
}

Type       sudo nano \.asoundrc             to edit the above file. Change the file to the following:

pcm.!default {
type asym
capture.pcm "mic"
playback.pcm "speaker"
}
pcm.mic {
type plug slave { pcm "hw:1,0" }
}
pcm.speaker {
type plug
slave.pcm {
type bluealsa device "xx:xx:xx:xx:xx"
profile "a2dp"
}
}

hw:1,0 stands for the card and device number which can be found from arecord -l.

In case a Bluetooth headset is being used as the microphone, paste the same content from pcm.speaker into pcm.mic and change the MAC address to that of the headset and change the profile to “sco”. 

Save a copy of the .asoundrc file to the following:                                                                  sudo cp ~/.asoundrc /etc/asound.conf


VIII] Installing the Google Assistant SDK:

Install the Google Assistant software by following all the instructions in the link below: Link

Once the above action is completed, type the following in a terminal:

source env/bin/activate                                                                                                                      googlesamples-assistant-pushtotalk –project-id my-dev-project –device-model-id my-model

Replace my-dev-project with the project id from the project settings and my-model with the model id from the credentials screen from the Google Actions Console.


IX] Completion:

Once all the above steps have been followed, your Google Assistant should be up and running. You can try asking a variety of questions and listen to the answers. 

Google Assistant running on Raspberry Pi

Creating a multiplication Skill in Alexa using python

Written By Monisha Macharla

Hi, I'm Monisha. I am a tech blogger and a hobbyist. I am eager to learn and explore tech related stuff! also, I wanted to deliver you the same as much as the simpler way with more informative content. I generally appreciate learning by doing, rather than only learning. Thank you for reading my blog! Happy learning!

RELATED POSTS

Magic Wand using Raspberry Pi and OpenCV

Magic Wand using Raspberry Pi and OpenCV

What if I could do things with a swing of a wand? Practically impossible but with technology maybe not. In this tutorial, we will use a raspberry pi and OpenCV to try and recreate something similar to a wand. It will perform specific functions when it recognizes...

IBM Watson IoT Platform with Raspberry Pi

IBM Watson IoT Platform with Raspberry Pi

IBM Watson is one of the leading cloud computing platforms there is. It has almost all the features one could expect from a modern-day cloud platform, from machine learning support to IoT, even till edge computing. In this tutorial, we will use raspberry pi and an...

Home Automation With Telegram and Raspberry Pi

Home Automation With Telegram and Raspberry Pi

In this Article we will see how we can use Telegram for Home Automation. Telegram is an extremely popular multi-platform messaging service. Just like any other messaging platform, it is used to send messages and exchange photos, videos, stickers, audio, and files of...

Home Automation System with Raspberry Pi and Flask

Home Automation systems are becoming increasingly popular for the level of convenience they offer. Imagine sitting on your couch and turning on/off lights or fans in the room without having to get up. You could also control blinds or even door locks. This project is a...

Smart Alarm Clock with Raspberry Pi

Smart Alarm Clock with Raspberry Pi

Smart Alarms are very common today yet the good ones expensive. What if you wanted to make a smart alarm clock on your own using as little hardware and cost as possible? You may ask isn't the RPI costly, yes it is but, the only purpose of using an RPI is easy to net...

VIDEOS – FOLLOW US ON YOUTUBE

EXPLORE OUR IOT PROJECTS

IoT Smart Gardening System – ESP8266, MQTT, Adafruit IO

Gardening is always a very calming pastime. However, our gardens' plants may not always receive the care they require due to our active lifestyles. What if we could remotely keep an eye on their health and provide them with the attention they require? In this article,...

How to Simulate IoT projects using Cisco Packet Tracer

In this tutorial, let's learn how to simulate the IoT project using the Cisco packet tracer. As an example, we shall build a simple Home Automation project to control and monitor devices. Introduction Firstly, let's quickly look at the overview of the software. Packet...

All you need to know about integrating NodeMCU with Ubidots over MQTT

In this tutorial, let's discuss Integrating NodeMCU and Ubidots IoT platform. As an illustration, we shall interface the DHT11 sensor to monitor temperature and Humidity. Additionally, an led bulb is controlled using the dashboard. Besides, the implementation will be...

All you need to know about integrating NodeMCU with Ubidots over Https

In this tutorial, let's discuss Integrating NodeMCU and Ubidots IoT platform. As an illustration, we shall interface the DHT11 sensor to monitor temperature and Humidity. Additionally, an led bulb is controlled using the dashboard. Besides, the implementation will be...

How to design a Wireless Blind Stick using nRF24L01 Module?

Introduction Let's learn to design a low-cost wireless blind stick using the nRF24L01 transceiver module. So the complete project is divided into the transmitter part and receiver part. Thus, the Transmitter part consists of an Arduino Nano microcontroller, ultrasonic...

Sending Temperature data to ThingSpeak Cloud and Visualize

In this article, we are going to learn “How to send temperature data to ThingSpeak Cloud?”. We can then visualize the temperature data uploaded to ThingSpeak Cloud anywhere in the world. But "What is ThingSpeak?” ThingSpeak is an open-source IoT platform that allows...

Amaze your friend with latest tricks of Raspberry Pi and Firebase

Introduction to our Raspberry Pi and Firebase trick Let me introduce you to the latest trick of Raspberry Pi and Firebase we'll be using to fool them. It begins with a small circuit to connect a temperature sensor and an Infrared sensor with Raspberry Pi. The circuit...

How to implement Machine Learning on IoT based Data?

Introduction The industrial scope for the convergence of the Internet of Things(IoT) and Machine learning(ML) is wide and informative. IoT renders an enormous amount of data from various sensors. On the other hand, ML opens up insight hidden in the acquired data....

Smart Display Board based on IoT and Google Firebase

Introduction In this tutorial, we are going to build a Smart Display Board based on IoT and Google Firebase by using NodeMCU8266 (or you can even use NodeMCU32) and LCD. Generally, in shops, hotels, offices, railway stations, notice/ display boards are used. They are...

Smart Gardening System – GO GREEN Project

Automation of farm activities can transform agricultural domain from being manual into a dynamic field to yield higher production with less human intervention. The project Green is developed to manage farms using modern information and communication technologies....