Skip to content

1275/esp32-serial-commander

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ESP32-S3 Serial Commander

A lightweight serial command interface for controlling ESP32-S3 GPIO pins via serial communication. All command strings are stored in flash memory (PROGMEM) to maximize available RAM for additional commands and functionality.

Hardware

  • Board: Arduino Nano ESP32 (ESP32-S3)
  • USB Connection: USB-C for power and serial communication
  • Baud Rate: 115200

Features

  • ✅ Control GPIO pins via simple serial commands
  • ✅ All command strings stored in flash memory (PROGMEM) to save RAM
  • ✅ Built-in command validation and error handling
  • ✅ Pin safety checks (avoids USB and UART pins)
  • ✅ Interactive command prompt with echo
  • ✅ System status information
  • ✅ Case-insensitive commands

Available Commands

Command Description Example
pin <num> high Set pin to HIGH pin 13 high
pin <num> low Set pin to LOW pin 13 low
pin <num> read Read digital value from pin pin 2 read
pinmode <num> output Set pin mode to OUTPUT pinmode 13 output
pinmode <num> input Set pin mode to INPUT pinmode 2 input
status Show system status (heap, CPU, etc.) status
help Display help information help

Getting Started

Prerequisites

  • Arduino IDE 2.0+ or PlatformIO
  • ESP32 board support installed
  • Arduino Nano ESP32 board definitions

Arduino IDE Setup

  1. Install the Arduino IDE from arduino.cc
  2. Add ESP32 board support:
    • Go to File → Preferences
    • Add to "Additional Board Manager URLs":
      https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
      
    • Go to Tools → Board → Boards Manager
    • Search for "esp32" and install "esp32 by Espressif Systems"
  3. Select your board: Tools → Board → esp32 → Arduino Nano ESP32

PlatformIO Setup

  1. Open the project folder in VS Code with PlatformIO extension
  2. PlatformIO will automatically detect the platformio.ini configuration
  3. Click "Build" or "Upload" in the PlatformIO toolbar

Upload and Run

  1. Connect your Arduino Nano ESP32 via USB-C
  2. Open the sketch esp32-serial-commander.ino
  3. Select the correct port under Tools → Port
  4. Click Upload
  5. Open Serial Monitor at 115200 baud
  6. Start typing commands!

Usage Examples

> pin 13 high
Pin 13: Set to HIGH

> pin 13 low
Pin 13: Set to LOW

> pinmode 2 input
Pin 2: Set to INPUT mode

> pin 2 read
Pin 2 = LOW

> status

=== System Status ===
Free Heap: 327680 bytes
Chip Model: ESP32-S3
CPU Frequency: 240 MHz

Pin Restrictions

The following pins are reserved and cannot be used:

  • GPIO 19, 20: USB communication
  • GPIO 43, 44: UART communication

All other GPIO pins (0-48) can be controlled, but always refer to your board's pinout diagram for the best pins to use.

Memory Optimization

This project uses PROGMEM to store all command strings and help text in flash memory rather than RAM. This is crucial for ESP32 projects that need to scale up with many commands, as it preserves precious RAM for runtime operations.

Benefits:

  • Command strings don't consume RAM
  • More memory available for buffers and variables
  • Easy to add many more commands without RAM concerns

Expanding the Project

To add new commands:

  1. Define command strings in flash:

    const char CMD_NEWCMD[] PROGMEM = "newcommand";
  2. Add command parsing in processCommand():

    if (compareProgmem(token, CMD_NEWCMD)) {
        // Your command logic here
        return;
    }
  3. Update the help text in HELP_TEXT

License

MIT License - See LICENSE file for details

Contributing

Feel free to submit issues and pull requests!

Author

Created for Arduino Nano ESP32 (ESP32-S3) development

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages