Voice Home Control V1.0

Introduction: Voice Home Control V1.0

A few months ago I acquired a personal assistant, specifically an Echo Dot equipped with Alexa. I chose it because I discovered that in a simple way can add plugins to control the device off and on like lights, fans, etc. In online stores I saw a large number of devices that fulfill this function, and that's when I thought .... why not make your own?

With this idea in mind, I started designing a board with Wi-Fi connection and 4 output relays. Below I will describe the design step by step from the schematic diagram, PCB design, programming and testing culminating in successful operation.

FEATURES

  1. Wifi network connection
  2. 100 / 240VAC input voltage
  3. 4 Output relays (Maximum 10A)
  4. Power indicator LED
  5. 4 LED´s power indicator of the relay
  6. Programming header
  7. Reset button

Step 1: Components and Tools

Components

  1. 3 Resistors 0805 of 1k ohm
  2. 5 Resistors 0805 of 220 ohms
  3. 2 Resistors 0805 of 10k ohms
  4. 1 Resistor 0805 of 4.7k ohms
  5. 2 Capacitors 0805 of 0.1uf
  6. 2 Capacitors 0805 of 10uf
  7. 4 Diodes ES1B or similar of 100v 1A SMA package
  8. 1 Voltage regulator AMS1117-3.3
  9. 4 Green LED´s 0805
  10. 1 Red LED 0805
  11. 4 Transistors NPN MMBT2222A or similar SOT23 package
  12. 1 ESP 12-E Wi-Fi module
  13. 1 Power Supply HLK-PM01
  14. 1 Switch tactile SMD
  15. 1 Pin header of 6 positions
  16. 5 Terminal Block of 2 positions 5.08mm pitch
  17. 4 Relays of 5VDC

Tools

  1. Soldering station or cautin of 25-30 Watts
  2. Lead solder
  3. Flux
  4. Tweezers
  5. Desoldering wick


Step 2: Power Supply and Voltage Regulator

For the operation of the circuit 2 voltages are required, one of 3.3 VDC for the control section, and another of 5 VDC for the power section, as the idea is that the board has everything necessary for operation, use A switched source that directly supplies 5v and is powered by line voltage is essential, this saves us from needing an external power adapter and we only need to add a 3.3v linear regulator (LDO).

With the above in mind, as a source I selected the Hi-Link HLK-PM01 which has an input voltage of 100-240VAC at 0.1A and output of 5VDC at 0.6A, followed by this, I placed the widely used AMS1117-3.3 regulator already which is very common and therefore easily available.

Consulting the datasheet of the AMS1117 you will find the values for the input and output capacitors, these are 0.1uf and 10uf for the input and another equal section for the output. Lastly, I placed a power indicator LED with its respective limiting resistance, which is easily calculated applying the ohm's law:

R = 5V-Vled / Iled

R = 5 - 2 / 0.015 = 200

The current of 15mA in the led is so that it does not shine so brightly and lengthen its life time.

Step 3: Control Seccion

For this section I selected an ESP-12-E Wi-Fi module because it is small, cheap and very simple to use with the Arduino IDE. Since the module has everything necessary for its operation, the external hardware necessary for the ESP to work is minimal.

Something to keep in mind is that some GPIO of the module is not recommended to use and others have specific functions, next I will show a table about the pins and what functions they fulfill:

GPIO---------Input----------------Output-------------------------Notes

GPIO16------no interrupt------no PWM or I2C support---High at boot used to wake up from deep sleep

GPIO5-------OK-------------------OK---------------often used as SCL (I2C)

GPIO4-------OK-------------------OK---------------often used as SDA (I2C)

GPIO0-------pulled up----------OK---------------Low to FLASH mode, boot fails if pulled Low

GPIO2-------pulled up----------OK---------------boot fails if pulled Low

GPIO14-----OK-------------------OK---------------SPI (SCLK)

GPIO12-----OK-------------------OK---------------SPI (MISO)

GPIO13-----OK-------------------OK---------------SPI (MOSI)

