Adrian Chen

DIY Google Home With Raspberry Pi

Smart home devices are trending right now along with how we have improved ML and AI to help these devices to understand us better.

The one aspect of these devices I don’t particularly like, and that’s the price tag…

The Amazon’s Echo dot has the best value of just under £50. It’s bigger version Amazon Echo priced at £149.99, which is a significant jump.

Google on the other hand has the Google Home at £129, cheaper than the Amazon Echo but still a lot of money.

And let’s not forget the most over priced of them all the Apple’s HomePod (Probably the worst name ever). It’s planned to be released in December, and expected price around £350 in the UK.

With Google has recently released the Google Assistant SDK, I’ve decided to try making my own Google home installing this on a Pi, they’ve got great documentation on how to set it all up, it was very simple to do.

I’ve used what I had around the house to put it together, Here’s a video of what I end up with after getting it all setup:

A USB webcam dangling out of out of a pi is not as pretty as the google home :D

So I’ve went and bought a tiny USB microphone. I also found a Razer Mamba mouse packaging case to put the Pi in, after drilling some holes to pull the cables thru, looking much better than before:

"DIY Google Home"

I got it integrated with IFTTT, so I can turn on and off my lights in the house which was pretty fun. and they make it so easy, no coding required.

You can also use the Pi to run any custom servers or scripts such as hosting and end point for the Google Assistant to interact with. I’m currently thinking about running a cron job on my pi to play a youtube videos as an alarm, then uses Google Assistant voice commands to stop the running task. (What can go wrong!)

There are some limitation to this, not all of the google home features works with the Google Assistant SDK, it’s certainly lacking few of the major feature such as playing podcast and music playlists, and integration with chrome cast devices. These are not yet available but are planned on the roadmap.

The cost also wouldn’t be ideal if you have to buy the pi 3, the speaker, microphone, charger all together you maybe able to make it just under the Amazon Echo Dot. I wouldn’t recommend this approach unless you already have most of the parts needed.

You have any ideas or questions about Google Assistant SDK or smart homes? Drop me a comment~!

Internet of Doors - DIY Smart Doorbell

IoT, camera, doorbell, internet, of, raspberrypi, smartdoor, things

"Hacking in progress"

Last year I’ve hacked my cheap wireless doorbell I got from Argos to send a signal to my raspberry pi with a 443 receiver module, which was kindly donated to me from one of my colleague. (Thank you Csaba!! ☺️)

After a few trial and error and soldering different length and size of the coil of wire for the antenna, I manage to get the receiver to pick up the press pretty accurately.

I then used some tape and stick the raspberry pi on to the back of my front door, which conveniently has a window so… I thought why not add a pi camera that take a photo each time the doorbell was pressed~!

"Door Pi"

I’ve let it running for a while it takes some interesting photos including a big close up of my lips:

"My Face" "My Face"

I still have a problem of not able to hear the door bell, whenever I’m cooking or have headphones on, so to solve that I used the Twilio API to set up messaging to my phone when my doorbell gets pressed, it took only like 5 mins to setup and have something running and sending messages thanks to it’s easy to use and well written API documentations with handy examples on different languages. Never miss a Amazon delivery again~!!

"Thanks Twilio"

I wrote the program in Nodejs, if anyone is interested to see the code or have any questions, feel free to drop me a line in the comment or email me~!

A New Day in Unity

c#, development, game, learning

The few indie game developers forums I’ve join, whenever someone makes post on #screenshotsaturday, my first question would always be “What did you used to build this with!?”

I’ve been spamming that for the past few months, and realised that a big portion of games are built with Unity3d. so I’ve decided to give this a shot and do some learning and tutorials~!

"Unity"

Conclusion

In the past I have only tried building games with a few javascript games frameworks; impact.js, crafty.js, Phaser, etc. There’s some really positive points using unity comparing it to these js frameworks.

The one thing I love most is the ease on publishing and building your game onto different platforms, such as html5, iOS, android, windows, mac, etc. Everything is within one package. Where as I had to use 3rd party tools to help me do things like this when i have built a web canvas game and wants to publishing onto the iOS for example.

