> ## 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.

<Frame caption="LoT Notebook workspace in VS Code: editor, Coreflux Explorer, Project, and Data Viewer">
  <img src="https://mintcdn.com/coreflux/XSOUAWqOWS4Y2_FQ/images/extension/extension-lotnb.png?fit=max&auto=format&n=XSOUAWqOWS4Y2_FQ&q=85&s=9e0cb958c924dad253919f3ff09f828a" alt="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" width="1920" height="1032" data-path="images/extension/extension-lotnb.png" />
</Frame>

## 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.
</Tip>

## Before you start

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

## Install and connect

<Steps>
  <Step title="Install the extension">
    <Frame caption="Extensions marketplace: search for Coreflux and install LoT Notebooks">
      <img src="https://mintcdn.com/coreflux/XSOUAWqOWS4Y2_FQ/images/extension/extension-installation.gif?s=3a2aa4cdbaf895e94e9954d6c45b7abf" alt="Animated walkthrough: VS Code Extensions view, search for coreflux, install Coreflux LoT, Coreflux icon appears in the Activity Bar" width="1280" height="688" data-path="images/extension/extension-installation.gif" />
    </Frame>

    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.
  </Step>

  <Step title="Connect to the broker">
    <Frame caption="Connect to the broker: pick credentials or connect from the Data Viewer">
      <img src="https://mintcdn.com/coreflux/XSOUAWqOWS4Y2_FQ/images/extension/extension-broker-connect.gif?s=faf63084741fb786ec1807145f691a89" alt="VS Code: connect to MQTT broker via LoT extension; status bar shows MQTT connected" width="1280" height="688" data-path="images/extension/extension-broker-connect.gif" />
    </Frame>

    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**.

    <Accordion title="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) |
    </Accordion>

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

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

<Frame caption="Create and deploy your first LoT">
  <img src="https://mintcdn.com/coreflux/XSOUAWqOWS4Y2_FQ/images/extension/extension-create-and-deploy-lot.gif?s=5cd139e03cbf0b5109848b498d7c65eb" alt="LoT Notebook: Create and deploy to broker from a code cell; success feedback and Coreflux Explorer update" width="1280" height="688" data-path="images/extension/extension-create-and-deploy-lot.gif" />
</Frame>

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 theme={null}
   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

<CardGroup cols={2}>
  <Card title="How to Use a LoT Notebook in VS Code" icon="book" href="/lot-notebooks/usage">
    Workflow, cells, broker connection, commands, Git, best practices, and troubleshooting.
  </Card>

  <Card title="How to Debug in LoT Extension" icon="bug" href="/lot-notebooks/debug">
    Data Viewer, replay, execution trace, and debug on LoT Notebooks.
  </Card>
</CardGroup>
