# Licensing and Setting up Trillbit library

## Step 1: Access your TrillBit developer account

1. Create or login to your TrillBit Developer account at: <https://developers.trillbit.com/>
2. On the home page, you will see platforms supported with 15 evaluation licenses for platforms- Android, iOS, Embedded and ESP-32 S3.&#x20;
3. On selection of the ESP-32 platform, you will see:&#x20;
   1. Section to download Credentials file-credentials.json for licensing the Trillbit SDK for your application.&#x20;
   2. Section with a link to Github page for Trillbit SDK for ESP-32\
      Pre-compiled binary <https://github.com/Trillbit-Inc/TrillbitSDK-ESP32-S3/blob/master/pre_built_bins/trillbit_esp32_sdk_demo_v1.0.bin>  is available to download from the [github repository](https://github.com/Trillbit-Inc/TrillbitSDK-ESP32-S3/tree/master/pre_built_bins)
4. Host source code <https://github.com/Trillbit-Inc/TrillbitSDK-ESP32-S3> page would contain:
   1. Pre-compiled library for the platform ESP-32 S3.
   2. Demo application for ESP-32 S3 and corresponding source code. &#x20;
   3. Python script for licensing procedure.&#x20;
   4. Supporting documents and User guides.

## Step 2: Get your credentials file

This credentials file is required for the authentication and licensing of your Trillbit SDK.&#x20;

Please access your credentials file and download here- <https://developers.trillbit.com/>

## Step 3: Setup ESP-32 S3- Flashing from Pre-built Binary&#x20;

### 1. For Windows <a href="#markdown-header-flashing-from-pre-built-binary-windows" id="markdown-header-flashing-from-pre-built-binary-windows"></a>

* Download the ESP32 flash tool from <https://www.espressif.com/sites/default/files/tools/flash_download_tool_3.9.4.zip>
* On Terminal, execute a 'git clone <https://github.com/Trillbit-Inc/TrillbitSDK-ESP32-S3.git>' to create a copy of the TrillbitSDK-ESP32-S3 repository on your machine, \
  OR&#x20;
* Download the source code from <https://github.com/Trillbit-Inc/TrillbitSDK-ESP32-S3>, as a .zip file.&#x20;
* Pre-built demo binary is located in repo at *pre\_built\_bins\trillbit\_sdk\_demo\_v1.0.bin*
* Run the flash tool and select start up settings as shown below

![Flash tool settings](https://bytebucket.org/trillbitoutsourcedprojects/mtfsk-esp32-s3-box/raw/905f6b646b4e1d80eaa2c9de9e8bfbc4cf2932d6/images/esp32s3_flash_tool_1.jpg?token=785491e16d9698a54d90cb75d11b27b4b02067d6)

* Browse for the downloaded pre-built binary file and select SPI flash download settings as shown below

![SPI flash download settings](https://bytebucket.org/trillbitoutsourcedprojects/mtfsk-esp32-s3-box/raw/905f6b646b4e1d80eaa2c9de9e8bfbc4cf2932d6/images/esp32s3_flash_tool_2.jpg?token=5ebb3c61a1477d8eb442a6ed6f8b933bc0723389)

* Click *Start*. Once the download progress shows *Finish* status, reboot s3-box by pressing the *Reboot* switch (below USB connector).

### 2. For Mac OS and Linux:

1. Install python3 on your system, if not already installed.&#x20;
2. Connect your development board to the computer through a USB Type-C cable.
3. Install 'esptool' by entering the following command in Terminal (pip3 can be specified as pip):\
   \&#xNAN;**`pip3 install esptool`**&#x20;
4. On Terminal, execute a 'git clone <https://github.com/Trillbit-Inc/TrillbitSDK-ESP32-S3.git>' to create a copy of the TrillbitSDK-ESP32-S3 repository on your machine.&#x20;
5. At the top directory of the cloned repository, execute the following:&#x20;

```
python3 -m esptool --chip esp32s3 write_flash 0x0 
pre_built_bins/trillbit_sdk_demo_v1.0.bin

* Run with sudo in commands if permission is denied. 
```

&#x20; 6\. Press reset button to test the firmware.

## Step 4: Building your own custom Trillbit binary

1. Visit Espressif's Quick Start Guide- <https://github.com/espressif/esp-box#quick-start>, and follow the instructions under Quick Start section.
2. In Step 3, clone the respository for ESP-32 S3 box-  <https://github.com/Trillbit-Inc/Trillbit-esp-box> .
3. Follow rest of the steps as mentioned in the Espressif Quick Start Guide.

## Step 5: Licensing your Trillbit SDK <a href="#markdown-header-licensing" id="markdown-header-licensing"></a>

### Setup Python Environment <a href="#markdown-header-licensing" id="markdown-header-licensing"></a>

Ensure you have python3 installed. Plug the USB-C cable to S3-Box and your PC. On power up you will see license missing message on the display of s3-box.

1. Run the license\_devic&#x65;*\_*&#x73;cript.py file, at the script location- \
   TrillbitSDK-ESP32-S3/scripts/**license**/ . &#x20;
2. Provide the path to the credentials file downloaded.&#x20;

If not downloaded already, please download the credentials.json file from the TrillBit dev-portal.&#x20;

For eg. At the top directory of your TrillbitSDK-ESP32-S3 clone directory, you would need to execute the following:&#x20;

```
>cd scripts/license/
>python3 license_device_script.py <path-to-thecredentials-file>
```

3\. The license\_d*evice\_*&#x73;cript.py file will proceed to license your board.&#x20;

4\. You will now see the success message. Your device is now licensed and ready to be integrated with the Trillbit library.&#x20;

## Step 6: Using the Demo <a href="#markdown-header-using-the-demo" id="markdown-header-using-the-demo"></a>

On successful licensing, you would see the following SDK demo display

![Demo main display](https://bytebucket.org/trillbitoutsourcedprojects/mtfsk-esp32-s3-box/raw/905f6b646b4e1d80eaa2c9de9e8bfbc4cf2932d6/images/esp32s3_demo_1.jpg?token=8e5e1c155eb9b1e0eea5a5476d6223e777d35374)

* Use the Mobile app to send data over sound.
* Received message would be displayed on the screen. Number prefixing the message increments for each received message.
* Tap *Echo* button to send back the last received message. If no last message is present then a default message would be sent.
* Tap *Stop* to stop and de-initialize the SDK.
* If stopped, tap *Start* to re-initialize the SDK to start receiving messages again.
* You can also view the console messages over USB/UART. Use the *monitor* tool of *idf*

```
$ cd ~/trillbit
$ . esp-idf/export.sh
$ cd mtfsk-esp32-s3-box
$ idf.py -p </dev/tty?> monitor
```

## Step 7: Sending data from TrillConnect

You may use the TrillApp - [TrillIoT](https://trillbit.gitbook.io/trillbit-sdk/demo-applications/trilliot) , as the sender configuration your mobile phone, to send messages to the ESP32-S3.

{% content-ref url="../../../demo-applications/trilliot" %}
[trilliot](https://trillbit.gitbook.io/trillbit-sdk/demo-applications/trilliot)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://trillbit.gitbook.io/trillbit-sdk/esp-32-support/trill-sdk-for-esp-32/setup-guide/licensing-and-setting-up-trillbit-library.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
