Home Projects IoT Cosmos Modules Connected Switch

Connected Switch

Demo Video

Functional Block Diagram

The Figure below shows the functional block diagram of CCS. The device contains four separate major components — ESP8266 12E wifi module, the 5V power supply module, PC 817 Optocoupler, and a bipolar transistor. The optocoupler is used for optical isolation of the circuit to prevent probable damage from the high voltage side of the relay. The NPN transistor is used for switching the voltage from the ESP8266 to the relay. To the end of the relays, would be connected the high voltage devices such as fans, lights, air conditioners etc. The switches’ states can be manually managed by User Managed End-Points, or can be triggered by other connected end-points

Cosmos: Fire Sensor Functional Block Diagram

Technical Overview

Flowchart

The Cosmos: Connected Switches (CCS) initially boots up and repeatedly tries to connect with the MQTT broker, RPi3, till a successful connection is established. Once the link is confirmed, the RPi3 would publish the initial state of CCS. The CCS, then waits for a message from the broker, which would indicate the action that it has to perform. For instance, consider the following message being sent by the broker to the CCS module —`C1ON` as mesgRecvd, which translates to a turning on switch 1. The mesgRecvd is stored as a string, and compared using simple if-else conditions stored on the ESP8266 module. This mesgSent value is checked, if it is the same as the previous message sent, to prevent redundant message transfer.

Once any one of the conditional statements return a true value, the ESP8266 would send an active high signal to the corresponding pin which is predefined in the schematic. This in turn would result in the relay to be activated, allowing the live wire to be in contact with the commonly closed pin, to complete the circuit.

Cosmos: Fire Sensor Flow Chart

Third Party Integration

Alexa

In the initial scope of the project, it was indicated that voice commands would be integrated into COSMOS. Using standard API calls as defined by Amazon for Amazon echo, simple commands like, “Turn on Switch 1”, “Turn off Switch 2”, can be used to trigger events without using either the phone or a web user interface. Please note that the name of the device, is easily customizable, and can be sent to something generic such as “Lights”, or something more specific like “Desk Lights”.

Siri

Since, the mobile operating system platform chosen for development was iOS, integration of Apple’s voice assistant was taken into consideration. Making use of the HomeKit library, integration with the native ‘Home’ app on iPhone was carried out to allow for a more flexible approach for state management of the COSMOS: Connected switches. This allows for easy voice based commands to be executed from any apple device – iPhone, iPad, HomePod, and Apple Watch. Simply saying “Hey Siri, Turn on Switch 1” or “Hey Siri, Turn off Switch 2” can be used to trigger events. Please note that the name of the device, is easily customizable, and can be sent to something generic such as “Lights”, or something more specific like “Desk Lights”.

Final Product

Cosmos: Fire Sensor Flow Chart