Getting Started
Prerequisites
Before you begin, ensure you have the following:
A Uniot-compatible device (e.g., ESP8266/ESP32 or Arduino-based hardware).
A computer with internet access.
Basic familiarity with IoT concepts (optional but helpful).
Installing Uniot Core Firmware
The best way to get started with Uniot Core is to install it via PlatformIO. Here’s how to proceed:
Create a new PlatformIO project or open an existing one.
When configuring your
platformio.ini
file for Uniot Core, pay attention to the following important details:Uniot-Core Dependency Installation: Ensure you include the
uniot-core
library in thelib_deps
section to integrate Uniot's core features. Specify the version explicitly (e.g.,uniot-io/uniot-core@^0.7.2
) to maintain compatibility.Setting Build Flags: Use the
build_flags
section to customize the firmware behavior. Key flags include:-D UNIOT_USE_LITTLEFS
to specify the file system (e.g., LittleFS or SPIFFS by default).-D UNIOT_CREATOR_ID
for identifying the firmware creator.-D MQTT_MAX_PACKET_SIZE
to adjust MQTT buffer size if necessary.-D UNIOT_LISP_HEAP
to adjust the memory size of UniotLisp environment-D UNIOT_LOG_ENABLED
and-D UNIOT_LOG_LEVEL
for enabling and configuring logging levels.
Microcontroller Selection: Define separate environments for each supported microcontroller model. For example:
ESP12E
for ESP8266-based boards.ESP32
for ESP32 boards.ESP32C3
for ESP32-C3 boards with USB-specific configurations.
Platform and Framework: Ensure that the
platform
andframework
settings match your microcontroller (e.g.,espressif8266
for ESP8266 orespressif32
for ESP32).Filesystem Configuration: Use the
board_build.filesystem
setting (e.g.,littlefs
- ifUNIOT_USE_LITTLEFS
is set to1
) to specify the filesystem type supported by Uniot Core.Default Environment: Set the
default_envs
to the environment corresponding to your primary microcontroller (e.g.,ESP12E
).USB and Debug Settings (Optional): For certain devices like the
ESP32C3
, additional USB-specific flags may be required, such as-D ARDUINO_USB_MODE=1
.
By carefully customizing these parameters, you can ensure that your development environment is optimized for Uniot Core.
As an example, we will use the ESP8266 Witty Cloud module. The module’s compact design and onboard LED's and sensors make it ideal for small IoT applications.
The following code demonstrates setting up Uniot Core to manage digital and analog inputs/outputs for this module:
This example showcases how to utilize Uniot Core features like managing digital/analog IOs and attaching a network controller. The Witty Cloud module’s capabilities, including onboard LEDs and a button, allow for a seamless testing environment.
After successful compilation, connect your device to your computer via USB.
Ensure your device is in bootloader mode before initiating the flashing process. For ESP8266, you may need to press and hold the FLASH button during power-up to enter the correct mode. Use commands like
pio run --target upload
to simplify the process with PlatformIO.
Adding Devices to the Platform
Open the Uniot Platform on your browser.
Create an account or log in if you already have one.
To add a new device to the Uniot Platform, navigate to the Devices page and select the “Add new device” button. This will open the device configuration page. Verify that your Account ID, shown in the Account Settings field, is correct (cross-check it with the information on the My Account page).
Follow the on-screen instructions:
Ensure the settings are accurate.
Power on your device.
Connect your computer or smartphone to the device’s WiFi network named “UNIOT-xxxxxxxx.”
Refresh the page to proceed with configuration steps.
Note: If you are using an Apple computer or smartphone, you will not be able to use this page after connecting to your device's WiFi. Manually copy your account ID and use it in the captive portal.
When connected to the device’s WiFi, the captive portal should automatically open. If not, you can access it manually via http://settings.uniot.io/ or the IP address 1.1.1.1.
Use the portal to select the target WiFi network for the device.
After a successful connection, rejoin your original WiFi network and locate the new device in the “Unauthorized” tab under Devices.\
It may take up to 10 seconds for the device to connect to the network and register in the Uniot. During this time, there will be no visual changes on the captive portal page. We will add visualization of the connection process in the next releases.
7. Authorize the device, assign it a recognizable name, and complete the setup.
Congratulations, your new uniot-device is now added to the platform!
Your First Automation Script
For an easy start, navigate to the Sandbox page and locate the welcome script titled “My First Script”.
This visual script generates the following code, which is executed directly on the device:
This script uses several blocks to demonstrate key concepts of automation:
State Variable Initialization: The block initializes a
state
variable asfalse
. This variable tracks the LED's on/off status.Run Task Block: Configured to run every 50 milliseconds indefinitely (as the
times
parameter is set to0
), ensuring the script continuously checks button activity and event triggers.Button Check Block: Monitors if the button (that occupies the register with index
0
, for details check the list of registers, which can be found in the device information on the Devices page) is clicked. When clicked, a global event namedled
is generated. This event can be heard by other devices in the network as well as by the dashboard, emitted with the toggled state value (not state
).Event Trigger Block: Responds to the
led
event by updating thestate
variable to the event's value and writing the new state to pin with registered index0
, controlling the LED.
Last updated