Internet, Voice and iOS control for my garage door opener using AWS Lambda, Amazon Echo, and Particle Photon.
There are 3 parts to this project. Number 1 is the hardware and firmware required to interface with the garage controller.
Obviously this is required to make it work. Number 2 and 3 are different ways to control that hardware, and can be
used independently. The iOS app is not dependent on the Alexa Skill, neither is the Alexa Skill dependent on the iOS app.
They both use the same method of triggering the hardware/firmware - the Particle Cloud API. The firmware on the photon exposes
a cloud function - garage
. In order to run the code in this function, you can send the corresponding REST API call as outlined
in the Particle Docs to hit this custom API endpoint and trigger our custom garage
function exposed in the firmware. This then will electronically close the switch contacts of the garage door button - Opening and
closing it.
-
Photon Firmware - Written in C and uploaded to the photon using Particle Dev or Particle Build.
-
Alexa Skill - Written in Node.js (version 4.3) and hosted as a function on AWS Lambda.
-
iOS Application - Very basic iOS app with 1 button that will trigger the door. Written in Swift and installed on your iOS device.
Interaction with Alexa can be made with the following commands:
Help
"Alexa, ask garage for help"
Open the garage door
"Alexa, tell garage door to open."
Close the garage door
"Alexa, tell garage door to close."
- Go to the AWS Console and click on the Lambda link. Note: ensure you are in us-east (N. Virginia) or you won't be able to use Alexa with Lambda.
- Click on the Create a Lambda Function or Get Started Now button.
- Under 'Select Blueprint', click 'Skip'.
- Name the Lambda Function
Garage
. - Select runtime of
Node.js 4.3
- Go to the the src directory, select all files and then create a zip file, make sure the zip file does not contain the src directory itself, otherwise Lambda function will not work.
- Upload the .zip file to the Lambda.
- Keep the Handler as index.handler (this refers to the main js file in the zip).
- Create a basic execution role and click 'Allow'. Click 'Next', then 'Create function'.
- Return to the main Lambda page, and click on 'Event sources' -> 'Add event source'.
- Choose Alexa Skills Kit and click 'Submit'.
- Click on your Lambda function name and copy the ARN to be used later in the Alexa Skill Setup.
- Go to the Amazon Developer Console, click 'Get Started' under Alexa Skills Kit, then click 'Add a New Skill'.
- Fill in
Garage
as 'Name', andgarage
as 'Invocation Name', this is the word you will say to activate the particle function, and the following spoken arguments will determine which command is triggered. - Select the Lambda ARN for the skill Endpoint and paste the ARN copied from above. Click Next.
- Copy the Intent Schema from the included IntentSchema.json.
- Copy the Sample Utterances from the included SampleUtterances.txt. Click Next.
- Under "Endpoint", paste in the ARN you copied from the last step of the Lambda setup and click the 'Lambda ARN' radio button. Click 'Next'.
- [Optional] go back to the skill Information tab and copy the
Application Id
. Paste the appId into theindex.js
file for the variableAPP_ID
, then update the lambda source zip file with this change and upload to lambda again, this step makes sure the lambda function only serves request from authorized source. - You are now able to start testing your sample skill! You should be able to go to the Echo webpage and see your skill enabled.
- In order to test it, try to say some of the Sample Utterances from the Examples section below.
- Your skill is now saved and once you are finished testing you can continue to publish your skill.
[WIP]
[WIP]
- Particle Photon (x1)
- Optocoupler (x1)
- 220 ohm resistor (x1)
- [Optional] Sparkfun Protoshield (x1)
- [Optional] Voltage regulator (x1, 5V, if powering photon from VIN pin)