Raspberry Pi Google Assistant With Sleek Wood Box

56,371

444

76

Introduction: Raspberry Pi Google Assistant With Sleek Wood Box

About: Instructable about how I make things that appear in my videos. Check out my youtube channel about making and hand tool woodworking. https://www.youtube.com/user/andii1701/videos

In this instructable I’ll show how to build a DIY Google AI Assistant using a Raspberry Pi, USB Speaker and USB microphone. I’ll also show how to make the sleek hardwood box it’s housed in.

I’m assuming a basic knowledge of the linux operation system, raspberry pi and unix command line. If your new to raspberry pi there are plenty of good getting started tutorials here https://www.raspberrypi.org/help/ and on instructables (:

If your not interested in woodworking. You can easily substitute the wooden box for something simpler, like a cardboard box or a plastic project box.

Hardware used:

Materials needed for the box:

  • 10mm aluminum tube
  • Tasmanian oak was used for the wood. Each board measured 24x9x1.2cm
  • Wood finishing oil, I used Danish oil.
  • 2mm wood screws
  • 30mm wood screws

Tools used:

  • soldering iron
  • tenon saw
  • hand router
  • bench chisel and mallet
  • sand paper
  • drill press
  • electronics perfboard was used as a template for the speaker holes
  • hacksaw
  • flat file

Step 1: Watch the Build Video

