Introduction: Raspberry Pi Google Assistant With Sleek Wood Box

Picture of Raspberry Pi Google Assistant With Sleek Wood Box

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

Picture of 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

Picture of 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

Picture of 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

Picture of 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

Picture of 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

Picture of 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

Picture of 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

Picture of 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

Comments

twestheimer (author)2017-12-14

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

andii (author)twestheimer2017-12-14

Yes

Wim3d (author)2017-11-16

Great video. I will try to make this to use my Pi as Google assistant. Do you think a Pi zero W will work?

What about a regular speaker with a 3.5 mm connector? Will that work instead of the USB speaker?

andii (author)Wim3d2017-11-17

Thanks! Be sure to subscribe (:

Raspberry pi zero W should work, might be a bit slower. regular speaker with 3.5mm jack will be fine.

twestheimer (author)andii2017-12-14

why was a USB speaker used if a regular speaker hooked to the 3.5 mm would work???

andii (author)twestheimer2017-12-14

The 3.5mm jack is on the side of the pi, so the enclosure would have needed to be bigger to house it.

sebastiankdp (author)2017-10-04

I followed all steps of the README.txt, but when i try to run "python hotword.py", I get the following error: "usage: hotword.py [-h] [--credentials OAUTH2_CREDENTIALS_FILE]

hotword.py: error argument -- credentials: No such file or directory: "/home/pi/.config/google-oauthlib-tool/credentials.json""

I dont exactly know what I did wrong or what thats supposed to mean, and am grateful for any help.

andii (author)sebastiankdp2017-10-05

Hi, you need to follow the google assistant cloud setup instructions here:

https://developers.google.com/assistant/sdk/develo...

Once you have the credentials.json file copy it to the pi and run: hotword.py --credentials <path-to-credemtials.json>

Dosselini (author)2017-09-23

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

andii (author)Dosselini2017-09-24

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

Dosselini (author)andii2017-09-26

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

andii (author)Dosselini2017-09-26

You need to run the hotword.py directly:

$ cd /home/pi/R200

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

$ python hotword.py

Dosselini (author)andii2017-09-27

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.

cyberwolves (author)2017-09-21

Hi andil i did not get this line :

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

$ patch -p0 < hotword.py.patch

Download and copy to which folder ?

andii (author)cyberwolves2017-09-22

Same folder where you cloned the git repo to.

cyberwolves (author)andii2017-09-22

please reply soon tell me in which folder should i copy the downloaded patch

andii (author)cyberwolves2017-09-22

$ 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

$ patch -p0 < hotword.py.patch

cyberwolves (author)andii2017-09-22

Finally i patched everything, but the led's are still not working...

im using AIY Projects

But when i tried this one below like you asked it works

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/...

please HELP me getting the led turn on

andii (author)cyberwolves2017-09-22

Double check the GPIO pin number is the same you are using in the hotword.py file. Also try using print statements in hotword.py to make sure the part with the GPIO calls are being called. If that does not work post your hotword.py post patched file and I'll take a look.

KriyenKP (author)2017-09-04

Can I substitute the usb microphone for the electret mic?
https://www.adafruit.com/product/1713

andii (author)KriyenKP2017-09-04

Don't know. If it works with the raspberrypi it should be fine.

lgilber (author)2017-08-31

The raspberry Pi portion of this instructable is a fine example of how NOT to write an instructable. Vague and nebulous. I got it to work, but I'm an electrical engineer, work in IT and am experienced with Rapsberry Pi.

GarrettG2 (author)2017-08-22

how do i make the script auto run when i boot the pi without a key board and mouse. I used the basic installtion based off of what google provided

andii (author)GarrettG22017-08-23

Have yet to do this. Take a look at this instructable: https://www.instructables.com/id/Raspberry-Pi-Launch-Python-script-on-startup/

QuinnF5 (author)2017-08-21

I'm making something similar, but using a adafruit trinket and neopixel ring of 12 leds too. When the assistant pulls the led pin high, the trinket will cue the neopixel animation when required. Thank you for making this tutorial and the awesome youtube video too!

andii (author)QuinnF52017-08-22

Cheers! The LED ring idea sounds awesome!

JonasMPowell (author)2017-08-19

Excellent tutorial. I'm about to start making this project but, with the speakers you linked out of stock, am unclear on what kind of speakers will work. I'm very new to RPi's and don't fully understand HATs and such yet, which most other RPi speakers seem to need. Could you go into a little more detail on speaker selection? Thanks!

andii (author)JonasMPowell2017-08-20

Thanks! You don't need to use use pi hats. Any small USB speaker should work. Try something like this https://www.sgbotic.com/index.php?dispatch=products.view&product_id=2444 or similar (:

varun ronaldo (author)2017-08-16

Can I use any other box for this project

andii (author)varun ronaldo2017-08-16

Sure can, you can even have no box (:

varun ronaldo (author)2017-08-16

Super project

andii (author)varun ronaldo2017-08-16

Thanks!

absinth4. (author)2017-08-15

Great project! If i skip the step with the led part, will it still be working ???

andii (author)absinth4.2017-08-15

Sure will. Just will be a little harder to tell when it's activated.

tinaciousz (author)2017-08-14

Can I ask it to set reminders for me? I want one of these in my kitchen!

andii (author)tinaciousz2017-08-14

Hi yes, it can set reminders and alarms (:

rene6 (author)2017-08-10

Hello Andii, great project! In step 8 you're describing the USB controller board. Can you tell me what hardware that is and how you connected it to the Pi.

Thanks,

René

andii (author)rene62017-08-11

Thanks! The USB controller was part of the off the shelf USB speaker I used. When breaking the speaker case I broke some of its internal wires. So I had to re-solder them back to it's original PCB.

rene6 (author)andii2017-08-11

Ok thanks, so when I use the speaker in your hardwarelist I just connect it to one of the pi's usb ports and the microphone to the other I assume. What is the maximum distance so that the microphone still reacts to your voice?

andii (author)rene62017-08-12

Yesm USB speaker an mic plug still plug in via USB. Not sure of maximum distance of the mic, but works fine when saying "OK google"anywhere in our open plan living room.

rene6 (author)andii2017-08-12

Thanks. Hope to build one in the comming months. I will place the result here.

mlowinske (author)2017-08-10

What was the overall cost of this and about how long did it take, but not including the wooden casing?

andii (author)mlowinske2017-08-10

Total cost including pi, official sdcard, usb mouse, usb speaker and official powersupply was $120AUD. You can probally get it cheaper as everying is more expensive in Australia.

Strato_caster (author)2017-08-09

Great project! I have an old Raspberry Pi 2 laying around. Is there any reason I couldn't use it for this project?

andii (author)Strato_caster2017-08-09

Thanks! Don't see why not, it might run a bit slower.

HerrRouge (author)2017-08-07

I just love the video of the process! ^_^

andii (author)HerrRouge2017-08-07

Happy you liked the video. Be sure to subscribe to my channel (:

HerrRouge (author)andii2017-08-08

Already did :)

fourbyfour4 (author)2017-08-07

I don't understand how to add GPIO code to the google assistant. patch -p0 hotword.py.patch does not do anything. Can anyone help me understand what I'm doing wrong. I downloaded hotword.py.patch to the download folder. Maybe I need to move it?

andii (author)fourbyfour42017-08-07

Sorry the correct command is:

$ patch -p0 < hotword.py.patch

About This Instructable

30,830views

364favorites

License:

Bio: 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 ...
More by andii:Raspberry Pi Google Assistant With Sleek Wood Box Building and Testing a Budget 3D Printer KitHow to CNC Without a CNC
Add instructable to: