Variables in Ubidots are the fundamental building blocks for your IoT application. They store the timestamped "dots" or data points you send to Ubidots from your IoT devices. Each variable belongs to a device and can store historical data, allowing you to monitor, analyze, and visualize trends over time. This article explains everything you need to know about variables in Ubidots, including their creation, fields, and advanced features.
How to Create a Variable
You can create variables in Ubidots in three ways:
1. Automatically, through the API (Recommended)
Every time you send data to a device that doesn't exist, Ubidots automatically creates both the device and the variables sent. This method is fast and scalable, especially for applications with multiple variables or devices.
2. Manually, in the Web Application
Go to the Devices section in your Ubidots account.
Select a device or create a new one.
Click Add Variable and fill in the required fields, such as the variable name.
3. Manually, through the API
You can create variables by sending an HTTP POST request to the Ubidots API. Refer to Ubidots API documentation for detailed instructions and examples.
Variable's Fields
The following fields can be edited through the web application. Please refer to our API docs to learn about hidden fields such as the variable's color:
Field | Description |
Name | The variable's name. |
Description | (Optional) A brief summary or note about the variable’s purpose or usage. |
Icon | A visual representation of the variable for easier identification in dashboards. Use any Fontawesome v6 icon label. |
API Label | A unique identifier used to reference the variable in API calls. |
ID | A system-generated unique identifier for the variable. |
Allowed Range | (Optional) The minimum and maximum acceptable values for this variable. Helps to filter out invalid or out-of-range data |
Tags | (Optional) Keywords that categorize and group variables for easier filtering and organization. |
Pre-processing | (Optional) Slope and Offset applied to incoming data to adjust the values dynamically. |
Unit | (Optional) The measurement unit for the variable (e.g., °C, %, kg). |
Last Activity | The timestamp of the last data point received for this variable |
"Allowed Range" Feature
Setting an allowed range ensures the integrity of your data by filtering out values that are too high, too low, or otherwise invalid. For example, a temperature sensor might only send readings between -40°C and 125°C. By defining this range, you can prevent outlier values from distorting your data analysis or triggering incorrect alerts.
Pre-Processing: Adding Slope and Offset
Pre-processing allows you to adjust the raw data values using a simple linear transformation:
Adjusted Value = (Raw Value × Slope) + Offset
For example, imagine a sensor sends raw voltage data ranging from 0–5V, but you want the data displayed in terms of pressure, ranging from 0–100 PSI.
Set the slope to 20 (100 PSI ÷ 5V) and the offset to 0, so the incoming raw value is automatically scaled to match the desired range.
This feature simplifies downstream calculations and ensures consistency in your data.
For more advanced calculations, you can leverage Synthetic Variables.
Exporting Ubidots Variables Data
Ubidots makes it easy to export variable data for external analysis or record-keeping. You can export data in two ways:
1. Through the Web Application
Navigate to the Devices section and select a device.
Click on the variable you want to export.
Use the Export Data option to download the data as a CSV file.
2. Through the API
Use our API to get a variable's data: