Introduction: Techswitch 1.0

About: Learning & discovering new things can enrich humanity. Technology can definitely change the world. I like to search problems so that I can find solutions. I don't realise my passion about technology during my …

Empower Smart home by TechSwitch-1.0(DIY Mode) .

What is TechSwitch-1.0(DIY Mode)

TechSwitch-1.0 is ESP8266 based smart switch. it can control 5 home appliances.

Why it is DIY mode??

  1. It is designed to re-flash any time. there is two mode selection jumper on PCB.

1) Run Mode:- for Regular operation.

2) Flash Mode :- in this mode user can re-flash chip by following Re-flash procedure.

3) Analog Input:- ESP8266 has one ADC 0-1 Vdc. Its header also provided on PCB to play with any Analog sensor.

Technical Specification of TechSwitch-1.0(DIY mode)

1. 5 Output(230V AC) + 5 Input(0VDC switching) + 1 Analog input(0-1VDC)

2. Rating :- 2.0 Amps.

3. Switching element :-- SSR +Zero Crossing switching.

4. Protection :- Each output protected by 2 Amp. glass fuse.

5. Firmware used:- Tasmota is easy to use and stable firmware. It can be flashed by different firmware as its DIY mode.

6. Input :- Opto coupled (-Ve) switching.

7. ESP8266 power regulator can be dual mode:- can use Buck converter as well AMS1117 regulator.


  • Detailed BOQ is attached.

    · Power Supply:- Make :- Hi-Link , Model :- HLK-PM01, 230V by 5 VDC, 3W (01)

    · Microcontroller:- ESP12F (01)

    · 3.3 VDC regulator :- Dual provision any one can be used

    · Buck converter (01)

    · AMS1117 Voltage regulator.(01)

    · PC817 :- Opt coupler Make :- Sharp Package:-THT (10)

    · G3MB-202PL:- SSR Make Omron(05), Zero crossing switching.

    · LED :-Color:- Any, Package THT (01)

    · 220 or 250 Ohm Resistor:- Ceramic (11)

    · 100 Ohm Resistor:- Ceramic (5)

    · 8k Ohm Resistor :- Ceramic(1)

    · 2k2 Ohm Resistor :- Ceramic(1)

    · 10K Ohm Resistor:- Ceramic (13)

    · Push button :-Part Code:- EVQ22705R, Type:- with Two terminal (02)

    · Glass Fuse:- Type :- Glass, Rating :- 2 Amp @ 230V AC. (5)

    · PCB Male Header:- Three header with Three pin & One header with 4 Pin. so one standard Strip of Male header is preferable to procure.

Step 1: Consept Finalization.

Finalization of Concept:- I have define requirement as below.

1. Making Smart Switch having 5 Switch & Can controlled by WIFI.

2. It Can operate withot WIFI by physical Switches or Pushbutton.

3 Switch can be DIY mode so it can be RE-Flashed.

4. It can fit in existing switch board without changing any switches or wiring.

5. ALL GPIO of Microcontroller to be used as it is DIY mode.

6. Switching device should SSR & zero crossing to avoide noice & switching surges.

7. Size of PCB Should be small enough so it can fit in existing switchboard.

As we finalized requirement , next step is to select hardware.

Step 2: Selection of Microcontroller

Microcontroller selection criteria.

  1. Required GPIO :-5 input + 5 Output + 1 ADC.
  2. Wifi enabled
  3. Easy to Re-flash to provide DIY functionality.

ESP8266 is suitable for above requriement. it has 11 GPIO + 1 ADC + WiFi enabled.

I have selected ESP12F module which is ESP8266 microcontroller based Devlopment board , it has small formfactor & all GPIO are populated for easy use.

