Things used in this project

Hardware components:
Amazon echo dot
Amazon Alexa Echo Dot
×1
Photon new
Particle Photon
×1
Mcp23008 scr8g5le 10a b%20(1)
ControlEverything.com Relay Shield for Particle Photon I²C 8-Channel SPDT 10-Amp
×1
Software apps and online services:
Particle Online build for particle photon
Gawd2jnp51w1h1ccsulo
IFTTT Amazon Alexa service
Hand tools and fabrication machines:
Screwdriver
To screw in hot leg to COM of relay
Wire cutter

Schematics

Video - Working model
RiySQOqGjFi9KlZu8cM8.mp4

Code

Code to control Relay Shield for Particle Photon I²C 2-Channel DPDT 5-Amp with WiFi and USBArduino
#if PLATFORM_ID == 6
//Photon code here

    #define MY_FUNCTION(cloudFunctionID,localFunctionName)   Particle.function(cloudFunctionID,localFunctionName) 
    #define MY_VARIABLE(cloudVariableID,localVariableName)   Particle.variable(cloudVariableID,localVariableName) 
    
    // This #include statement was automatically added by the Particle IDE.
    #include "NCD2Relay/NCD2Relay.h"
    
    /*For relay control*/
    NCD2Relay relayController;
    
   
    /*Relay number*/
    int relayNumber = 1;
    
    /*Relay status*/
    int rStatus = 0;
    /***********************************Relay END**************************************/
    
    int commandSent = 255;
 
    void setup() 
    {
        setupFunctions();
        setupRelay();
    }
    
    void loop() 
    {
       
    }
    
    void setupFunctions()
    {
        MY_FUNCTION("Relay#",setRelayNumber);
        MY_FUNCTION("RelayAction",setResetRelay);  
    }
    
    void setupVariables()
    {
    }
    
    void setupRelay()
    {
        Serial.begin(9600);
        relayController.setAddress(0,0,0);
    }
    

    
    int setRelayNumber(String command)
    {
        if (command.length() != 1) 
            return -1;
    
        relayNumber = atoi(command);
                
    }
    
    int setResetRelay(String command)
    {
        if (command.length() != 1) 
            return -1;
        
        commandSent = atoi(command);

        if (commandSent==1) 
        {
            rStatus = relayController.readRelayStatus(relayNumber);
            
            if(rStatus==0)
            {
              relayController.turnOnRelay(relayNumber);  
            }

            return rStatus;
        }
        else if(commandSent==0)
        {
            rStatus = relayController.readRelayStatus(relayNumber);
            
            if(rStatus==1)
            {
                relayController.turnOffRelay(relayNumber);
            }
            

            return rStatus; 
        }
    }


#else
    #error "*** PLATFORM_ID not supported by this library. PLATFORM should be Core or Photon ***"
#endif

Credits

T4ay8khmmkybgrh5mg54
Jay K

HMI Architect - Automotive domain

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

IoT Drone - Part 1 - Motor Control
Intermediate
  • 1,363
  • 27

Work in progress

After flying a friends drone I was hooked. However, I wanted to build my own, so this is part one of my drone project - motor control.

Bike Swarm
Intermediate
  • 611
  • 13

Work in progress

Cyclists will be able to connect seamlessly to form a synchronized swarm of riders to reduce traffic congestion and improving safety.

Bike Swarm

Team Bright Water Bottle

Smart Maid
Intermediate
  • 1,315
  • 21

Full instructions

Hack your existing iRobot Create with Particle and control it through Alexa.

Smart Maid

Team Yosnalab

"Internet-controlled" Nespresso Machine
Intermediate
  • 2,618
  • 8

Using a chatbot and a Nespresso machine to make coffee remotely.

IoT Smart Desk Drawer with Amazon DRS
Intermediate
  • 461
  • 4

Never run out of office supplies again. PostIt notes, stamps, paperclips, tape and paper replenished from the cloud.

Home Theater Accent Lights
Intermediate
  • 307
  • 1

Full instructions

Particle Photon and SmartThings controlled WS2812B.

Add projectSign up / Login
Respect project