Close
0%
0%

Talking Home (Powered by Alexa & Cypress PSoC 6)

Alexa & Cypress PSoC® 6 Microcontrollers (MCU) based home monitoring and control system. Just ask Alexa!!!

Similar projects worth following
I want to build a home automation and monitoring system using Cypress PSoC® 6 WiFi-BT Pioneer Kit (CY8CKIT-062-WIFI-BT). I will interface some external sensors (temperature, humidity, air quality, light intensity and pressure) with the PSoC MCU. I will also connect the Pioneer Kit with my planter using Bluetooth to collect the soil moisture data from the planter. Using the built-in wifi of the Pioneer Kit all the sensor data will be uploaded to AWS DynamoDB. The data from the DynamoDB table will be read from an AWS Lambda function. I will create a custom Alexa Skill to invoke the lambda function. When a user will ask about any parameter of his room or house the Alexa skill will invoke the lambda function to read the sensor data from DynamoDB table. After getting the data Alexa will deliver it to the user. Base on the sensor data user can also ask Alexa to control any device such as the water pump for the planter when moisture is low. For controlling the device AWS IoT will be used

In this project I will show you how you can control your home appliances using Alexa voice command. PSoC 6 WiFi-BT Pioneer Kit (CY8CKIT-062-WiFi-BT) will be used as the main controller of the project. A custom Alexa Skill will be developed for controlling the devices. Amazon AWS IoT Core will be used to send voice command from Alexa to PSoC 6. AWS Lambda will help to send MQTT message to AWS IoT Core. PSoC 6 Pioneer Kit will subscribes to a specific MQTT topic generated from AWS IoT and control a relay board according to the received message. 

Software/Services used in the Project

AWS Services

    1. Internet of Things Service (AWS IoT Core)

   2. Security, Identity, & Compliance service (IAM)

   3. Compute Service (Lambda)

   4. Alexa Skill

Arm Mbed CLI

aws_config.h

Configuration for AWS IoT

h - 5.07 kB - 08/23/2020 at 06:15

Download

subscriber.cpp

The source file for PSoC 6 kit. MQTT protocol is implemented and subscribes to AWS IoT Core.

cpp - 7.63 kB - 08/22/2020 at 08:42

Download

index.js

This file is for Lambda. Upload it to AWS Lambda after replacing the endpoint with your own.

javascript - 5.60 kB - 08/20/2020 at 05:07

Download

intents.json

JSON file for Alexa Skill. You can directly upload this file for the Alexa Skill.

JavaScript Object Notation (JSON) - 2.58 kB - 08/19/2020 at 17:41

Download

  • 1 × PSoC 6 WiFi-BT Pioneer Kit The PSoC 6 WiFi-BT Pioneer Kit has been designed for users to develop next-generation Internet of Things (IoT) applications. It comes with the PSoC 62 MCU, which provides IoT developers with an ultra-low power, flexible and secure MCU architecture. User's can choose from the various combinations of power, performance and peripherals provided by the PSoC 62 MCU architecture, to enable features such as extended battery life, small form factors, and security for connected devices. This kit also comes with a Murata LBEE5KL1DX Module (based on the CYW4343W), which provides robust and reliable Wi-Fi AND Bluetooth connectivity in one chip. The PSoC 6 WiFi-BT Pioneer Kit provides Arduino™ UNO V3 and Digilent Pmod™ compatible headers, enabling plug and play of various shield boards to broaden the user's development scope. It comes with an on-board debugger/programmer (KitProg) to easily debug and program the target device. In addition, software libraries and code examples are provided to help user's along with their development process.
  • 1 × 4 Channel 5V Relay Module Relay module is required for driving AC device using microcontroller.
  • 1 × Amazon ECHO Device

  • Testing

    Md. Khairul Alam08/23/2020 at 06:19 0 comments

    After compiling and transferring the .hex file to the PSoC 6 board, I connected the board with PuTTY (the baud rate is 115200) for debugging. If everything goes perfect you will get the following response on PuTTY terminal

    On message receive from AWS IoT the following output was shown in PuTTY terminal. It is a indication that everything is working perfectly.

    Now, it is the right time to connect the relay board to the PSoC board. I used male to female jumper wire for the job. Here is the connection

    No power is provided in the board at this moment. 

    Lets, provide the power in the board. After powering the all the device is off. So all the relay LED is glowing.

    When it receives Kitchen light on and bedroom light on command from the Alexa then corresponding two relays turn on. 

