Uniot Docs
  • Introduction
  • Guides
    • Getting Started
    • Uniot Badge
    • Device Network
  • Foundations
    • Edge Logic Deployment
  • General Concepts
    • Primitives
    • Scripting
  • Platform
    • Dashboard
    • Sandbox
      • Visual Editor
        • Special
        • Logic
        • Math
        • Loops
        • Text
        • Variables
        • Functions
        • Primitives
      • Logger
      • Emulator
      • Control Panel
  • Advanced
    • Uniot Core
      • Scheduler
        • TaskScheduler
        • IExecutor
        • ISchedulerConnectionKit
        • Task
        • SchedulerTask
      • AppKit
        • AppKit
        • LispDevice
        • LispPrimitives
        • TopDevice
      • CBORWrapper
        • CBORObject
        • COSE
        • COSEMessage
        • ICOSESigner
      • Date
        • Date
        • SimpleNTP
      • EventBus
        • EventBus
        • IEventBusConnectionKit
        • DataChannels
        • EventEmitter
        • EventListener
        • EventEntity
        • CallbackEventListener
      • Hardware
        • Button
      • LispWrapper
        • DefaultPrimitives
        • LispHelper
        • PrimitiveExpeditor
        • unLisp
      • MQTTWrapper
        • CallbackMQTTDevice
        • MQTTDevice
        • MQTTKit
        • MQTTPath
      • Network
        • ConfigCaptivePortal
        • NetworkController
        • NetworkScheduler
      • Register
        • GpioRegister
        • ObjectRegister
        • ObjectRegisterRecord
        • Register
        • RegisterManager
        • RegisterManagerProxy
      • Storage
        • CBORStorage
        • CrashStorage
        • Storage
        • WifiStorage
      • Utils
        • Array
        • Bytes
        • ClearQueue
        • IterableQueue
        • LimitedQueue
        • GlobalBufferMemoryManager
        • Map
        • Singleton
        • TypeId
      • Credentials
    • Uniot Lisp
      • Language Description
      • Embedding Instructions
  • API
    • MQTT Convention
Powered by GitBook
On this page
  • Overview
  • Visual Editor
  • UniotLisp
  • Script Execution
  • Development Workflow
  • Example Script
  • Related Topics
  1. General Concepts

Scripting

PreviousPrimitivesNextDashboard

Last updated 2 months ago

Scripts are one of the most interesting features of Uniot - they define how your device thinks and behaves. Think of scripts as a set of instructions that tell your device what to do: when to turn the lights on, how to respond to button presses, how to process sensor data, or how to interact with other devices and dashboards via MQTT.

This flexibility means both beginners and experienced developers can create powerful IoT systems, from simple automated switches to complex networks. Whether you're just starting your IoT journey or you're a seasoned programmer, Uniot's scripting capabilities provide the tools you need to bring your ideas to life.

Overview

Scripts in Uniot can be created in two ways:

  1. Visual Editor: A drag-and-drop interface based on that allows you to create scripts visually.

  2. UniotLisp Code: Direct programming using the UniotLisp language, offering more advanced control and flexibility.

You can not use both methods simultaneously. Once you start writing UniotLisp code directly, you'll need to recompile your visual blocks to return to the Visual Editor.

Visual Editor

The Visual Editor provides an intuitive way to create scripts using a drag-and-drop interface. Read more about it in the documentation.

Ideal for:

  • Beginners learning IoT programming

  • Rapid prototyping

  • Understanding program flow visually

  • Learning UniotLisp concepts

UniotLisp

Ideal for:

  • Experienced developers

  • Complex applications

  • Performance optimization

  • Advanced program structures

Script Execution

Scripts run in an autonomous environment powered by the UniotLisp interpreter on your microcontroller. The interpreter:

  • Executes scripts in a lightweight virtual machine

  • Manages memory for embedded systems efficiently

  • Handles garbage collection automatically

  • Provides error checking and reporting

  • Maintains isolated execution environments

Scripts can:

  • Access Hardware: Interact with sensors and actuators through primitives

  • Process Data: Perform calculations and logic operations using built-in functions

  • Handle MQTT: Send and receive MQTT messages for remote communication

  • Control Timing: Manage execution frequency

Development Workflow

  1. Create: Write your script using either the Visual Editor or UniotLisp code

  2. Deploy: Upload the verified script to your device

Example Script

In this script, the following components are used:

Related Topics

UniotLisp is a lightweight Lisp implementation for embedded systems. It provides basic data types, operations, control structures, and hardware access primitives. Read more about it in the documentation.

Test: Use the built-in to verify behavior

Debug: Utilize the to track execution and identify issues

This example script toggles an LED connected to pin 0 on and off every 500ms using the dwrite primitive. Read more about primitives .

block: Defines the main execution loop

variable: Updates the value of the state variable

variable: Inverts the value of the state variable

primitive: Writes a digital value to a pin 0

: Learn about hardware interaction functions

: Detailed guide to visual programming

: Complete language documentation

Blockly
Visual Editor
UniotLisp
Emulator
Logger
here
Primitives
Visual Editor
UniotLisp
set
dwrite
not
task