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

Contact

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

Lightweight Sliding Door Automator
Intermediate
  • 1,557
  • 8

Work in progress

Automate the opening and closing of a lightweight sliding door (e.g. a screen door), including remote controls on your phone.

Christmas Gift Box
Intermediate
  • 3,634
  • 595

Full instructions

Christmas Gift Box plays music and sends an email when it is opened.

Carbon Fiber Vacuum Chamber
Intermediate
  • 2,909
  • 94

Full instructions

Our project is a carbon fiber vacuum chamber that is monitored by multiple particle photons and various sensors.

ConnectTheDots with Particle Azure IoT Hub Integration
Intermediate
  • 844
  • 8

Protip

This project will allow you to connect your Particle device into an Azure IoT Hub for viewing data in real-time through an ASP.NET web app!

What should I wear outside?
Intermediate
  • 5,046
  • 67

Full instructions

A whimsical weather clock powered by Particle and forecast.io

LED Reflection Clock
Intermediate
  • 2,176
  • 35

Work in progress

Using 60 LED's facing a suitable wall, the time is projected in colour.

Add projectSign up / Login