View project log

  • 1
    Building Custom Alexa Skill

    For working with amazon services you will need to have an account for AWS cloud. I am assuming you have already an account.

    1. Login Amazon developer account and navigate to Alexa developer console.

    2. Click on Create skill.

    3. Enter a name for the skill and leave the rest at default as shown in following Figure. (Ensure default language is English (US). Default settings allows us to create a custom skill and use our own AWS lambda endpoint)

    4.  Choose hello world template and click on Continue with template.

    5.  Start building the custom skill by

         a. Entering an invocation name – ‘talking home’ is used in this project. This name is required for launching our custom skill.

         b. Adding custom intents and utterances –

             We will add a separate intent for controlling each of the device that we want to operate with our voice command. For adding a new intent click on Add Intent

            Put an intent name and click on Create custom intent

             Add all those phrases the user might utter to achieve the intent’s functionality as its sample utterances. (e.g. suppose a user wants to turn on the kitchen light, then the user may ask: turn on the kitchen light, turn the kitchen light, kitchen light on, make kitchen light on etc.)

    You can create the intents from the GUI in the developer console shown in the above step or use the provided JSON file (intents.json) and copy paste the contents in the JSON editor tab directly.

        c.  After creating all the intents ‘Save model’ followed by ‘Build Model’ and ensure error free build.

        d. Test your model by using ‘Evaluate model’. Entering a sample utterance should invoke the correct intent.

        e. Go to Endpoints -> Choose AWS Lambda ARN. Copy the skill Id. This is required in the AWS Lambda services configuration.

    After creating Lambda function we will get an ARN. We will return to the Alexa developer console and add the ARN of the lambda function we create in Alexa Skill endpoint.

        Refer to Alexa documentation for developing custom skill for more detailed explanation of creating custom skills.

  • 2
    Configuring the AWS IoT Core service

    Login to AWS console. Go to the AWS IoT Core.

    AWS IoT Core requires the following to be set up

    1.       Things - Things refer to a representation of the physical device.

    2.      Certificates - Certificates should be created to ensure secure communication between AWS and the device.

    3.      Policies - you must create and attach an AWS IoT policy that will determine what AWS IoT operations the thing may perform.

    Things Setup

    a. Go to AWS IoT Core service and from the Manage tab click on Things and then choose Register a thing

    b. Select Create a single thing and provide a thing name, keep other thing untouched and click on next

    Certificate Setup

    a. After creating a thing your next task is to create certificate for the thing. For creating certificate click on Create certificate

    b. Your certificate will be created. After creating certificate you need to download all the certificate file. You will required all these for PSoC programming.

    Attaching a Policy

    Now you need to attach a policy for the thing giving necessary access permission

    1. In the AWS IoT console, if a Get started button appears, choose it. Otherwise, in the navigation pane, expand Secure, and then choose Policies.
    2. If a You don't have any policies yet dialog box appears, choose Create a policy. Otherwise, choose Create.
    3. Enter a name for the AWS IoT policy (for example, psoc_policy). Add the json text and click on Create.

    I have already created a policy and added this policy to the thing. 

    From IoT things page you can choose already created policy and then click on Register Thing. You AWS IoT thing will be created syccessfully.

    Follow the instructions in the amazon documentation for more to create things, certificates, policies and attach the policies to certificates.

    Ensure to have same region selected for AWS lambda and AWS IoT core.

    Regions can be selected at the top right corner in both the consoles. N.Virginia (US EAST region was selected in this project).

  • 3
    Creating Lambda function
    1. From AWS home page, open lambda services by navigating through Services -> Compute -> Lambda and click on Create function.

      2. Choose to create function -> Author from scratch and Enter a function name.

       Choose Node.js 12.x for Runtime.

       3. Leave ‘choose/create execution role’ at default (i.e create a new role with basic lambda permissions).

       4. Once the function is created,  click on Add trigger and choose Alexa Skills Kit. 

      5. Enable skill id verification and paste the copied skill id from the Alexa skills endpoint section.

      6. Click on Lambda function name and Scroll down to the code function area and copy the code provided as index.js to the console

        7. Modify the lambda function to interact with the ‘thing’ related data in AWS IoT.

            a. Insert Endpoint with your own ‘thing’ endpoint from the IoT AWS core.

            Navigate to Things -> Interact and choose the REST API endpoint in the IoT AWS core.

            b. Change the ‘thing’ name in the lambda function per the thing name created in AWS IoT as shown below.

    8. Copy the ARN of your lambda function. Go back to Alexa developer page and add this to the default region of AWS Lambda ARN in the Alexa Skills Endpoint.

                  This is required for invoking this lambda function when the user interacts with ASK

View all 4 instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates