> For the complete documentation index, see [llms.txt](https://docs.chassy.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.chassy.io/reference/chassy-component-for-esp32.md).

# Chassy Component for ESP32

## Overview

The Chassy Component is a library for ESP32 devices that enables seamless integration with the Chassy services. It provides functionality for device registration, authentication, and over-the-air (OTA) firmware updates. This component simplifies the process of connecting ESP32 devices to the Chassy cloud, allowing for remote management and monitoring of your fleet.

### Key Features

* Automatic device registration and enrolment
* Secure authentication and communication using modern TLS protocols
* OTA firmware updates
* Status reporting to the Chassy endpoint

### Requirements

1. **ESP-IDF v5.5 or later**: This component is built and tested with ESP-IDF version 5.5. Earlier versions may not be fully compatible.
2. **OTA Partition Configuration**: Your device must have at least 2 OTA partitions of 1 MB each to support the OTA update functionality.
3. **NVS Storage**: A minimum of 4 KB of NVS (Non-Volatile Storage) must be reserved for Chassy component use. This storage is used for maintaining device credentials, deployment information, and update status.
4. **Network Connectivity**: The device must have Wi-Fi or Ethernet connectivity to communicate with Chassy services.

### Prerequisites

1. **ESP-IDF**: This component requires the Espressif IoT Development Framework (ESP-IDF). Follow the [official installation guide](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/index.html) to set up ESP-IDF on your development machine.
2. **Bootstrap Token**: A bootstrap token from your Chassy account is required for initial device enrolment.

### Configuration

The component requires the following configuration in your device's Non-Volatile Storage (NVS):

* `hostname`: A unique name for your device
* `bootstrap_token`: The token obtained from your Chassy account
* `endpoint`: Set to either "development" or "production" depending on your environment

### Integration Guide

To include the Chassy component in your ESP32 project:

1. Add the Chassy component as a library to your project
2. In your initialization function, call:

   ```cpp
   chassy::ChassyDeviceManager::run_on_init(device_ip_address);
   ```
3. In your main loop, periodically call:

   ```cpp
   chassy::ChassyDeviceManager::update_chassy_endpoint(device_ip_address);
   ```
4. To check for and perform updates when available:

   ```cpp
   auto status = chassy::ChassyDeviceManager::update_chassy_endpoint(device_ip_address);
   if (status == chassy::ChassyDeviceManager::CheckUpdateStatus::kUpdateAvailable) {
       chassy::ChassyDeviceManager::perform_update(device_ip_address);
   }
   ```

### Enrollment

For a guide on how to enroll a new ESP32 device, please follow [this guide](/user-guides/fleet-user-guide/enrolling-machines/enrolling-esp32-devices.md).