Watch this build video to get an idea on what is involved. If you like my video please, like it, leave a comment and subscribe to my channel (: https://www.youtube.com/user/andii1701

Step 2: Setup the Raspberry Pi

Connect the pi to a keyboard, monitor and mouse. Boot it up. Now configure network and ssh access. There is a good guide here: https://developers.google.com/assistant/sdk/develop/python/hardware/setup

Note Raspberry PI's do not have real time clocks so you will need to either setup NTP or manually set the time with the command:

$ date -s '2014-12-25 12:34:56'

not doing so can cause SSL errors later.

Once network is setup update you pi’s operating system by following this guide: https://www.raspberrypi.org/documentation/raspbian/updating.md

(Optional) Compile python3.6 on the raspberry pi

The default python3 install on the raspberry pi is python3.4, I wanted a more modern python, so I downloaded and compiled python3.6 from source http://bohdan-danishevsky.blogspot.com.au/2017/01/building-python-360-on-raspberry-pi-3.html

Step 3: Configure Google Cloud

The google assistant SDK needs to talk to it's API in google cloud. This process involves creating a google cloud project, enabling the assistant API, generating a client secret and downloading that secret json blob to the pi. There are detailed instructions here: https://developers.google.com/assistant/sdk/develop/python/config-dev-project-and-account

Step 4: Configuring the Assistant Python Software on the Pi.

If you just want a bear bones google assistant running on follow this guide: https://developers.google.com/assistant/sdk/develop/python/run-sample.

However if you want to add a LED or extend it in other ways git clone this library and follow the instructions to get it running:

$ git clone https://github.com/googlesamples/assistant-sdk-py...
$ cp -r assistant-sdk-python/google-assistant-sdk/googlesamples/assistant/library new-project

$ cd new-project

[Follow the instructions in README.rst to get it going]

You should now have a working Google assistant running on the Pi.

Step 5: Getting the Assistant to Turn on the LED

Solder the 330ohm resistor to the negative terminal of the LED and wire it up according to the above diagram. I used PIN3 for ground and PIN18 for positive.

Python has an excellent library for controlling GPIO pins called Rpi.GPIO. Install this library into your virtual env:

$ pip install RPi.GPIO

Before messing around with the assistant's code, I'd suggest following this guide to make sure the LED works first:

https://thepihut.com/blogs/raspberry-pi-tutorials/...

Adding GPIO code to the google assistant was quite straight forward. Download the attached patch and apply it with:

$ patch -p0 < hotword.py.patch

If the patch applied correctly the LED should turn on after "OK Google" and turn off after the assistant finishes.

Step 6: Building the Box

Now the google assistant and LED are working you can now make the box.

I sawed the timber to length 24cm and planed down the ends to match each other. Using a marking gauge I marked a rectangle on the inner face of each board that was 1/4” in from each side. I then chiseled and hand routed out this area to a depth of about 6mm. I place the pi between the boards regularly to check the gap distance. If you don't have a hand router, you could use an electric router or make a simple one.

Note I should have left raised platforms in the corners of the trench for the aluminum spacers to sit on. The wood screws had very little wood on the front board to bite into. It was enough, just!

This is not shown on the video. On the back board I cut out a deeper area around the PI’s USB ports. This extra trench depth came to about 9mm. This allowed the boards to end up closer together, providing a more sleek look.

Step 7: Drill Speaker Holes

Using a speaker as a size guide, I masked out an area of holes on an electronics perfboard with tape. I then used this perfboard as a drill template by taping it to the board. Make there is enough room at the back to place the pi and two speakers. I’d do a mock electronics layout first.

Using a 1mm drill bit carefully drill out the speaker grill. (This will take some time :)

Step 8: Layout Electronics

Layout all electronics. Drill pilot holes for the Pi and screw it in place using the 2mm wood screws. Place the speakers over the grills and figure out how long the USB cord needs to be. A long usb cord will not fit in the box. Cut the cord to length and re-solder it to the usb controller. Everything can now be connected and placed. Hot glue the speakers in place. I placed the USB controller board under it’s usb cables near the Pi’s USB hub. I also used a bit of electrical to cover it so no shorts occur.

Drill a 3mm hole for the LED. Place it in the hole and wire it up. Note I had to cut 2mm off each black pin connector on the breadboard wires so they will fit in the box. Cover the exposed wires and resistor with electrical tape to prevent shorts.

Step 9: Make Aluminium Spacers and Finishing the Box

Using 10mm aluminium tube, I cut the spacers to length 23mm with the hack saw (same height as the Pi). Then cleaned up the cuts with the flat file. Place the spacers in the corners and put the back board in place, make sure you are happy with how wide the gap is.

Using the spacers as a guide mark a drill hole at the centre of each spacer. In the back piece drill pilot holes for the case screws. Do a mock assembly and secure it together with tape. Using the depth guide on the drill press, drill shallow pilot holes on the front board by drilling though the back board pilot holes. BE VERY CAREFUL not to drill through the front board!

Counter sink the back drill holes with a counter sink bit.

You can now screw together the box. Be careful to choose the correct length wood screws. I got lucky, the 30mm wood screws were just long enough. It might be worth taking the box to the hardware store so you can find the correct screws.

Finishing the box

I sanded the box smooth and used a camera dust remover to blow out the dust from the speaker grill and electronics. I finished the box with danish oil, carefully dabbing it on around the speaker grill so the holes to do not get clogged.

Congratulations your done! BTW google assistant have tonnes of easter eggs you can discover (:

Step 10: Extending the Google Assistant

Extending the assistant is an instructable in itself. So I'm not going to cover it in detail here. But I'll point you in right direction. The simplest way to extend the assistant is to write apps in the ittt.com (If this then that) service. ittt.com is a online service you can create simple web apps that automatically perform various tasks. The google assistant can be wired up to this service.

Another way to extend the assistant is by extending the python client. I did not look into this in detail but this link is worth looking at: https://developers.google.com/assistant/sdk/develop/python/next-steps

Step 11: Conclusion

Thanks for reading the instructable, hope you enjoyed it. If you have not done so watch the build video above (: Please subscribe to my channel if you like it.

Me:

twitter: @andii1701

instagram: @andrew_r_jones

youtube: @andii1701

Box Contest 2017

Participated in the
Box Contest 2017

1 Person Made This Project!

Recommendations

  • Make It Bridge

    Make It Bridge
  • For the Home Contest

    For the Home Contest
  • Game Design: Student Design Challenge

    Game Design: Student Design Challenge

76 Comments

0
gamerabbit16
gamerabbit16

Question 1 year ago

Hello Andi,
can I use raspberry zero 2 for the project?

0
gamerabbit16
gamerabbit16

Reply 2 years ago

with a raspberry pi

0
DanielA546
DanielA546

Question 4 years ago on Step 3

Great project but I might be stuck! I have my RPI3 updated and I am on step 3 (google cloud) specifically running the following command to get the json on my device.

scp ~/Downloads/credentials.json <username>@<device-ip-address>:</path/to/assistant-sdk/project>

password: password-for-device

what is the path I use? a completed example with pi@ip and path would be awesome!

0
Dman4djob
Dman4djob

Answer 4 years ago

You want to place the file in /home/pi/

No one can give you the exact code to put in because it is related to the ip address of your raspberry pi as well as its individual password. To find out your associated ip address run the following command... sudo ifconfig your ip address will be on the line titled "inet addr"

Your password if unchanged from factor settings should be... raspberry

Hope this helps you out.

0
strawberryp
strawberryp

Question 4 years ago

how did you get the microphone and speaker working at the same time

0
Dosselini
Dosselini

5 years ago

Hi Andii,

Well played on this tutorial, I found it very easy to follow and I've got it working nicely on a RasPi 3. However, like cyberwolves I seem to have a problem getting the LED to light. I've uploaded the hotword.py file. I know the LED itself works because I can light it with a separate script (also attached). Interestingly the print command "LED on" doesn't seem to appear in the console either. Any suggestions? Many thanks

0
andii
andii

Reply 5 years ago

Your hotword.py file looks good. How are you running the assistant?

0
Dosselini
Dosselini

Reply 5 years ago

Thanks for taking the time to reply Andyii. I run:

$ source /home/pi/R200/env/bin/activate
(env) $ google-assistant-demo

R200 is the name of my project

0
andii
andii

Reply 5 years ago

You need to run the hotword.py directly:

$ cd /home/pi/R200

$ source /home/pi/R200/env/bin/activate

$ python hotword.py

0
MohamedS522
MohamedS522

Reply 4 years ago

Hi andii, stil me too stuck on this step, I couldn't use the patch file can I got this error "python: can't open file 'hotword.py': [Errno 2] No such file or directory"

0
Dosselini
Dosselini

Reply 5 years ago

That's cracked it.

Thank you for your help Andii. I figure if there's an indicator of a quality Instructable it's the willingness to follow up and help out. Top marks.

0
JuanR286
JuanR286

5 years ago

Hi! Awesome tutorial, i want to know if this raspi Google home works with Google play music. Thanks

0
twestheimer
twestheimer

5 years ago

do you need to register every time you run the sample? I ran the code last night and it had an error but did "run" now this morning the device is not showing?

0
matthieupro2
matthieupro2

5 years ago

when i type "python3 -m venv env it does not procced

0
andii
andii

Reply 5 years ago

Can you post the error message.

0
twestheimer
twestheimer

5 years ago

since the USB speakers are back ordered could the project be modified to use Bluetooth speakers?

0
andii
andii

Reply 5 years ago

Yes