Our smarthome system employs IoT devices, with the ESP32 serving as the control hub. Communication between the ESP32 and the server is facilitated by the MQTT protocol, while NodeJS is used to develop the server and MongoDB is employed to store data. A web client is built to oversee device control and data analysis, with REST API used for server-to-web-client communication, complemented by WebSockets for real-time communication.
In addition, we try to use great platform Sinric Pro - a cloud service that enables voice control of devices. Specifically, we use Sinric Pro to control up to 3 devices and , employing either Alexa or Google Assistant for device control.
-
npm
npm install npm@latest -g
-
ESP32 Install in Arduino IDE
- Board (esp32)
- Library (Sinric Pro, WebSockets, AdruinoMqttClient, AdruinoJson, adruino-mqtt-master)
-
Clone the repo: https://github.com/brojackvn/SmartHome-IoT.git
-
Install npm packages
> cd server > npm install
-
To use Sinric Pro, you need to create an account, connect to Sinric Pro and add add a device.
- Replace APP_KEY and APP_SECRET in the code with the APP_KEY and APP_SECRET you created.
- Create a device in Sinric Pro dashboard and replace the device id in the code with the device id you created.
-
Run server
> cd server > npm start
-
Run client
> cd client
-
Run ESP32
> cd ESP32 > open file smarthome-esp.ino in Arduino IDE > upload code to ESP32
-
Open browser and go to http://localhost:3000
-
Open Sinric Pro app or use Alexa or Google Assistant to control device