GPIO15-----pulled to GND----OK---------------SPI (CS) Boot fails if pulled High

GPIO3-------OK-------------------RX pin----------High at boot

GPIO1-------TX pin--------------OK---------------High at boot, boot fails if pulled low

ADC0--------Analog Input-----X

The above information was found at the following link: https://randomnerdtutorials.com/esp8266-pinout-ref...

Based on the above data, I chose pins 5, 4, 12 and 14 as the digital outputs that will activate each of the relays, these are the most stable and safe for activation.

Finally I added what is necessary for programming, a reset button on that pin, a resistor connected to power on the enable pin, a resistance to ground on the GPIO15, a header that is used to connect an FTDI to the TX, RX pins and ground the GPIO0 to put the module in Flash mode.

Step 4: Power Seccion

This section will take care of using the output 3.3VDCs on the GPIO ports to activate a relay. The relays need more power than that provided by an ESP pin, so a transistor is required to activate it, in this case we use the MMBT2222A.

We must take into account the current that will pass through the collector (Ic), with this data we can calculate the resistance that will be placed at the base of the transistor. In this case, the Ic is going to be the sum of the current that passes through the relay coil and the current of the LED that indicates the ignition:

Ic = Irelay + Iled

Ic = 75mA + 15mA = 90mA

Since we have the current Ic we can calculate the base resistance of the transistor (Rb) but we need an extra data pair, the gain of the transistor (hFE), which in the case of the MMBT2222A has a value of 40 (the gain is dimensionless, therefore it does not have units of measurement) and the barrier potential (VL) that in silicon transistors has a value of 0.7v. With the above we can proceed to calculate Rb with the following formula:

Rb = [(VGPIO - VL) (hFE)] / Ic

Rb = [(3.3 - 0.7) (40)] / 0.09 = 1155.55 ohms

Based on the calculation above, I chose a resistance of 1kohm.

Finally, a diode was placed parallel to the relay coil with the cathode facing Vcc. The ES1B diode prevents reverse FEM (FEM, or Reverse Electromotive Force is the voltage that occurs when the current through a coil varies)

Step 5: PCB Design: Schematic and Component Organization

For the elaboration of the schematic and the card I used the Eagle software.

It begins by making the schematic of the PCB, it must capture each previously explained part of the circuit, it begins by placing the symbol of each component that integrates it, then the connections between each component are made, care must be taken not to connect erroneously, this error will be reflected in the circuit design causing a malfunction. Finally, the values of each component will be indicated according to what was calculated in the previous steps.

Now we can continue with the design of the card, the first thing we must do is organize the components so that they occupy the least possible space, this will decrease the manufacturing cost. Personally, I like to organize the components in such a way that a symmetrical design is appreciated, this practice helps me when routing, makes it easier and more stylish.

It is important to follow a grid when accommodating the components and route, in my case I used a 25mil grid, by IPC rule, the components must have a separation between them, generally this separation is also 25mil.

Step 6: PCB Design: Edges and Mounting Holes

Having all the components in place, we can delimit the PCB, using the "20 Dimension" layer, the perimeter of the board is drawn, ensuring that all the components are inside it.

As special considerations, it is worth mentioning that the Wi-Fi module has an antenna integrated in the PCB, to avoid attenuating the reception of the signal, I made a cut just below the area in which the antenna is located.

On the other hand, we are going to work with alternating current, this has a frequency of 50 to 60Hz depending on the country in which you are, this frequency can generate noise in digital signals, so it is good to isolate the sections that handle alternating current from the digital part, this is done by making cuts in the card near the areas through which the alternating current will circulate. The above also helps avoid any short circuit on the PCB.

Finally, mounting holes are placed in the 4 corners of the PCB in order that if you want to place it in a cabinet, the placement is easy and fast.

Step 7: PCB Design: Top Routing

We begin the fun part, routing, is to make the connections between components following certain considerations such as track width and turning angles. Generally, I first make the connections that are not power and ground, since the latter I make with plans.

