Hackster is hosting Hackster Holidays, Finale: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Tuesday!Stream Hackster Holidays, Finale on Tuesday!
Dixon Selvan
Published © CC BY-NC-ND

The Smart Table Assistant

A voice-powered table assistant for makers and hackers to help manage inventory information and control power to maker/ home appliances.

IntermediateWork in progressOver 3 days5,088
The Smart Table Assistant

Things used in this project

Story

Read more

Custom parts and enclosures

Smart Relay Case

This is a smart relay case built to contain Arduino MKR1000, Arduino UNO, 4 channel 5V DC Relay module. The connections can be extended through jumper wires which can go through the slot inside each compartment and the top lid.

Schematics

Smart Relay

Circuit Diagram of the 'Smart Relay' part of the 'Smart Table Assistant'

Code

Smart Relay - Arduino UNO Code

C/C++
This is the code for the Arduino UNO used as part of the Smart Relay which controls the 4 channel 5V relay module.
/* This is the code for Arduino UNO used in the 'Smart Relay' part of the 'Smart Table Assistant project' built for the 
 *  'Smart Homes on the Edge' contest conducted by Hackster.io and sponsored by Seeed and Snips.
 * 
 * Contest Page - https://www.hackster.io/contests/building-for-voice
 * 
 * Blog Link - 
 * 
 * Author : Dixon Selvan
 * Date   : April 11, 2019
 * Project: Smart Table Assitant
 * Website: 
 * 
 * Hardware components Required
 * ----------------------------------------
 * 1. Arduino UNO board
 * 2. Four Channel Relay Module
 * 3. Arduino MKR1000
 * 4. Few Jumper wires
 * 
 * Connections
 * -----------
 * Arduino UNO      |   Relay Module
 * ---------------------------------------------
 *      5V          |         VCC
 *      Gnd         |         Gnd
 *      IN1         |         D10     
 *      IN2         |         D11
 *      IN3         |         D5
 *      IN4         |         D6
 * Arduino UNO      |   Arduino MKR1000
 * ---------------------------------------------
 *      Vin         |         +5V
 *      Gnd         |         Gnd
 *      RX          |         TX     
 *      TX          |         RX
 * 
 */
 
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); 
     }
  }
}

Smart Relay - Arduino MKR1000 Code - Secrets.h

C/C++
This is the secrets.h code for the Arduino MKR1000 used as part of the Smart Relay which controls the Arduino UNO connected to the 4 channel 5V relay module.
#define SECRET_SSID ""
#define SECRET_PASS ""
#define SECRET_USERNAME ""
#define SECRET_DEVICEID ""
#define SECRET_DEVICECREDENTIAL ""

Smart Relay - Arduino MKR1000 Code

C/C++
This is the code for the Arduino MKR1000 used as part of the Smart Relay which controls the Arduino UNO connected to the 4 channel 5V relay module.
/* This is the code for Arduino MKR1000 used in the 'Smart Relay' part of the 'Smart Table Assistant project' built for the 
 *  'Smart Homes on the Edge' contest conducted by Hackster.io and sponsored by Seeed and Snips.
 * 
 * Contest Page - https://www.hackster.io/contests/building-for-voice
 * 
 * Blog Link - 
 * 
 * Author : Dixon Selvan
 * Date   : April 11, 2019
 * Project: Smart Table Assitant
 * Website: 
 * 
 * Hardware components Required
 * ----------------------------
 * 1. Arduino MKR1000 board
 * 2. Few Jumper wires
 * 3. [Optional] 3.7V Lithium Battery
 * 
 * Connecting Arduino MKR1000 with thinger.io, getting started guide - http://docs.thinger.io/arduino/
 */

/*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["Relay"] << [](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);
  }
}

Smart Table Assistant - GitHub Repository

This is the GitHub Repository where you can find the entire code for the 'Smart Table Assistant' project.

Credits

Dixon Selvan
1 project • 17 followers
Software Engineer & an Electronics and Communication graduate, who is passionate about the latest Technology, IoT, AI/ML & Embedded Systems.

Comments