element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Home Automation
  • Challenges & Projects
  • Project14
  • Home Automation
  • More
  • Cancel
Home Automation
Blog SERA - Smart Extension Relay with Alexa - powered by MATRIX Creator and Arduino MKR1000
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Home Automation to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: dixonselvan
  • Date Created: 14 Mar 2019 3:20 PM Date Created
  • Views 2541 views
  • Likes 10 likes
  • Comments 5 comments
  • homeautomationch
  • alexa voice service
  • p14 mkr 1000
  • ardexpert
  • rpiexpert
Related
Recommended

SERA - Smart Extension Relay with Alexa - powered by MATRIX Creator and Arduino MKR1000

dixonselvan
dixonselvan
14 Mar 2019

Before starting with the project, I would like to thank tariq.ahmad for providing me with a free MATRIX Creator and Raspberry Pi 3B boards for the Home Automation Project14 Competition. If you would like to see my other Home Automation projects, check them out here in this link - Home Automation Projects - Consolidation.

 

Warning

Please do not attempt this project without proper electrical knowledge or guidance.

 

Table of Contents

    • Introduction
    • Working
    • Code
    • Useful Links

 

Introduction

 

How do I call it?

It has a been a while I have been playing around with a hacked extension box for the sake of controlling power to my home appliances. But it does not have a name yet. Let us name it SERA. SERA stands for Smart Extension Relay with Alexa voice service.

 

What can SERA do?

SERA can control the power to all the home appliances connected to it, through voice commands interpreted by Alexa. How it does will be explained below.

 

Let's see SERA in action before we dive into programming...

In this video, first Alexa in Amazon Echo Dot will interpret the voice commands to the Arduino MKR1000. Then I have muted the Echo Dot and turned Alexa voice services on the MATRIX Creator which will start to interpret the voice commands to Arduino MKR1000 thereby controlling the home appliances.

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

Working

 

In this SERA project, the MATRIX Creator will be running the Alexa Voice services to instruct the Arduino MKR1000 wirelessly to control the relay connected to the extension box. So you need two things,

  1. Alexa voice services installed on the MATRIX Creator
  2. The Smart Relay

 

Alexa Voice Services installation on the MATRIX Creator

 

Follow the steps in this tutorial blog to install Alexa voice services on the MATRIX Creator - https://www.hackster.io/matrix-labs/matrix-voice-and-matrix-creator-running-alexa-c-version-9b9d8d

 

The Smart Relay

 

The process goes like this when you instruct Alexa, the instructions are understood by Alexa and it calls out the respective applet in IFTTT. Then IFTTT triggers the respective action for the obtained input from Alexa. The action would be to pass a POST request to thinger.io with JSON body as below. This has the input variable 'state' passed to the Arduino MKR1000 through its API in thinger.io. Based on the state passed Arduino MKR1000 (master) communicates the corresponding relay to be turned ON/ OFF to the Arduino UNO (slave) connected to the Relay module. For instance, 1 - Turns the mobile charger ON and 2 - Turns OFF the mobile charger, 3 & 4 for the next relay ON & OFF and 5 & 6 for the third relay.

 

 

Alexa voice services installed on MATRIX Creator will interpret the voice commands to the Arduino MKR1000 which will in turn control the home appliances.

 

Code

Arduino MKR1000 code

 

/*Disabling the secure TLS/SSL connection*/
#define _DISABLE_TLS_


#include <WiFi101.h>
#include <ThingerWifi101.h>
#include "arduino_secrets.h"


/*Declaring Variables*/
int relayState = 0;


/*Create an account in thinger.io and replace username below with that username. 
Create a new device and replace deviceId, deviceCredential below with the one you had created.*/
ThingerWifi101 thing(SECRET_USERNAME, SECRET_DEVICEID, SECRET_DEVICECREDENTIAL);


void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
    
  /*Serial initialisation*/
  Serial1.begin(38400);
  
  /*Replace the below accrodingly with your WiFi SSID and password*/
  thing.add_wifi(SECRET_SSID, SECRET_PASS);


  /*The relay state is obtained as an input resource (integer/ number) from thinger.io*/
  thing["Test"] << [](pson& in){
      relayState = in["state"];
      changeRelayState();
  };
}


void loop() {
  thing.handle();
}


void changeRelayState(){
  if(relayState == 1)
  {
    digitalWrite(LED_BUILTIN, HIGH);
    Serial1.print(1);
  }
  else if (relayState == 2){
    digitalWrite(LED_BUILTIN, LOW);
    Serial1.print(2);
  }
  else if(relayState == 3)
  {
    digitalWrite(LED_BUILTIN, HIGH);
    Serial1.print(3);
  }
  else if (relayState == 4){
    digitalWrite(LED_BUILTIN, LOW);
    Serial1.print(4);
  }
  else  if(relayState == 5)
  {
    digitalWrite(LED_BUILTIN, HIGH);
    Serial1.print(5);
  }
  else if (relayState == 6){
    digitalWrite(LED_BUILTIN, LOW);
    Serial1.print(6);
  }
}

 

"arduino_secrets.h" file

Fill the corresponding data inside double quotes and save this file in the folder where you have the Arduino MKR100 code.

 

#define SECRET_SSID ""
#define SECRET_PASS ""
#define SECRET_USERNAME ""
#define SECRET_DEVICEID ""
#define SECRET_DEVICECREDENTIAL ""

 

