IoT Based Home Automation Using Sinric Pro Google Assistant Alexa
by techstudycell in Circuits > Microcontrollers
1295 Views, 3 Favorites, 0 Comments
IoT Based Home Automation Using Sinric Pro Google Assistant Alexa
In this ESP32 project, I have shown how to make an IoT-based Home Automation with Google Assistant & Alexa using ESP32 to control 3 home appliances with voice commands. If the internet is not available, then you can control the home appliances from manual switches. During the article, I have shown all the steps to make this smart home system.
This complete Home Automation system has the following features:
- Control appliances with Google Assistant
- Control appliances with Alexa
- Control appliances manually with switches.
- Monitor real-time feedback in the Google Home and Amazon Alexa App.
- You can also set Automation to control the relays automatically.
- Control home appliances manually without internet.
- For this project, I have used a FREE Sinric Pro account
So, you can easily make this home automation project at home just by using an ESP32 and relay module. Or you can also use a custom-designed PCB for this project.
Supplies
You can make this project just by using ESP32, a 4-channel relay module and pushbuttons/switches.
But if you use PCB then you need the following components.
- ESP32 DEVKIT V1
- Relays 5v (SPDT) (4 no)
- BC547 Transistors (4 no)
- PC817 Optocuplors (4 no)
- 510-ohm 0.25-watt Resistor (4 no) (R1 - R4)
- 1k 0.25-watt Resistors (6 no) (R5 - R10)
- 10k 0.25-watt Resistor (1 no) (R11)
- LED 5-mm (6 no)
- 1N4007 Diodes (4 no) (D1 - D4)
- Push Buttons (4 no)
- Terminal Connectors
- 5V DC supply
Circuit Diagram of the ESP32 Home Automation Project
The circuit is very simple, I have used the GPIO pins D23, D22, D21 & D19 to control the 4 relays.
And, the GPIO pins D13, D12, D14 & D27 are connected with switches to control the 4 relays manually.
I have used the INPUT_PULLUP function in Arduino IDE instead of using the pull-up resistors.
I have used a 5V mobile charger to supply the smart relay module.
Please take proper safety precautions while working with high voltage.
Control Relays With Google Assistant Using ESP32
If the ESP32 is connected to the WiFi, then you can control the home appliances from the Google Home App and also from the push buttons / manual switches.
You can also tell Google Assistant to turn on or off the appliances.
Plus, you can check and control relay status from anywhere using the Google Home App, without needing a Google Home Nest device.
Control Relays With Alexa Using ESP32
You can also control the home appliances from the Amazon Alexa App if the ESP32 is connected to the WiFi.
You can also tell Alexa to turn on or off the appliances.
You can also control the appliances from the /push buttons / manual switches, Plus monitors the real-time feedback of the relays in the Amazon Alexa App from anywhere in the world.
You don't need any Echo devices for this IoT project.
Controlling Relays Manually With Pushbuttons / Switches
If the WiFi is disconnected, you can control the relays from the push buttons / manual switches.
The ESP32 will check for the WiFi after every 5 seconds. When the WiFi is available, the ESP32 will automatically connect with the WiFi.
Please refer to the circuit diagram to connect the manual switches.
Design the PCB for This ESP32 Project
To make the circuit compact and give it a professional look, I designed the PCB after testing all the features of the smart relay module.
You can download the PCB Gerber, BOM, and "pick and place" files of this ESP32 control relay PCB from the following link:
GitHub link to Download PCB Gerber File(for SMT)
GitHub link to Download through hole PCB Gerber file.
For this project, I have the JLC SMT Service while ordering the PCB.
Why You Should Use JLC SMT Service?
On JLCPCB's one-stop online platform, customers enjoy low-cost & high-quality & fast SMT service at an $8.00 setup fee($0.0017 per joint).
$27 New User coupon & $24 SMT coupons every month.
Visit https://jlcpcb.com
JLCPCB SMT Parts Library 200k+ in-stock components (689 Basic components and 200k+ Extended components)
Parts Pre-Order service https://support.jlcpcb.com/article/164-what-is-jlcpcb-parts-pre-order-service
Build a Personal library Inventory, save parts for now or the future
Assembly will support 10M+ parts from Digikey, Mouser.
Steps to Order the PCB Assembly From JLCPCB
- Visit https://jlcpcb.com/ and Sign in / Sign up.
- Click on the QUOTE NOW button.
- Click on the "Add your Gerber file" button. Then browse and select the Gerber file you have downloaded.
- Set the required parameters like Quantity, PCB masking color, etc.
- Select the Assemble side and SMT Quantity.
- Now upload the BOM and PickAndPlace files.
- Now confirm all the components you want to be soldered by SMT services.
- Click on the SAVE TO CART button.
Select Shipping Address and Payment Mode
- Type the Shipping Address.
- Select the Shipping Method suitable for you.
- Submit the order and proceed with the payment.
You can also track your order from the JLCPCB. My PCBs took 3 days to manufacture and arrived within a week using the DHL delivery option.
PCBs were well-packed and the quality was really good at this affordable price.
Create an Account in Sinric Pro
First, visit https://sinric.pro/
You have to create an account in Snric Pro.
Then log in to the Sinric Pro Account.
You will get an APP KEY and APP SECRET for the account, which will be required in the code.
Add Room and Devices in Sinric Pro
After that add a room and give a nickname to that room (Ex Living Room)
Then Add devices one by one and give the nickname for each device. Sinric will assign a unique device ID for each device.
Here, I have used the free Sinric Pro account, so I can add a maximum of 3 devices for free.
Generate the Code Using ZeroCode Features
Now you can generate the source code using the Sinric Zero Code features.
- Click on the Zero Code.
- Select the Devices and Switch type
- Enter the GPIO details for Relays and switches
- Enter WiFi name and password
- Click on Download.
Please refer to the tutorial video.
Program ESP32 Using Arduino IDE
First, download the code & install all the required libraries mentioned in the code.
Required Libraries:
- Sinric Pro
- ArduinoJson
- WebSockets
After that select the DOIT ESP32 DEVKIT V1 board and the PORT.
Then click on the upload button.
Setup the Google Home App
First, download and install the Google Home App. then follow the steps to create Home in Google Home app
- Tap on the "+" icon (upper left corner).
- Tap on Create new home.
- Enter the Home nickname and address.
- Then click on Continue.
The Home is created. Now again tap on the "+" icon to add devices.
Connect Sinric Skill in the Alexa App
Download and install the Amazon Alexa App from the Google play store or App Store.
- Go to "More", then select "Skills & Games"
- Search for Sinric Pro and tap on "Sinric Pro".
- Tap on "ENABLE TO USE"
- Log in with the Sinric account credentials.
- Tap on CLOSE.
- Tap on "DISCOVER DEVICES".
- It will take a minute to add devices. During this time the ESP32 should be connected with the WiFi.
- Tap on "Devices", and tap on "Plug" to see all the devices.
Thus, all the devices from Sinric Pro will be added to the Amazon Alexa App.
Test the ESP32 Project
Before connecting the appliances test the circuit.
Finally!! the IoT-based Smart Home System Is Ready
Now you can smartly control your home appliances.
I hope you have liked this Google and Alexa control home automation project. I have shared all the required information for this project.
I would appreciate it if you share your valuable feedback. Also if you have any queries please write in the comment section.
Thank you & Happy Learning.