> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreflux.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Using LoT Notebooks

> Use LoT Notebooks as living documentation—run LoT code, document your project, and see MQTT data all in one place.

![VS Code with a LoT notebook open showing markdown and LoT code cells, Coreflux Explorer and project tree on the left, Data Viewer below, and MQTT connection in the status bar](https://mintcdn.com/coreflux/XSOUAWqOWS4Y2_FQ/images/extension/extension-lotnb.png?fit=max\&auto=format\&n=XSOUAWqOWS4Y2_FQ\&q=85\&s=9e0cb958c924dad253919f3ff09f828a)

## Overview

**LoT Notebooks** are **living documentation**: Markdown for documentation and runnable LoT code in the same file. You **run LoT** to deploy to the **Coreflux MQTT broker**, document with **Markdown** and use the **Data Viewer** to **see what is happening on the broker**.

> [!TIP]
>
> **Write it, run it, see the result in the broker.** With LoT Notebooks and LoT VS Code Extension, document the "why," deploy the "what," and see the MQTT traffic and execution logic side by side with your notebook.

## Before you start

* **Visual Studio Code** installed
* A **Coreflux broker** installed or in another machine you can reach

## Install and connect

**1. Install the extension**

![Animated walkthrough: VS Code Extensions view, search for coreflux, install Coreflux LoT, Coreflux icon appears in the Activity Bar](https://mintcdn.com/coreflux/XSOUAWqOWS4Y2_FQ/images/extension/extension-installation.gif?s=3a2aa4cdbaf895e94e9954d6c45b7abf)

1. Open VS Code.
2. Open the Extensions view in the sidebar (or use the shortcut `Ctrl+Shift+X` on Windows/Linux, `Cmd+Shift+X` on macOS).
3. Search for **LoT Notebooks** by **Coreflux** and install it.

**2. Connect to the broker**

![VS Code: connect to MQTT broker via LoT extension; status bar shows MQTT connected](https://mintcdn.com/coreflux/XSOUAWqOWS4Y2_FQ/images/extension/extension-broker-connect.gif?s=faf63084741fb786ec1807145f691a89)

1. Click on the MQTT Connection Status on bottom left corner of your VS Code or click **Connect to Broker** in the **Data Viewer** (Coreflux sidebar).
2. Enter your broker **URL**, **username**, and **password**.

> **Example URL and default login credentials**
>
> Use a full URL such as `mqtt://localhost:1883` or `mqtts://your-host:8883` for TLS.
>
> | Setting | Example (local defaults) |
> | - | - |
> | URL | `mqtt://localhost:1883` |
> | Username | `root` |
> | Password | `coreflux` (change immediately in production) |

When you are connected, the status bar shows a green **MQTT: Connected**. If any issues occur, the status bar will become red.

## Create a LoT notebook and deploy your first LoT code

![LoT Notebook: Create and deploy to broker from a code cell; success feedback and Coreflux Explorer update](https://mintcdn.com/coreflux/XSOUAWqOWS4Y2_FQ/images/extension/extension-create-and-deploy-lot.gif?s=5cd139e03cbf0b5109848b498d7c65eb)

1. In the Activity Bar (left bar), open **Coreflux**.
2. Under **PROJECT**, use **New File**, give your **LoT Notebook** a name, and it will be created within the **workspace folder** you opened in VS Code.
3. Add a code cell from the notebook toolbar (**+ Code**). Optionally, add a Markdown cell (**+ Markdown**) to document your code.
4. Write or paste a LoT code (for example the Action below) and click **Execute Cell** icon on the cell or **Run All** option above.

   ```lot wrap theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
   DEFINE ACTION Heartbeat
   ON EVERY 10 SECONDS DO
       PUBLISH TOPIC "system/heartbeat" WITH TIMESTAMP "UTC"
   ```
5. See the data change in the **Data Viewer**, by subscribing to all topics, just like MQTT Explorer. Additionally, you can click on a data topic to see it in more detail, including a replay of the data changes.

## Next Steps

> **[How to Use a LoT Notebook in VS Code](/lot-notebooks/usage)**
>
> Workflow, cells, broker connection, commands, Git, best practices, and troubleshooting.

> **[How to Debug in LoT Extension](/lot-notebooks/debug)**
>
> Data Viewer, replay, execution trace, and debug on LoT Notebooks.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.