• 1
    Step 1

    Wiring:

    The wiring is super simple. You will have to manage to connect everything with patience to make sure everything goes where it should.

    The power supply and the ground are connected to the transformer input. The output as black and read will supply energy to the NodeMCU and the relay board as well. Bear in mind, that this is very important, you will have to adjust with the driver the output to 5 volts.

    Channels 1 to 4 from the relay board will be connected to NodeMCU pins D1, D2, D5, and D6. And last you will have to connect the power supply to the light or to the outlet and to the relay switch that will be closing or breaking the circuit to turn on and off the light.

    Adjust the Voltage of the Transformer:

    Very important to remember to adjust the transformer to 5v. This is the voltage required to feed the relay board and the NodeMCU. You can check this with a tester.

    The Arduino Code:

    You will see that the code we will be uploading to the NodeMCU is pretty simple. At the top are the WIFI and UDP libraries. The variables we will be using for the relay state. The setup configuring the pins and the beginning of the WIFI and UDP. The loop with the processing of the incoming UDP signal. In the end, the UDP feedback sending and a utility function to get a string from the char array UDP packet.

    Place All the Components in a Box:

    It would be more professional if you manage to fit everything inside some kind of rack or box.

    Testing:

    With this small piece of code, you can send the required UDP signals to trigger the different switches. Remember to make sure you are sending it to the right port.

    Coming Next:

    In future tutorials of these series, we will explore different ways we can build a device to control these switches in a super futuristic fashion

    See you in the next one and have a good one.