FlashForgePrinterApi – Java Library for Controlling FlashForge 3D Printers Over the Network

Java Nov 19, 2020
Slugger2k/FlashForgePrinterApi
Network printer API for FlashForge Adventurer 3 and maybe others. - Slugger2k/FlashForgePrinterApi

The FlashForgePrinterApi is an open-source Java library that enables developers to discover and control FlashForge 3D printers—particularly the Adventurer 3—over the local network using raw TCP commands. Created by Slugger2k, this library provides access to key printer functionalities like retrieving printer status, temperatures, sending print jobs, and toggling the printer's LED lighting.

🚀 Key Features

  • Automatic printer discovery via UDP broadcast
  • TCP/IP communication using FlashForge’s proprietary command protocol
  • Retrieve printer info and status including current temperatures
  • Send GX files to the printer and start prints
  • Control printer LEDs
  • Easy integration into Java applications

🔌 How It Works

The library uses undocumented commands compatible with many FlashForge printers. Once a printer is discovered on the network, it establishes a TCP connection and sends raw commands like M28, M29, INFO, etc.

Here’s a typical sequence:

  1. Discover the printer on the LAN.
  2. Connect using AdventurerClient.
  3. Retrieve printer metadata and temperature status.
  4. Upload and start a print job.

📦 Maven Installation

Add the library to your Java project via Maven:

<dependency>
  <groupId>de.slg</groupId>
  <artifactId>FlashForgePrinterApi</artifactId>
  <version>0.0.5</version>
</dependency>

✅ Example Code

Here is a complete and corrected example that demonstrates printer discovery, status checking, and sending a print job:

import de.slg.mavlib.FlashForgeDiscoverClient;
import de.slg.mavlib.AdventurerClient;
import de.slg.mavlib.PrinterInfo;
import de.slg.mavlib.StatusInfo;
import de.slg.mavlib.TemperatureInfo;

import java.net.InetAddress;
import java.nio.file.Paths;

public class FlashForgeExample {
    public static void main(String[] args) {
        try {
            // Discover printer on the network
            InetAddress addr = new FlashForgeDiscoverClient().getPrinterAddress();
            System.out.println("Printer found at: " + addr.getHostAddress());

            try (AdventurerClient client = new AdventurerClient(addr)) {
                // Retrieve general printer info
                PrinterInfo info = client.getInfo();
                System.out.println("Printer Info: " + info);

                // Retrieve current status and temperatures
                StatusInfo status = client.getInfoStatus();
                TemperatureInfo temps = status.getTemperatures();
                System.out.printf("Nozzle: %.1f°C / Target: %.1f°C   Bed: %.1f°C / Target: %.1f°C%n",
                    temps.getCurrentNozzle(), temps.getTargetNozzle(),
                    temps.getCurrentBed(), temps.getTargetBed());

                // Start print job with a GX file
                client.print(Paths.get("path/to/file.gx"));
                System.out.println("Print started.");
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

💡 Use Cases

  • 🖥️ Desktop utilities for monitoring printer health and status
  • 🔁 Automated print farms where jobs are submitted via scripts
  • 📊 Dashboard integration (e.g., in a web UI or Home Assistant setup)
  • 🔧 Developer tooling to extend capabilities of FlashForge printers

🧪 Printer Compatibility

The library has been tested mainly with the FlashForge Adventurer 3, but may also work with other printers like:

  • FlashForge Finder
  • FlashForge Voxel (Monoprice)
  • Possibly Guider or Adventurer 4 with similar firmware

However, because the protocol is not officially documented by FlashForge, compatibility across models and firmware versions is not guaranteed.


⚠️ Limitations

ProsLimitations
No USB required – LAN onlyNo official documentation
Raw control via TCPMight break with firmware updates
Easy to integrate in JavaLacks advanced logging or UI

📈 Development and Contribution

You’re welcome to fork the repository, submit pull requests, or open issues to improve support for more printers and commands.


🔚 Conclusion

The FlashForgePrinterApi is a powerful Java library for network-based control of FlashForge 3D printers. Whether you're building tools for your own print farm or integrating printer management into an automation platform, this API gives you low-level access over the LAN using Java.

It's an ideal tool for developers who want full control over their printers—no browser UI or USB cable required.

Tags

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.