CPP Report
CPP Report
1 INTRODUCTION
2.1
In this IoT projects, We have make the smart home with Google
Assistant & Alexa using NodeMCU ESP8266 to control relays with
voice commands and manual switches. We have used all the free tools
for this IoT-based home automation system.
Working
If the NodeMCU is connected with the WiFi, then we can control the
home appliances from Google Home App and also from the manual
switches.
we can also ask Google Assistant to turn on and off the appliances.
we can control, monitor the real-time status of the relays in the
Google Home App from anywhere in the world. we don't need any
Google Home Nest device for this home automation project.
4.We will get an APP KEY and APP SECRET for the
account, which will be
required in the code.
//#define ENABLE_DEBUG
#ifdef ENABLE_DEBUG
#define NODEBUG_WEBSOCKETS
#define NDEBUG
#endif
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include "SinricPro.h"
#include "SinricProSwitch.h"
#include <map>
// comment the following line if you use a toggle switches instead of tactile buttons
//#define TACTILE_BUTTON 1
int relayPIN;
int flipSwitchPIN;
deviceConfig_t;
// please put in your deviceId, the PIN for Relay and PIN for flipSwitch
// right now we have 4 devicesIds going to 4 relays and 4 flip switches to switch the relay manually
};
String deviceId;
bool lastFlipSwitchState;
flipSwitchConfig_t;
void setupRelays() {
for (auto &device : devices) { // for each device (relay, flipSwitch combination)
digitalWrite(relayPIN, HIGH);
void setupFlipSwitches() {
for (auto &device : devices) { // for each device (relay / flipSwitch combination)
int relayPIN = devices[deviceId].relayPIN; // get the relay pin for corresponding device
void handleFlipSwitches() {
#ifdef TACTILE_BUTTON
#endif
#ifdef TACTILE_BUTTON
}
#endif
void setupWiFi()
Serial.printf("\r\n[Wifi]: Connecting");
WiFi.begin(WIFI_SSID, WIFI_PASS);
Serial.printf(".");
delay(250);
digitalWrite(wifiLed, LOW);
void setupSinricPro()
mySwitch.onPowerState(onPowerState);
}
SinricPro.begin(APP_KEY, APP_SECRET);
SinricPro.restoreDeviceStates(true);
void setup()
Serial.begin(BAUD_RATE);
pinMode(wifiLed, OUTPUT);
digitalWrite(wifiLed, HIGH);
setupRelays();
setupFlipSwitches();
setupWiFi();
setupSinricPro();
void loop()
SinricPro.handle();
handleFlipSwitches();