text.skipToContent text.skipToNavigation

COVID-19 Update

In line with government guidelines, Jaycar Auckland stores and Warehouse will be temporarily CLOSED. All other company-owned locations outside of Auckland will be Level 2. We encourage all customers to take advantage of free delivery for online orders over $99. THESE WILL DISPATCH ONCE THE WAREHOUSE REOPENS. We thank you for your support as we continue to keep our stores safe. See here for the latest on delivery delays.

IoT Smart Wireless Switch

Download Project Resources View on Github

IoT Smart Wireless Switch

Here is a great project to get started with your very own IoT (Internet of Things) home automation project. Based on the tiny yet powerful ESP8266 integrated WiFi and MCU (Microcontroller Unit) you can turn on or off appliances using your smart phone or tablet. Once you become familiar with the source code (provided with the project documentation) you will be able to create your very own innovations.

Bill of Materials

Qty Code Description
1 XC3802 ESP8266 D1 Mini Mainboard
1 XC3850 Prototype Shield (for XC3802)
1 ZW3100 Transmitter Mod 433mhz
1 MS6148 Switch RF Mains W/REM 10A Switch RF

You'll also need about 30cm of wire.

In order for the IoT Smart Wireless Switch to work you need to have good Wi-Fi coverage and your smart phone (or tablet) needs to be connected to the same Wi-Fi network as the IoT Smart Wireless Switch.

Connection Table

The figure below shows the circuit diagram, there is not much wiring to this project, only three wires between the ESP8266 and the 433MHz transistor unit, plus another wire that acts as an antenna.

Connections

The components can be constructed in any way that is convenient for your application, we have chosen to use the Wi-Fi Mini Shield XC3850 because it offers a neat way to interface to the ESP8266 D1 main board.

Shield

Programming

Step 1: Get the Source Code File

Download the project source code from here. If the source code file is zipped, then extract the file and place it in your Arduino IDE directory (normally /Documents/Arduino/Sketches/...).

Step 2: Configure Your Wi-Fi Settings

Open the project source file in the Arduino IDE. Change the following parameters to your Wi-Fi network SSID and password:

cost char* ssid = "your Wi-Fi SSID here"
cost char* password = "your Wi-Fi password here"

Note: Include the " in the above variables.

Step 3: Upload Your Source Code

Make sure you have selected the correct target board, under the 'Tools' menu:

Tools Menu

Make sure the you have connected the ESP8266 board to your computer and you have selected the correct USB port. Now upload the source code to your ESP8266.

After the upload operation is completed, under the 'Tools' tab, click on 'Serial Monitor' to open a serial monitor window (make sure the data rate is set to 115200 baud). You will be prompted with the Wi-Fi connection status as shown below:

Wi-Fi Status

Write down the IP address that appears on your screen, in the above example this is 192.168.10.197 (this will be different for your network).

Step 4: Go Online

On your smart phone or tablet (or any PC for that matter) open a new web browser such as Microsoft Edge, Google Chrome, etc. In the URL address enter the IP address you noted from Step 3 above. Now you should see the IoT Smart Wireless Switch control screen, as shown below.

Screen

In the sample code we called the first switch "Bedroom Lights" and the second "Kitchen Lights", you can customise these labels by locating and editing the following code:

// Display current state, and ON/OFF buttons for Switch 1
client.println("<p><i>Bedroom Lights -</i> " + output_1_State + "</p>");

// Display current state, and ON/OFF buttons for Switch 2
client.println("<p><i>Kitchen Lights -</i> " + output_2_State + "</p>");

Step 5: Pair Power Switch

Now all you need to do is to pair your IoT Smart Wireless Switch with the mains power unit. This is a very easy operation; all you need to do is follow the steps below:

1. Make sure the main power unit is unplugged.
2. Now insert the main power unit to the mains power. You will see the red light flashing, this indicates that the unit is ready to pair.
3. On your smart phone control screen click either the first or second "On" button. Wait until the command is completed. Now you should see the red light on the mains unit stay on (stop flashing).

That's it, your IoT Smart Controller is now paired with your mains power unit. You should be able to now switch the power unit on or off by clicking on the control screen button. Note that only the button you paired in step 3 above will be connected to the mains unit. You can add another mains unit and pair it to the second button, you can even modify the code to add more mains controllers.

Use

You can continue to use the remote control unit that is provided with your RF Mains Switch MS6148, so at your convenience you can control lights or appliances ON or OFF using your IoT Smart Wireless Switch (via your phone or any browser) or using the provided remote control unit.

Control