// esp32

Firmware

The ESP32 firmware that runs on Desk Buddy — listens for MQTT commands, drives servos, captures photos, and updates itself over the air.

Overview

Desk Buddy firmware is a C++ Arduino sketch targeting the ESP32. It connects to your Wi-Fi network, subscribes to an MQTT topic, and dispatches incoming JSON commands to action handlers — one per capability: servo control, base rotation, gripper, inverse kinematics, camera, OTA updates, and more.

The full source is MIT-licensed and available on GitHub:

View Firmware Source

Requirements

Hardware

ESP32-CAM (AI Thinker or compatible) with camera module

Arduino IDE 2.x

Download from arduino.cc

ESP32 Board Package

Espressif ESP32 — install via Arduino Board Manager

MQTT Broker

Any broker on your network (Mosquitto, HiveMQ, etc.)

Arduino Libraries

Install via Tools → Manage Libraries:

  • PubSubClient — MQTT client
  • ArduinoJson — JSON parsing and serialization
  • ESP32Servo — servo control on ESP32 GPIO pins
  • esp_camera, HTTPClient, Preferences — included in the ESP32 board package

Flashing with Arduino IDE

  1. 1
    Clone the repo
    git clone https://github.com/doeswork/desk_buddy.git
  2. 2
    Open the sketch

    Open firmware/firmware.ino in Arduino IDE. All companion .cpp/.h files in the same folder load automatically.

  3. 3
    Select your board

    Tools → Board → ESP32 Arduino → AI Thinker ESP32-CAM. Set upload speed to 115200.

  4. 4
    Enter flash mode & upload

    Hold IO0 to GND while pressing reset to enter flash mode. Click Upload, then reset the board when flashing completes.

  5. 5
    Configure Wi-Fi & MQTT

    On first boot the ESP32 broadcasts a Wi-Fi AP named DeskBuddy-Setup. Connect to it and visit 192.168.4.1 to enter your Wi-Fi credentials and MQTT broker address. These are saved to flash — you only need to do this once.

  6. 6
    Verify

    Open Serial Monitor at 115200 baud. You should see Wi-Fi and MQTT connections established, followed by the firmware listening for commands.

Brownout resets? The ESP32-CAM draws significant current when the camera is active. If you see brownout messages in Serial Monitor, use a 5V/2A minimum supply or add a decoupling capacitor across the power rails.

// mqtt

Sending Commands

Once flashed, Desk Buddy is controlled entirely over MQTT — the web app, your own scripts, or any MQTT client can all send commands using the same JSON protocol.

MQTT Reference →
📡 JSON over MQTT