Step 3: Checking GPIO Detail of ESP8266 Board.

    • As per ESP8266 Data sheet some GPIO are used for special function.
    • During Breadboard Trial I scratched my head as not able to boot it.
    • Finally by research on internet and playing it with breadboard I have summarized GPIO data and made simple table for easy understanding.

    Step 4: Selection of Switching Device.

    • I have selected Omron Make G3MB-202P SSR
      • SSR having 2 amp. current capacity.
      • Can operates on 5VDC.
      • Provide Zero crossing Switching.
      • Inbuilt Snubber circuit.

    What is Zero Crossing?

    • 50 HZ AC supply is sinusoidal voltage.
    • Supply voltage polarity changed every 20 mille second & 50 times in one second.
    • Voltage gets zero every 20 mille second.
    • Zero crossing SSR detects zero potential of voltage and turn on output on this instance.
      • For example :- if command send at 45 Degree (voltage at maximum peak), SSR turned on at 90 degree(when voltage is zero).
    • This reduces switching surges & noise.
    • Zero crossing point is shown in attached image (Red highlighted text)

    Step 5: Selection of Power Supply.

    Selection of Power Supply.

    • In India 230VAC is domestic supply. as ESP8266 operates on 3.3VDC, we have to select 230VDC / 3.3VDC power supply.
    • But Power Switching device which is SSR & operates on 5VDC so i have to select Power Supply which have 5VDC as well.
    • Finally selected power supply having 230V/5VDC.
    • To get 3.3VDC i have selected Buck converter having 5VDC/3.3VDC.
    • As we have to design DIY mode i also provide provision of AMS1117 linear voltage regulator.

    Final Conclusion.

    First power supply conversion is 230VAC / 5 VDC having 3W capacity.

    1. HI-LINK make HLK-PM01 smps.

    Second conversion is 5VDC to 3.3VDC

    1. For this i have selected 5V/3.3V Buck converter & provision of AMS1117 Linear voltage regulator.

    PCB made in such way it can use AMS1117 or buck converter(Anyone one).

    Step 6: ESP8266 PIN Selection.

    ESP8266 has total 11 GPIO and One ADC pin. (Refer Step 3)

    Pin selection of esp8266 is crucial because of below critaria.

    Criteria for Input selection:-

    • GPIO PIN15 Required to be Low during Bootup other wise ESP will not boot.
      • It try to bootup from SD card if GPIO15 is High during Bootup.
    • ESP8266 neve Boot If GPIO PIN1 or GPIO 2 or GPIO 3 is LOW during bootup.

    Criteria for Output Selection :-

    • GPIO PIN 1,2,15 & 16 get High during Bootup(for fraction of time).
    • if we use this pin as input & PIN is at LOW level during bootup then this pin gets damaged due to short circuit between PIN which is Low but ESP8266 turin it HIGH during bootup.

    Final conclusion :-

    Finally GPIO 0,1,5,15 & 16 are selected for output.

    GPIO 3,4,12,13 & 14 are selected for Input.


    • GPIO1 & 3 is UART pins which are used to flash ESP8266 & we also wanted to use those as output.
    • GPIO0 is used to put ESP in flash mode & we also decided to use it as output.

    Solution for above constrain:-

    1. Problem solved by provide two jumpers.
      1. Flash mode jumper: - In this position all three pins are isolated from switching circuit and connected to flash mode header.
      2. Run mode jumper:- In this position all three pins will connected to switching circuit.

    Step 7: Optocoupler Selection.

    PIN Detail:-

    • PIN 1 & 2 Input Side (Inbuilt LED)
      • Pin 1 :- Anode
      • Pnd 2 :- Cathode
    • PIN 3 & 4 Output Side(Photo transistor.
      • Pin 3:- Emitter
      • Pin 4 :- Collector

    Output switching circuit selection

    1. ESP 8266 GPIO can feed only 20 m.a. as per esprissif.
    2. Optocoupler are used to protect ESP GPIO PIN during SSR switching.
    3. 220 Ohms resistor is used to limit current of GPIO.
      • I have used 200, 220 & 250 & all resistors are work fine.
    4. Current calculation I = V/R, I = 3.3V / 250*Ohms = 13 ma.
    5. PC817 input LED has some resistance which considered as zero for safe side.

    Input Switching circuit selection.

    1. PC817 optocouplers are used in input circuit with 220 ohms current limiting resistor.

    2. Output of optocoupler are connected with GPIO along with Pull-UP resistor.

    Step 8: Circuit Layout Preparation.

    After selection of all component and define wiring methodology, we can move on to develop Circuit using any software.

    i have used Easyeda which is Web based PCB development platform and easy to use.

    URL of Easyeda :- EsasyEda

    For simple explainaiton i have divided whole circuit in chunks. & first is Power circuit.

    Power circuit A:- 230 VAC to 5VDC.

    1. HI-Link makes HLK-PM01 SMPS used to convert 230Vac to 5 V DC.
    2. Maximum Power is 3 Watt. means it can supply 600 ma.

    Power circuit B:- 5VDC to 3.3VDC.

    As this PCB is DIY mode. i have provide two method to convert 5V to 3.3V.

    1. Using AMS1117 Voltage regulator.
    2. Using Buck Converter.

    anyone can used as per component availability.

    Step 9: ESP8266 Wiring

    Net port option is used to make schematic simple.

    What is Net port??

    1. Net post means we can provide name to common junction.
    2. by using same name in different part, Easyeda will considered all same name as single connected device.

    Some basic rule of esp8266 wiring.

    1. CH_PD pin required to be high.
    2. Reset pin required to be high during normal operation.
    3. GPIO 0,1 & 2 shoud not at Low during boot up.
    4. GPIO 15 should not at High level during Boot up.
    5. Considering all above points in mind ESP8266 wiring scheme is prepared. & shown in schematic image.
    6. GPIO2 is used as Status LED & connected LED in Reverse polarity to avoide GPIO2 LOW during Bootup.

    Step 10: ESP8266 Output Switching Circuit

    ESO8266 GPIO 0, 1, 5, 15 & 16 used asoutput.

    1. To keep GPIO 0 & 1 at high level its wiring is bit different from other output.
      1. Booth this pin is at 3.3V during boot up.
      2. PIN1 of PC817 which is anode is connected to 3.3V.
      3. PIN2 which is Cathode is connected to GPIO using current limiting resistor(220/250 Ohms).
      4. As forward biased Diode can pass 3.3V(0.7V diode drop) Both GPIO get almost 2.5 VDC during boot up.
    2. Remaining GPIO pin connected with PIN1 wihich is Anode of PC817 & Ground is connected with PIN2 which is Cathode using current limiting resistor.
      1. As Ground is connected with Cathode it will pass from PC817 LED and keep GPIO at Low level.
      2. This makes GPIO15 LOW during boot up.
    3. We solved problem of all three GPIO by adopting different wiring scheam.

    Step 11: Esp8266 Input.

    GPIO 3,4,12,13 & 14 are used as Input.

    As Input wiring will be connected to field device, protection required for ESP8266 GPIO.

    PC817 optocoupler used for input isolation.

    1. PC817 Input Cathodes are connected with Pin headers using current limiting resistor (250 Ohms).
    2. Anode of all Optocoupler is connected with 5VDC.
    3. Whenever Input pin connected to Ground, Optocoupler will forward biased and output transistor turned on.
    4. Collector of optocoupler is connected with GPIO along with 10 K Pull-up resistor.

    What is Pull-up???

    • Pull-up resistor is used To keep GPIO stable, high value resistor connected with GPIO and another end is connected to 3.3V.
    • this keep GPIO at high level and avoid false triggering.

    Step 12: Final Schematic

    After Completion of all parts its time to check wiring.

    Easyeda Provide feature for this.

    Step 13: Convert PCB

    Steps to convert Circuit in to PCB Layout

    1. Aftermaking Circuit we can convert it in to PCB layout.
    2. By pressing Convert to PCB option of Easyeda system will start conversion of Schematic in to PCB Layout.
    3. If any wiring error or unused pins are present then Error/Alarm generates.
    4. By checking Error in Right side section of Software development page we can resolve each error one by one.
    5. PCB layout generated after all error resolution.

    Step 14: PCB Layout & Componant Arrangement.

    Componant Placement

    1. All components with its actual
    2. dimensions and labels are shown in PCB layout screen.
      1. First step is to arrange component.
    3. Try to put High voltage and Low voltage component as far as possible.
    4. Adjust each component as per required size of PCB.
      1. After arranging all components we can make traces.
    5. (traces width required to be adjust as per current of circuit part)
    6. Some of traces are traced in bottom of pcb using layout change function.
    7. Power traces are keeping exposed for soldering pouring after fabrication.

    Step 15: Final PCB Layout.

    Step 16: Checkign 3D View and Generating Ggerber File.

    Easyeda provide 3D view option in which we can check 3D view of PCB and get idea how it looks after fabrication.

    After checking 3D view Generate Gerber files.

    Step 17: Placing Order.

    After Generation of Gerber file system provides Front view of final PCB layout and cost of 10 PCB.

    We can place order to JLCPCB directly by pressing "Order at JLCPCB" Button.

    We can select color masking as per requirement and select mode of delivery.

    By placing order and making payment we get PCB within 15-20 days.

    Step 18: Recieving PCB.

    Check PCB front and back after receiving it.

    Step 19: Componant Soldring on PCB.

    As per component identification ON PCB all components soldering started.

    Take Care:- Some part footprint is backward side so check labeling on PCB and part manual before final soldering.

    Step 20: Power Track Thickness Increasing.

    For power connection tracks I put open tracks during PCB layout process.

    As shown in image all power traces are open so poured extra soldering on it to increase currant caring capacity.

    Step 21: Final Checking

    After soldering of all components cheked all components using multimeter.

    1. Resistorvalue checking
    2. Optocoupler LED checking
    3. Grounding checking.

    Step 22: Flashing Firmware.

    Three jumpers of PCB are used to put esp in boot mode.

    Check Power selection Jumper on 3.3VDC of FTDI Chip.

    Connect FTDI chip to PCB

    1. FTDI TX :- PCB RX
    2. FTDI RX :- PCB TX
    3. FTDI VCC :- PCB 3.3V
    4. FTDI G :- PCB G

    Step 23: Flash Tasamota Firmware on ESP.

    Flash Tasmota on ESP8266

      1. DownloadTasamotizer & tasamota.bin file.
      2. Download link of Tasmotizer:- tasmotizer
      3. Download link of tasamota.bin:- Tasmota.bin
      4. Install tasmotazer and open it.
      5. In tasmotizer click selectport drill dawn.
      6. if FTDI is connected then port appear in list.
      7. Select port from list.(in case multiple port, check which port is of FTDI)
      8. click open button and Select Tasamota.bin file from download location.
      9. click on Erase before flashing option(clear spiff if any data is there)
      10. Press Tasamotize! Button
      11. if everything is ok then you get progressbar of erasing flash.
      12. once process completed it shows "restart esp" popup.

      Disconnect FTDI from PCB.

      Change Three jumper from Flash to Run Side.

      Step 24: Seting Tasmota

      Connect AC power to PCB

      Tasmota configration online help:-Tasmota configration help

      ESP will start and Status led of PCB flash onece. Open Wifimanger on Laptop It shows new AP "Tasmota" connect it. once connected webpage opened.

      1. Configure WIFI ssid & Password of your router in Configure Wifi page.
      2. Device will restart after saving.
      3. Once reconnect Open your router, check for new device ip & note its IP.
      4. open webpage and enter that IP. Webpage open for tasmota setting.
      5. Set Module type(18) in configue module option and set all input & output as mentioned in comnfigration image.
      6. restart PCB and its good to go.

      Step 25: Wiring Guide and Demo

      Final Wiring & Trial of PCB

      Wiring of all 5 inputs are connected to 5 Switch/Buttone.

      Second connection of all 5 device is connected to Common "G" wire of input header.

      Output side 5 Wire connecton to 5 home applieance.

      Give 230 to input of PCB.

      Smart Swith with 5 Input & 5 Output is ready to use.

      Demo of trial :- Demo

      PCB Design Challenge

      Participated in the
      PCB Design Challenge