# How to Use PlatformIO for the ESP32-S3 N16R8
The Lonely Binary ESP32-S3 N16R8 is a powerful microcontroller board from Espressif. It includes a dual-core Xtensa LX7 processor running at up to 240MHz, integrated Wi-Fi and Bluetooth, 16MB of Quad SPI Flash, and 8MB of Octal PSRAM for memory-intensive applications like AI, displays, or data buffering. 
PlatformIO, an open-source ecosystem for IoT development, simplifies working with this board by providing a unified IDE, build system, and library manager that supports both Arduino and ESP-IDF frameworks.
This article guides you through setting up and using PlatformIO with the ESP32-S3 N16R8, from installation to uploading your first program. We'll focus on the Arduino framework for simplicity.
## Step 1: Installing PlatformIO
PlatformIO integrates seamlessly with Visual Studio Code (VS Code), making it the recommended IDE for development.
1. Download and install VS Code from the official Microsoft website[](https://code.visualstudio.com/).
2. Open VS Code and navigate to the Extensions view by pressing Ctrl+Shift+X (or Cmd+Shift+X on macOS).
3. Search for "PlatformIO IDE" and install the extension. This will download PlatformIO Core and set up the environment.
4. Restart VS Code. You'll see a new PlatformIO icon (an alien head) in the activity bar on the left.
## Step 2: Creating a New Project
1. In VS Code, click the PlatformIO icon and select "PIO Home" > "Open".
2. Click "New Project".
3. Name your project (e.g., "Lonely Binary ESP32-S3 N16R8").
4. Select the board: Search for "Espressif ESP32-S3-DevKitM-1" or similar. 
5. Choose the framework: "Arduino" for ease, or "Espressif IoT Development Framework" for advanced ESP-IDF features.
6. Click "Finish". This generates the project structure, including src/main.cpp and platformio.ini.

## Step 3:  Configuring platformio.ini
### Using UART (Left) Port
``` bash
[env:esp32-s3-devkitm-1]
platform = espressif32
board = esp32-s3-devkitm-1
framework = arduino
monitor_speed = 115200
upload_speed = 921600
board_upload.flash_size = 16MB
board_build.partitions = default_16MB.csv
build.flash_type=qio
board_build.arduino.memory_type = dio_opi
build_flags = 
              -D CORE_DEBUG_LEVEL=5
              -D BOARD_HAS_PSRAM
              -mfix-esp32-psram-cache-issue
```
#### Using USB (Right) Port
``` bash
[env:esp32-s3-devkitm-1]
platform = espressif32
board = esp32-s3-devkitm-1
framework = arduino
monitor_speed = 115200
upload_speed = 921600
board_upload.flash_size = 16MB
board_build.partitions = default_16MB.csv
build.flash_type=qio
board_build.arduino.memory_type = dio_opi
build_flags = 
              -D CORE_DEBUG_LEVEL=5
              -D BOARD_HAS_PSRAM
              -mfix-esp32-psram-cache-issue
              -D ARDUINO_USB_MODE=1
              -D ARDUINO_USB_CDC_ON_BOOT=1  
```
## Step 4: Modify main.cpp
``` cpp
#include <Arduino.h>
void setup() {
  Serial.begin(115200);
  delay(1000);  // Short delay to ensure serial is ready
  if (psramInit()) {
    Serial.println("PSRAM is enabled!");
    Serial.printf("PSRAM size: %u bytes\n", ESP.getPsramSize());
  } else {
    Serial.println("PSRAM is not enabled or not found.");
  }
}
void loop() {
  // Empty loop, or add your code here
  delay(1000);  // Prevent tight looping
}
```
Compile and Upload above code and open the serial monitor

                                
                            
                            - Choosing a selection results in a full page refresh.


 
    
    
    