Parallel ground and power planes are extremely useful in attenuating noise at the power source due to its capacitive impedance and should be spread over the widest possible area of the board. They also help us reduce electromagnetic radiation (EMI).

For the tracks we must be careful not to generate turns with 90 ° angles, neither too wide nor too thin. Online you can find tools that help us calculate the width of the tracks taking into account the temperature, the current that will circulate and the density of copper on the PCB: https://www.4pcb.com/trace-width-calculator.html

Step 8: PCB Design: Bottom Routing

On the Bottom face we make the missing connections and in the excess space we put ground and power planes, we can notice that several vias were placed that connect the ground planes of both faces, this practice is to avoid ground loops.

Ground loops are 2 points that theoretically would have to be the same potential but they really are not because of the resistance of the conductive material.

The tracks from the relay contacts to the terminals were also exposed, in order to be reinforced with solder and withstand a higher current load without overheating and burning.

Step 9: Gerber Files and Ordering the PCBs

Gerber files are used by the printed circuit board industry to manufacture PCBs, they contain all the information necessary for their manufacture, such as copper layers, solder mask, silkscreen, etc.

Exporting Gerber files from Eagle is very simple using the "Generate CAM Data" option, the CAM processor generates a .zip file that contains 10 files corresponding to the following PCB layers:

  1. Bottom Copper
  2. Bottom Silkscreen
  3. Bottom Solder Paste
  4. Bottom Soldermask
  5. Mill Layer
  6. Top Copper
  7. Top Silkscreen
  8. Top Solder Paste
  9. Top Soldermask
  10. Drill File

Now is the time to turn our Gerber files into a real PCB. Upload my Gerber files in JLCPCB to manufacture my PCB. Their service is quite fast. I received my PCB in Mexico in 10 days.

Step 10: Assembling the PCB

Now that we have the PCBs, we are ready for the assembly of the board, for this we will need the soldering station, solder, flux, tweezers and mesh to desolder.

We will start by soldering all the resistors in their respective places, we place a small amount of solder on one of the two pads, we solder the terminal of the resistance and we proceed to solder the remaining terminal, we will repeat this in each one of the resistors.

In the same way, we will continue with the capacitors and LEDs, we have to be careful with the latter since they have a small green mark that indicates the cathode.

We will proceed to solder the diodes, transistors, voltage regulator and push button. It respects the polarity marks of the diodes that it shows the silkscreen, also be careful when soldering the transistors, heating them too much can damage them.

Now we will place the Wi-Fi module, first we will solder a pin taking care that it is perfectly aligned, achieving this, we will solder all the remaining pins.

It remains only to weld all the Through-Hole components, they are the simplest for being of a larger size, just make sure to make a clean weld that has a shiny appearance.

As an additional step, we will strengthen the exposed tracks of the relays with tin, as I mentioned before, this will help the track withstand more current without burning.

Step 11: Software

For programming I installed the Arduino fauxmoesp library, with this library you can emulate Phillips Hue lights, although you can also control the brightness level, this board will only work as an on / off switch.

I leave you the link so you can download and install the library: https://github.com/simap/fauxmoesp

Use an example code from this library and make the necessary modifications for the operation of the device, I leave the Arduino code for you to download and test.

Step 12: Conclusion

Once the device is assembled and programmed, we will proceed to test its functionality, we only need to place a power cable in the upper terminal board and connect it to a socket that provides 100-240VAC, the red LED (ON) lights up, will look for the network of internet and will connect.

we enter our Alexa application and ask you to search for new devices, this process will take around 45 seconds. If everything is correct, you should see 4 new devices, one for each relay on the board.

Now it only remains to tell Alexa to turn the devices on and off, this test is shown in the video.

Ready!!! Now you can turn on and off with your personal assistant the device you want.

PCB Design Challenge

Participated in the
PCB Design Challenge

Be the First to Share

    Recommendations

    • Metal Contest

      Metal Contest
    • Make it Fly Challenge

      Make it Fly Challenge
    • First Time Author Contest

      First Time Author Contest

    Comments