EzloPi AC lamp setup with relay and a momentary switch

NOTE: Before moving into this example it is very necessary to know about the device registration, provisioning and converting the ESP32 device into an EzloPi device along with knowledge of Ezlogic desktop app. All these information can be collectively found in EzloPi User manual document.

1 About this example

This example aims to demonstrate how a user can interface a momentary switch for controlling the lamp. With using the switch it is not necessary that we need to have mobile app, however changes in status of the Lamp are updated in the app in real time.

2 Circuit setup

For interfacing and controlling the lamp we will be needing following components:

  1. An AC lamp with lamp holder and wires to connect to AC mains.
  2. A momentary switch with 10K OHM, ¼ watt of resistor
  3. ESP32 device for converting it into EzloPi smart device
  4. A properly designed relay module
  5. Power source for ESP32 as well as relay module

The wiring diagram can be represented as:

Two Circuit Setup

In the same way connection with the components has been made as:

Components Connections

3 Interfacing a relay for an AC LAMP using Ezlogic Desktop app:

Note that before moving to add any device a new device should be added and which should be accessible from Vera mobile app.

Ezlogic Desktop app

Also note that for this example purpose we will be adding the Relay under EzloPi serial 100004006.

Device addition will be started with the button Add device in the UI as above. From the dropdown shown at 2 select LED at the moment since LED option can be used for toggling the GPIO which works for triggering the relay.

Adding Device

Select Output pin for LED, in this example GPIO 2 has been selected. GPIO 2 at output means RELAY is expected to be connected at GPIO2 of ESP32 and the same pin will be controlled via Vera mobile app. The button can either be enabled or disabled.

Upon enabling the button user will have extra control facility with a button connected at GPIO5. The purpose of a push button (one click switch) is to turn ON and OFF the specified output i.e. GPIO2 in this case. Please enable the button checking the BUTTON ENABLE checkbox as shown in the picture above.

After a LED has been configured and pressed the Apply button we get this device added at the list.

LED configuration

After it, we write this GPIO configuration to the ESP32 (EzloPi) device connected to the PC with pressing Set Config Button and after the configuration update has been written we will get the success message as:

GPIO configuration

Note: After configurations has been set/updated to the device please reboot the ESP32 device.

Now the relay has been added and it will automatically be updated in the device with the ID we registered as following the section 6 of user manual titled as “Interfacing a device” and can be visible in the app as a LAMP as shown below on device dashboard of the app. Note again the device ID in this example is 100004006.

Interfacing a device

Before that let us move forward knowing about the app.

4 Vera Mobile app

You can download Vera android and iOS app from respective store searching for Vera Mobile.

iOS App : Click to Download

Android App : Click to Download

Install the app and open it.

Vera Mobile app

Create an account in ezlo cloud using the vera app. Proceed for login if you have an existing account.


The device added explained in section 5, Registration of user manual titled as “Registration of a new EzloPi device into Cloud and provisioning the device” will appear after getting logged-in to the app as below:

Set a Location

Tap into the device for entering into the device dashboard. You will see your dashboard as:

Device Dashboard

For checking the device that has been just added you can navigate to devices list from the menu as:

Devices List

The added device will appear as:

Added Device Dashboard

This is the device that has been added as instructed in section 2 of user manual titled as “Interfacing a device”.

We can control the device from this UI itself or we can also add it in the dashboard shortcut for easy access and status.

For such we can add the device into the dashboard shortcut as:

1. Navigate to the setting on top Right corner of the app

Navigate to the setting

2. Press an edit button on device widget

Added Device Dashboard

3. A new dialogue will appear with all the interfaced devices. Currently we have only one device in the name of LED. Select the device checking the radio button on the left to the Lamp icon and press save. Which will close the dialogue and you will see the lamp being added in the dashboard widget shortcut.

4. After it press done as shown in 5 and now this process completes.

5 Controlling the lamp from the app:

Now we have completed all our setup and can control the lamp using the mobile app wherever we are located at.

With the dashboard shortcut as mentioned in section 3 we can just press the icon for toggling the state of the device. If the device status is off the Lamp turns OFF and if the device status is ON in the dashboard icon the Lamp status will be ON on real time.

Turning ON the lamp:

Lamp should first be in OFF state. If you press on the the button, the icon changes with indicating that lamp has just Turned ON on the app. At same time changes can be seen on the hardwaer as well, i.e. device turns ON. In other words power is connected to the lamp by triggering the relay interfaced to ezlopi hardware device.

Turning ON the lamp

*Icon source: Push Button Icon

Turning OFF the lamp:

Lamp should first be in ON state.

If you press on the the button, the icon changes with indicating that lamp has just Turned OFF on the app. At same time changes can be seen on the hardwaer as well, i.e. device turns OFF. In other words power is disconnected by triggering the relay interfaced to ezlopi hardware device.

Turning OFF the lamp

*Icon source: push button Icon