I really really like is how easy it was on building the levels and positioning things. Impact.js provided an level editor but it is still pretty clunky, with the other frameworks there’s a bit of trial and error with placing things with code. Generally overall I think I prefer building stuff with Unity than the game javascript frameworks.

Google Live Case Color - Pixel

case, google, live, phone, pixel, tech

Recently Bought a maps Live case for my google pixel from the google store. I spent some time choosing the color theme and the map location for my case. Just arrived today, the color on the case was way off, the black theme I selected was almost at a purple color, waited ages for the case to arrive as well 😩… This is what it looked like: "Google Map Live Case"

I’ve contacted the google’s team and let them know about the color issue, they say they are looking into it. Hopefully they can sort it out soon.

Raspberry Pi Torrent Box

gear, hardware, mini-project, pi, raspberry

With the new release of the Raspberry Pi 2, it reminded me of the old Raspberry Pi model B I have that’s covered in dust doing nothing. Feeling a bit sad for my Raspberry Pi I decided to turn it into something useful, a 24/7 bit torrent client. For downloading erm… all the public domain legal earth watching that I do.

The Pi’s power consumption is so low, it almost cost nothing on your electricity bill, and it’s passive cooling which means it noiseless.

I mostly followed this guide here on setting up Deluge the bit torrent client & samba share on the Raspberry Pi.

When I first tried out the guide, I had an self powered external hard drive that I plugged straight into the Pi, however when ever we try to access the files more than a minute, I would get an I/O error writing to ... then I would have to remount the drive on the pi. After trying out different combination of the format and partition of the hard disk… it turned out there was a power surge on the hard disk USB plug, when it connects to the Pi it would disrupt it’s operation.

This is my working solution:

"Setup of the Raspberry Pi torrent box using the powered usb hub and external hard drive"

I Added a powered usb hub between the Raspberry Pi and the external hard disk to make sure the hard disk is not drawing power from the Pi, and also changed the external hard disk to be one of the simple plug and play WD My Passport without any power source, this have been running smoothly without an issue so far for the past 2 months, quietly sitting on my shelf next the my router~ Hope this will help some of us who had the similar problem on external hard drive with the raspberry pi.

Quick PHP Server

gulp, impactjs, nodejs, php, workflow

I’ve been playing with ImpactJS for a while, I’ve found myself needing to run a php server to use it’s level editor Weltmister.

I didn’t want to install a full server stack solution like mamp, xampp, etc… As I already use gulp for the streaming build system. The simplest solution I’ve found is to run php and nodejs side by side. You can fire up a quick php server using it’s built-in web server:

1
2
$ cd ~/impactJs
$ php -S localhost:9090

How to Settimeout in Jasmine 2

jasmine, tdd, test, timeout

The waitsFor funciton for asynchronous specs have been removed in Jasmine 2, instead we have a done callback argument that when present, will make Jasmine consider its coresponding block as asynchronous, and waits for it to be invoked before timing out or finishing the spec, very similar to how Mocha does it’s async tests.

1
2
3
4
5
6
7
8
describe "When fetched", ->
  beforeEach: (done)->
      account.fetch
          success: ->
              done()

  it "should update its stock price", ->
      expect(account.name).toEqual("Adrian")

This is all well and good, until I ran into a problem when doing intergration test with my app that includes thrid party library that I can’t really dig into, in mycase it was the Google Maps API. To use the done syntax, you require to have an entry point of knowing when your ajax call finishes to raise the done event.

To get round this you need to use the good old setTimeout method like so:

1
2
3
4
5
6
7
8
9
10
11
12
describe "on running a search", ->
    it "returns places", (done) ->
        places = null
        $(searchBox).on "placesChanged", (e, data) ->
          places = data
          expect(places.length).toBeGreaterThan 0
          done()
        setInputVal = ->
          input.val("London")
          input.focus().simulate("keydown", { keyCode: 13 })
        # No way for us to know exactly when the Google SearchBox is ready for input ...
        setTimeout(setInputVal, 1000)

In my opinion the waitsFor function still has a place in Jasmine, the done callback syntax doesn’t completely replaces waitsFor.