But if you want to build a smart home that is completely private, you don’t want to rely on a third party. You never know when they might close down their cloud services. Thus, security and reliability are big concerns. Fortunately, building smart switches that work with Alexa and smart home automation software, such as Home Assistant, is quite easier.
What You Need to Build a Smart Switch
Let’s say you want to build a 5-channel smart switch that you can use to control up to 5 different devices of up to ~2 amps at 220V or 110V. To build this smart switch, you will need the following:
One D1 Mini One Hi-Link 5V 5W or 10W PSU Two 6-pins screw terminals One 2-pins screw terminal Five 220Ω ¼ watt resistors Five 1KΩ ¼ watt resistors Five MOC3021 optocoupler ICs Five Triacs, such as BTA12, BTA16, or similar. We have used the BTA16. One fabricated or general PCB to mount and solder all the components Soldering iron and tin Wires to connect your load
We have already designed the PCB and did the hard part (new and improved). All you need to do is download the Gerber file, which you can use to get your PCBs printed or fabricated from any PCB manufacturer or supplier. FYI, we got 10 PCBs fabricated for $7 and paid $5 for shipping.
Solder the Components on the PCB
Mount all the components on the PCB as shown on the PCB. You may also use general PCB and follow the connection diagram shared below to manually mount and solder all the components.
IMPORTANT INSTRUCTIONS
Do not mount and solder the D1 Mini directly to the PCB. Follow these instructions to mount D1 Mini on the PCB.
D1 Mini comes with male and female berg strips. Solder the male berg strip to D1 Mini. Solder the female berg strip on the PCB where we need to place the D1 Mini. Place the D1 Mini on the female strips soldered on the PCB board to mount it on the board.
This will help you quickly disconnect or replace D1 Mini if it goes bad.
If you don’t know or never soldered before, we highly recommend that you learn how to solder before proceeding.
Flash the Firmware
Once the components are mounted and soldered on the PCB, follow these steps to download, flash and configure the firmware on the D1 Mini to control the 5-Solid State relay on the board.
Download the Tasmota firmware (tasmota. bin file) on your system and install the Tasmotizer tool (available for Windows Only). You may also use ESPHome-Flasher tool if you are using macOS or Linux. Launch the Tasmotizer tool and connect the D1 Mini to your PC using the micro USB cable. Click the Refresh button. Select the COM port where the D1 Mini is connected. Click Open and then browse the Tasmota firmware you downloaded (. bin file). Click Tasmotize. Wait for the process to complete. It will take less than a minute to finish. Once the flashing is finished, click the Send config button. Select WiFi and enter the SSID and password of your Wi-Fi network. Click Module/template and choose Generic. Click Save. You will see a message ‘Configuration Sent. Device will restart. ’ Click the Get IP button after a few seconds. This will show you the IP of the device when it successfully connects to your network. Open the Web Browser and enter this IP. It will open the Tasmota Web Interface.
If you want, you can also build a single-channel solid-state relay or DIY Alexa-supported single-channel smart switch.
Configure the DIY Smart Switch
Once the Tasmota Web Interface (Web UI) opens, follow the below steps to configure the 5-switches for Wi-Fi and Alexa control.
Click Configuration > Configure Module. Then refer to the below screenshot to choose the Relay and Switch options followed by the channel number. Once you have selected all the required channels for Relay and Switch options, click Save. The device will save the configuration and restart. The Web UI will be auto-refreshed. You will see 5-controls on the Tasmota web UI. These can be used to trigger and control the solid state relays on the board to switch ON/OFF the connected load. 1 indicates the switch is ON while 0 indicates OFF.
Enable Alexa Support
To control this smart 5-channel smart switch with Alexa, follow these steps:
In the Tasmota Web UI, click Configuration > Configure other. In the Device name, give your smart switch a nice name, such as Living Room Smart Switch. Also, enter the name of the 5-devices that you will be controlling using this DIY smart switch. Since we are using it for light controls, we have named them accordingly. Make sure to select the Hue Bridge radio button and then click Save. The device will restart. You can now ask your Echo device to discover devices using the command, ‘Alexa, discover devices. ’ You may also use the Alexa app > Devices to add these DIY smart switches. The devices will show the name which you entered in the friendly name field in the Tasmota Web UI. However, you can edit or change the names in Alexa app as per your needs. They are recognized as Royal Philips Electronics smart device. Now you can control the smart switches with the Alexa app or using your Echo device. Just say, ‘Alexa, switch on the Led Strip. ’
Add to Home Assistant
To add this DIY smart switch to Home Assistant (HA), you need to enable the MQTT on Home Assistant and then enter the MQTT details via the Tasmota Web UI by following these steps:
In Tasmota UI, click Configuration > Configure MQTT. Enter the Host IP (your HA IP), User, and Password. Keep other things as default and click Save. If auto-discovery is enabled on your HA (by default it is), you can see the 5-new smart switches in Settings > Devices & Services. You can select and add them to your HA dashboard and control the switches from the HA web UI directly with real-time switch status updates.
Deploy Noiseless DIY & Private Smart Switches
You can build and use this 5-channel smart switch to control your fan, lights, or any other home appliances that require up to 200-300 watts of power. Since we have built this switch with Solid-State Relays (SSR), this switch will work silently with no clicking noise. Besides, you can control them locally even if there’s no internet or, if you are connected to the internet, from anywhere in the world using the Alexa app.