Working with actuators
An IoT device acts on the physical world by using actuators, hence the name. The device generates an output as decided by the internal states of the application, which can be a reading from a sensor or a scheduled operation. The trigger for an action can also be an external command received from an external entity such as another device in the network, or perhaps its human user with a mobile application. Let's start with relays.
Using an electromechanical relay to control switching
An electromechanical relay (EMR) is an electronic device that switches its output on and off according to its input control signal. The input signal level is low voltage, so it 
can be driven by using a microcontroller unit or a system on a chip (SoC), such as ESP32. The output of an EMR is electrically isolated from its input and switches' high-voltage/high-current load connected to it. The power source of the load can be alternating current (AC) and/or DC....