Skip to content

sibeni-li/arduino_remote

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arduino Remote Control from SolveIt

Control a physical Arduino board from SolveIt (or any cloud environment) through SSH tunnels. This project enables AI assistants to write, compile, and upload Arduino sketches to hardware on your local workstation.

The magic: Your Arduino is connected to your local machine, but AI tools running in the cloud can directly flash code to it. No manual copy-paste required.

Project Overview

┌─────────────────┐      SSH      ┌─────────────┐   reverse SSH   ┌─────────────────┐      USB      ┌─────────┐
│  SolveIt Cloud  │ ───────────▶ │     VPS     │ ◀───────────── │  Workstation    │ ───────────▶ │ Arduino │
│  (AI + Tools)   │               │  (gateway)  │    (autossh)    │  (arduino-cli)  │               │  Board  │
└─────────────────┘               └─────────────┘                 └─────────────────┘               └─────────┘

Components

Component Purpose
arduino_remote.py Core Python module with 7 tool functions
setup_guide.ipynb Complete setup guide (Part 1)
module.ipynb Module development walkthrough (Part 2)
CRAFT.ipynb SolveIt auto-loading configuration (Part 3)

Available Tools

Tool Description
detect_board() Auto-detect connected Arduino port and board type
create_sketch(name, code) Write Arduino code to a temp file
send_sketch(name) Transfer sketch to workstation
compile_sketch(name) Compile using arduino-cli
compile_lib_sketch(name) Compile with external libraries
install_lib(lib_name) Install Arduino libraries
upload_sketch(name) Flash to the Arduino board

Technical Details

Languages & Libraries

  • Python 3.12+
  • Fabric - SSH connection management
  • arduino-cli - Command-line Arduino toolchain

Architecture

The system uses a reverse SSH tunnel to reach your local workstation from the cloud:

  1. Your local machine maintains an autossh connection to your VPS
  2. This creates a reverse tunnel (e.g., port 2222 on VPS → port 22 on local)
  3. SolveIt SSHs to your VPS, then through the tunnel to your workstation
  4. Commands are executed via arduino-cli on your local machine

Dependencies

fabric>=3.0

Usage Instructions

Prerequisites

  1. A VPS with SSH access
  2. arduino-cli installed on your local workstation
  3. autossh for maintaining the reverse tunnel
  4. SSH key authentication configured

Setup Steps

  1. Follow Part 1 setup guide for complete setup:

    • Installing arduino-cli
    • Configuring SSH keys
    • Setting up the reverse tunnel with autossh
    • Testing the connection
  2. Configure the module - Edit the module to match your setup (doc):

    ARDUINO_PATH = "/path/to/your/arduino/sketches"
    ARDUINO_CLI = "/path/to/arduino-cli"
    SSH_CMD = "ssh your-vps ssh -p 2222 -i /path/to/.ssh/solveit your-user@localhost"
    LIB_PATH = "/path/to/Arduino/libraries"
  3. For SolveIt integration, place files in your instance and use the CRAFT pattern to auto-load the tools.


The Story

What started as a simple SSH reverse tunnel to flash my Arduino from the cloud evolved into a complete AI-integrated tooling system.

Phase 1: The Problem

I wanted to program my Arduino from SolveIt, a cloud-based development environment, but my board was physically connected to my local workstation. Solution: set up a reverse SSH tunnel through my VPS to bridge the gap.

Phase 2: The Module

After manually running SSH commands repeatedly, I wrapped everything into a clean Python module with 7 functions: detect board, create/send/compile/upload sketches, and manage libraries. One import, and I had full Arduino control from the cloud.

Phase 3: AI Integration

The real breakthrough: making these functions available as AI tools. By adding proper type hints and docstrings, SolveIt's AI assistant could now directly call these functions autonomously.

I can now write my code by learning with AI, compile it, and upload it to my physical board in one place.

About

Arduino remote control tool for SolveIt

Resources

License

Stars

Watchers

Forks

Contributors