In this guide, we will walk you through the process of setting up a simple Internet of Things (IoT) system using the ESP32 Microcontroller. This setup will use the IOTWORKS platform, which allows you to configure and manage your IoT devices both offline and online.
First, create your own hardware design using the ESP32 Microcontroller. If you don't have your own design, you can follow the simple pictorial diagram provided below using the listed materials.
ESP32 Microcontroller
Light Dependent Resistor (LDR) – For testing analog sensor inputs
Motion Sensor – For testing digital sensor inputs
Relay
LEDs (2)
1k Ohm Resistor
Jumper Wires
Breadboard
Pictorial Diagram on Simple Circuit
Once you have gathered the components, assemble them on the breadboard following the connections from the pictorial diagram.
In this configuration:
The LDR will connect to one of the analog input pins of the ESP32.
The Motion Sensor will be connected to a digital input pin.
The Relay will be controlled by a digital output pin.
The LEDs will be connected to Digital output pin.
The assembled breadboard should look like the image below:
Simple Circuit on Breadboard
Once your circuit is assembled, connect the ESP32 microcontroller to your computer using a USB cable. This will allow you to upload the firmware and control the device via the IOTWORKS platform.
Now that your hardware is connected, open your web browser (Chrome, Edge, or any browser that supports Web Serial). Navigate to the IOTWORKS web application using the following URL:
A login page will appear. If you already have an account, enter your credentials and log in.
If you don’t have an account yet, click Sign Up to create one and follow the on-screen instructions.
Online Login Page
Online Registration Page
Once logged in, navigate to the Firmware section from the navigation bar to upload the firmware to your ESP32 microcontroller.
In the Firmware section, find the appropriate firmware version for your device.
Click the Connect button to establish a serial connection with your ESP32.
Choose the Serial Port where your ESP32 is connected, and then follow the on-screen instructions to flash the firmware.
Note: Firmware Flashing/Installation to microcontroller available only in Computer and Browser that support web serial
Choose Serial Port after clicking the Connect Button
Click Install to flash the firmware to microcontroller
After Firmware Installations, Click Logs & Console (It's mandatory to show the Connect Wi-Fi options)
In Console Logs, you will see the device initial configurations information's, Click Back to go back to previous screen
After the firmware has been installed, the microcontroller will restart, and the option to Connect to Wi-Fi will appear. If you want to connect the ESP32 to your Wi-Fi network, follow these steps:
Select the Wi-Fi option and choose your network SSID from the list.
Enter the network password and click Connect.
Choose Connect to Wi-Fi in the Options
Configure Wi-Fi Connections
Once the ESP32 is connected to the Wi-Fi network, you will be given the option to visit the device portal.
Click Visit Device and log in using the default credentials:
Username: admin
Password: admin
After logging in, you will be directed to the Dashboard Page of the device portal, where you can configure GPIO settings, monitor sensors, and control actuators.
Click Visit Device to Access Device Portal
Device Login Page
Next, we will configure the GPIO pins of the ESP32 to match your hardware setup.
Click on the Configurations tab in the navigation bar.
In the configurations page, assign the sensors and actuators to the corresponding GPIO pins, as per the breadboard design. For example:
Light Sensor (LDR) to GPIO 33
Motion Sensor to GPIO 14
Relay to GPIO 13
LEDs to GPIO 19 and GPIO 18
Click Save to store the configuration.
GPIO Configurations based on our simple circuit design
After saving the GPIO settings, return to the Dashboard Page. You will now be able to view real-time sensor data and control actuators (e.g., turning the relay on or off) from the dashboard.
Offline Dashboard showing our GPIO Configurations
To automate the behavior of your IoT system, you can set up automation rules in the IOTWORKS platform.
Click on the Automation tab in the navigation bar.
In the automation configuration page, create a rule by selecting:
Sensor: Choose the sensor you want to monitor (e.g., Light Sensor).
Condition: Define a condition (e.g., Less than 15).
Threshold: Set the threshold value.
Actuator: Choose which actuator to control (e.g., Relay).
Action: Define the action (e.g., Turn ON or OFF).
Click Save to apply the automation rule.
Automation Rule Configurations
If you want to control and monitor the device remotely via the cloud, you need to configure the ESP32 to connect to the online platform.
Click on the Settings tab in the device portal.
Configure the following settings:
Wi-Fi: SSID and password (already configured in Step 6).
MQTT: Use the provided MQTT broker details.
IoT Cloud Settings: Enter the Host/DNS and Authentication Token (which is automatically generated when the device is added to the online platform).
Device Setting Page
MQTT is the protocol used for communication between your IoT device and the IOTWORKS platform.
Access MQTT Settings:
Navigate to the Settings page and locate the MQTT Settings section.
Input the following details:
MQTT Broker URL: mqtt.iotworks.tech
Port: 1883
Username: Leave this field blank.
Password: Leave this field blank.
Save Settings:
Once you have filled in the required fields, click the Save button to store your MQTT settings.
MQTT Configurations
To connect your ESP32 device to the IOTWORKS online platform, you need to add the device to the web application and generate an authentication token.
Navigate to the Devices Section:
Click on the Devices tab in the navigation bar.
Add a New Device:
Click the Add New Device button.
In the pop-up modal, enter the Device Name and Description. For example, name it Simple IoT Test Circuit.
Click Save.
Add New Device in the Device Management page
3. Copy the Authentication Token:
Once the device is added, an Authentication Token will be generated automatically.
Copy this token, as it will be used to verify the microcontroller in the IoT Cloud Settings.
Device will be added, and Authentication Token will be generated automatically
Now that you have the authentication token, you can complete the cloud settings on your device.
Go to IoT Cloud Settings:
In the device portal (local web interface), go to Settings and locate the IoT Cloud Settings section.
Input the following details:
Host/DNS: https://app.iotworks.tech
Authentication Token: Paste the token you copied from the web application.
Save Settings:
Click the Save button to store the cloud settings.
Restart the Microcontroller:
After saving the settings, restart your microcontroller. This will apply the cloud configurations and initiate the connection to the IOTWORKS online platform.
Fill-out the input fields as shown in the above image, Copy & Paste the token and click Save button, then restart the Microcontroller for the microcontroller connect to our web application
After restarting the device, check its status in the IOTWORKS web application.
Navigate to the Devices Section:
In the web application, go to the Devices section.
Check Device Status:
If the device is successfully connected, the status will change to Online.
You can now manage and control your device remotely from the IOTWORKS platform.
Device Status in Device Management Page would change to Online if the microcontroller successfully connected to out platform
Now that your device is connected to the IOTWORKS platform, you can configure the GPIO pins online.
Go to GPIO Configurations:
In the web application, click on the GPIO tab in the navigation bar.
Select Your Device:
Click on the device name you just added to configure the GPIO pins.
Configure the GPIO Pins:
Assign the sensors and actuators to the corresponding GPIO pins. For example:
Light Sensor (LDR): GPIO 33
Motion Sensor: GPIO 14
Relay: GPIO 13
LEDs: GPIO 19 and GPIO 18
Save the Configuration:
Once the pins are configured, click Save to store the GPIO settings.
Online GPIO Configurations
To automate actions based on sensor data, you will now configure automations via the IOTWORKS platform.
Navigate to the Automation Section:
In the web application, click on the Automation tab in the navigation bar.
Add a New Automation Rule:
Click the +Add New button to create a new rule.
In the pop-up modal, configure the automation rule by setting the following:
Sensor: Select the sensor to trigger the automation (e.g., Light Sensor).
Condition: Set the condition (e.g., Greater than 25).
Actuator: Choose the actuator (e.g., Relay).
Action: Set the action (e.g., Turn Off or On).
Enable the Rule:
Check the box to Enable Rule.
Click Save Automation to apply the automation rule.
Add New Automations Rule
Once you have saved the automation rule, you can test the functionality.
Monitor Sensors and Actuators:
Go to the Device Dashboard and check the real-time readings from your sensors.
Manually trigger conditions to see if the automation rules respond as expected (e.g., when the light level drops below 15, the relay should turn on).
Control Actuators:
You can also manually toggle actuators from the dashboard to ensure they are functioning correctly.
Individual Device Dashboard Online
Congratulations! You have successfully connected your IoT device to the IOTWORKS platform, configured GPIO, and set up automation rules. You can now monitor and control your devices from anywhere, using the IOTWORKS online platform. Feel free to explore other features of the platform and continue testing new setups.
Don't forget to provide feedback to help us improve the platform as you continue to develop and innovate with IOTWORKS!