Arduino UNO code

 

int Relay1 = 10;
int Relay2 = 11;
int Relay3 = 5;
int Relay4 = 6;
int serialData = 0;


void setup() {
  // put your setup code here, to run once:
  pinMode(Relay1, OUTPUT);
  pinMode(Relay2, OUTPUT);
  pinMode(Relay3, OUTPUT);
  pinMode(Relay4, OUTPUT);
  Serial.begin(38400);
  digitalWrite(Relay1, HIGH);
  digitalWrite(Relay2, HIGH);
  digitalWrite(Relay3, HIGH);
  digitalWrite(Relay4, HIGH);
}


void loop() {
  // put your main code here, to run repeatedly:
  if(Serial.available()>0){
     serialData = Serial.read();
     Serial.println(serialData);
     if (serialData == 49){
      digitalWrite(Relay1, LOW);
     }
     else if (serialData == 50){
      digitalWrite(Relay1, HIGH);
     }
     else if (serialData == 51){
      digitalWrite(Relay2, LOW);  
     }
     else if (serialData == 52){
      digitalWrite(Relay2, HIGH); 
     }
     else if (serialData == 53){
      digitalWrite(Relay3, LOW);
     }
     else if (serialData == 54){
      digitalWrite(Relay3, HIGH);
     }
     else if (serialData == 55){
      digitalWrite(Relay4, LOW);  
     }
     else if (serialData == 56){
      digitalWrite(Relay4, HIGH); 
     }
  }
}

Useful Links

Description Link
Product Page

MATRIX Creator - https://www.matrix.one/products/creator

Raspberry Pi 3B - https://www.raspberrypi.org/products/raspberry-pi-3-model-b/

Arduino MKR1000 - https://store.arduino.cc/usa/arduino-mkr1000

Tutorial

Installing Alexa voice service in MATRIX Creator -

https://www.hackster.io/matrix-labs/matrix-voice-and-matrix-creator-running-alexa-c-version-9b9d8d

MATRIX Creator Community https://community.matrix.one/

 

Have you got any suggestion or comment? Let me know in the comments section below.

  • Sign in to reply

Top Comments

  • dixonselvan
    dixonselvan over 6 years ago in reply to jomoenginer +2
    Thanks jomoenginer and congratulations you too for winning the MATRIX Creator giveaway. jomoenginer wrote: However, I believe a bit of clarification is needed since you can not install and run the…
  • three-phase
    three-phase over 6 years ago +1
    Interesting system you have built up dixonselvan . Could you automate something like the lights so when it gets dark, Alexa can then on the light automatically for you? Kind regards
  • jomoenginer
    jomoenginer over 6 years ago +1
    Nice Project Dixon and congrats on winning the Giving Your Habitat a Personality with Home Automation! contest. However, I believe a bit of clarification is needed since you can not install and run the…
  • samreen.islam
    samreen.islam over 6 years ago in reply to dixonselvan

    Hi dixonselvan,

     

    Yes, you and jomoenginer are exactly right. Alexa voice services are running on the Raspberry Pi and utilize the MATRIX Creator's microphones as audio input.

     

    Congratulations to you both for the cool projects! I look forward to seeing more of what you create. image

     

    Best,

    Samreen

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • dixonselvan
    dixonselvan over 6 years ago in reply to jomoenginer

    Thanks jomoenginer  and congratulations you too for winning the MATRIX Creator giveaway.

     

    jomoenginer  wrote:

     

    However, I believe a bit of clarification is needed since you can not install and run the Alexa Voice Services on the MATRIX Creator; this is running on the Raspberry Pi.

     

    To my knowledge, yes Alexa is running on the Raspberry Pi with MATRIX Creator microphones are capturing our voice and pass them to Raspberry Pi. But why I have mentioned  “MATRIX Creator is running the Alexa voice services” is because I considered MATRIX Creator and Raspberry Pi as one entity. After all it is the daughter board or add-on board for pi and it can not run standalone. Find below some screenshots from the tutorial link (by MATRIX Labs) which I posted tells only the microphone of MATRIX Creator is utilised and Pi is running the Alexa voice services.

     

    image

     

    image

     

    image

     

    I think samreen.islam from MATRIX Labs can confirm this as well? Samreen can you please confirm whether MATRIX Creator or Raspberry Pi is running Alexa voice services (refer the query quoted above by Jon Morss)?

     

    Thanks,

    Dixon Selvan

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jomoenginer
    jomoenginer over 6 years ago

    Nice Project Dixon and congrats on winning the Giving Your Habitat a Personality with Home Automation! contest.

     

    However, I believe a bit of clarification is needed since you can not install and run the Alexa Voice Services on the MATRIX Creator; this is running on the Raspberry Pi.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • dixonselvan
    dixonselvan over 6 years ago in reply to three-phase

    Thanks three-phase for your suggestion. The initial plan for this project had this feature but then it did not go well as planned (I'll post a separate blog to cover the issues faced from the beginning). So yes, I'll add in more features to SERA with the automatic turn ON or OFF of the lights.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • three-phase
    three-phase over 6 years ago

    Interesting system you have built up dixonselvan. Could you automate something like the lights so when it gets dark, Alexa can then on the light automatically for you?

     

    Kind regards

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube