Arduino Library Template

Professional development framework for creating production-ready Arduino libraries in minutes. Automated CI/CD, setup scripts, and full Arduino Library Manager compliance included.

Library Manager Ready 🤖 CI/CD Automated 5 Min Setup 📦 MIT Licensed

Key Features

Everything you need to create professional Arduino libraries, all in one template.

🚀

Automated Setup

PowerShell and Bash scripts automatically configure your library, rename files, and update metadata in seconds.

🔧

CI/CD Pipeline

GitHub Actions workflow tests your library across AVR, SAMD, and megaAVR architectures automatically on every commit.

📚

Complete Documentation

Developer guides, quick references, example documentation, and contribution guidelines all included and ready to customize.

Library Manager Compliant

Follows Arduino Library Specification perfectly. Ready for submission to Arduino Library Manager without modifications.

🎯

Professional Structure

Proper folder layout with src/, examples/, extras/, and docs/ directories. Issue and PR templates included.

💡

Working Examples

Functional example sketches demonstrating basic and advanced usage. Learn by example, customize for your needs.

Quick Start

Get your Arduino library up and running in under 5 minutes.

  • Create Repository Click the "Use this template" button on GitHub to create your own repository based on this template.
  • Clone Locally Clone your new repository to your local machine:
    git clone https://github.com/yourusername/your-library.git
    cd your-library
  • Run Setup Script Execute the automated setup script for your platform:
    # Windows (PowerShell)
    ./setup-library.ps1
    
    # Linux/Mac
    chmod +x setup-library.sh
    ./setup-library.sh
  • Implement Your Library Write your library code in the src/ directory. The template provides a working example to get you started.
  • Test Locally Create a ZIP file and install it in Arduino IDE to test your library before publishing.
  • Push and Publish Push to GitHub, create a release tag, and submit to Arduino Library Manager. CI automatically validates your code!
💡 Pro Tip: The setup scripts will prompt you for your library name, author details, and description. They automatically update all files with your information.

Installation

For Template Users

Creating a new library from this template:

  1. Click "Use this template" button on the GitHub repository
  2. Name your repository (should match your library name)
  3. Clone and run the setup script as shown in Quick Start

For Library Users

Installing a library created from this template:

Via Arduino Library Manager (Recommended)
1. Open Arduino IDE
2. Go to Sketch → Include Library → Manage Libraries
3. Search for the library name
4. Click Install
Manual Installation
1. Download the library ZIP from GitHub releases
2. Arduino IDE → Sketch → Include Library → Add .ZIP Library
3. Select the downloaded ZIP file
4. Restart Arduino IDE

Setup Scripts

The template includes automated setup scripts that handle all the configuration for you.

What They Do

  • Rename library files from LibraryName to your actual library name
  • Update library.properties with your author details and description
  • Modify all code references and include statements
  • Update example sketches to use your library name
  • Configure keywords.txt for Arduino IDE syntax highlighting
  • Update documentation with your information

Script Options

Two scripts are provided for cross-platform compatibility:

setup-library.ps1

For Windows users
PowerShell script with interactive prompts. Handles Windows line endings and paths correctly.

./setup-library.ps1

setup-library.sh

For Linux/Mac users
Bash script with the same functionality. Uses Unix line endings and paths.

chmod +x setup-library.sh
./setup-library.sh
⚠️ Important: Run the setup script before making any changes to the template files. It will prompt you for all necessary information.

Folder Structure

The template follows the Arduino Library Specification 1.5 format.

arduino-library-template/
├── .github/                  # GitHub specific files
│   ├── ISSUE_TEMPLATE/      # Bug report & feature request templates
│   ├── workflows/           # GitHub Actions CI/CD
│   └── PULL_REQUEST_TEMPLATE.md
├── docs/                     # Documentation files
│   ├── DEVELOPER.md         # Technical documentation
│   └── QUICK_REFERENCE.md   # Command reference
├── examples/                 # Example sketches
│   ├── BasicUsage/
│   └── AdvancedUsage/
├── extras/                   # Additional resources
│   └── wiring.txt           # Circuit diagrams
├── src/                      # Library source code
│   ├── LibraryName.h        # Public API header
│   ├── LibraryName.cpp      # Implementation
│   └── internal/            # Internal utilities
├── .gitignore               # Git ignore rules
├── CHANGELOG.md             # Version history
├── CONTRIBUTING.md          # Contribution guidelines
├── keywords.txt             # Arduino IDE keywords
├── library.properties       # Arduino metadata
├── LICENSE                  # MIT License
├── README.md                # Main documentation
├── setup-library.ps1        # Windows setup script
└── setup-library.sh         # Unix setup script

Key Directories Explained

Directory Purpose Required?
src/ Library source code (.h and .cpp files) Yes
examples/ Example sketches demonstrating usage Highly Recommended
extras/ Additional documentation, images, datasheets Optional
docs/ Extended documentation and guides Optional
.github/ GitHub-specific files (CI, templates) Optional

CI/CD Pipeline

Automated testing with GitHub Actions ensures your library works across multiple Arduino platforms.

What Gets Tested

  • Arduino AVR - Arduino Uno, Mega, Nano
  • Arduino SAMD - MKR boards, Zero
  • Arduino megaAVR - Uno WiFi Rev2

When Tests Run

  • Every push to the main branch
  • Every pull request
  • Manual workflow dispatch

What Gets Checked

  • All example sketches compile without errors
  • Library structure is valid
  • Code compiles for multiple architectures
  • No syntax or compilation warnings
✅ Automated Reports: Compilation results are automatically uploaded as artifacts. Review them in the Actions tab after each run.

Adding More Architectures

To test on additional platforms, edit .github/workflows/arduino-ci.yml:

- arduino-platform: "esp32:esp32"
  fqbn: "esp32:esp32:esp32"
  artifact-name: "esp32-esp32"

Examples

The template includes working example sketches to demonstrate library usage.

BasicUsage.ino

Demonstrates the most basic usage of the library - initialization and simple operations.

#include <LibraryName.h>

LibraryName myDevice(13);

void setup() {
  myDevice.begin();
  myDevice.activate();
}

void loop() {
  delay(1000);
  myDevice.deactivate();
  delay(1000);
  myDevice.activate();
}

AdvancedUsage.ino

Shows more complex usage patterns like managing multiple instances.

📚 More Examples: For detailed information about creating examples, see the Examples Guide.

Publishing to Arduino Library Manager

  • Create a Release Tag your code with a version number (semantic versioning):
    git tag v0.1.0
    git push origin v0.1.0
  • Submit to Library Registry Fork the arduino/library-registry repository and add your library URL to repositories.txt
  • Wait for Approval Arduino team reviews submissions (typically 3-7 days). Once approved, your library appears in Arduino Library Manager!
  • Versioning Guidelines

    Follow Semantic Versioning: MAJOR.MINOR.PATCH

    • PATCH (0.0.1) - Bug fixes, no API changes
    • MINOR (0.1.0) - New features, backwards compatible
    • MAJOR (1.0.0) - Breaking changes, incompatible API