Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-3dprinter-mks-wifi

Package Overview
Dependencies
Maintainers
0
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-3dprinter-mks-wifi

This package allows to manage a 3dPrinter with MKS WIFI support using node.

  • 1.0.15
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
834
increased by567.2%
Maintainers
0
Weekly downloads
 
Created
Source

npm version

node-3dprinter-mks-wifi

This package allows to manage a 3dPrinter with MKS WIFI support using node.


Prerequisites

This package is designs for 3dPrinter using marlin derived firmware and supporting MKS WIFI featrues! This package requires NodeJS (version 16 or later) and NPM. Node and NPM are really easy to install. To make sure you have them available on your machine, try running the following command.

$ npm -v && node -v

Table of contents


Installation

BEFORE YOU INSTALL: please read the prerequisites

Via Github

Clone this repo on your local machine:

$ git clone https://github.com/alealpha07/node-3dprinter-mks-wifi
$ cd node-3dprinter-mks-wifi

Via npm

Install the npm package

$ npm install node-3dprinter-mks-wifi

Usage

To use the package you need to include the Printer class in your index file first

const Printer = require("node-3dprinter-mks-wifi"); // for npm
//const Printer = require("./printer"); // for github

create an instance of the Printer by providing the correct IP and PORT

const Printer = require("node-3dprinter-mks-wifi");
const IP = "192.168.1.1"; //replace with your IP
const PORT = "8080"; //replace with your PORT

const printer = new Printer(IP, PORT);

now you can use the functionalities of the printer by simply using the methods listed in the API section

Full Example

This simple example will connect, retrive the printing status and print it to the console.

const Printer = require("node-3dprinter-mks-wifi");
const IP = "192.168.1.1"; //replace with your IP
const PORT = "8080"; //replace with your PORT

const printer = new Printer(IP, PORT);

printer.connect().then(()=>{
   printer.getState().then((result) => {
      console.log(result);
   }).catch((error) => {
      console.log(error);
   }).finally(()=>{
      printer.disconnect();
   })
})

With async/await:

const Printer = require("node-3dprinter-mks-wifi");
const IP = "192.168.1.1"; //replace with your IP
const PORT = "8080"; //replace with your PORT

const printer = new Printer(IP, PORT);

async function main(){
   try{
      await printer.connect();
      let result = await printer.getState();
      console.log(result);
   }catch(error){
      console.log(error);
   }
   finally{
      printer.disconnect();
   }
}

main();

API

constructor

constructor

new Printer(ip, port)

Supported options for the constructor method are listed below.

Options

ip

TypeDefault valueMandatory
stringnullyes

port

TypeDefault valueMandatory
stringnullyes

minimumExtruderTemperature

TypeDefault valueMandatory
number0no

maximumExtruderTemperature

TypeDefault valueMandatory
number280no

minimumBedTemperature

TypeDefault valueMandatory
number0no

maximumBedTemperature

TypeDefault valueMandatory
number100no

connect

connect to the printer

printer.connect()

Supported options and possible results for the connect method are listed below.

Returns

string - Connected to printer at IP:PORT if succeeded string - Connection error: ERROR if failed

Options

no option is present


disconnect

disconnect from the printer

printer.disconnect()

Supported options and possible results for the disconnect method are listed below.

Returns

string - Disconnected from printer. if succeeded string - Disconnection error: ERROR if failed

Options

no option is present


getState

get status of the printer (printing, idle, pause)

printer.getState()

Supported options and possible results for the getState method are listed below.

Returns

string - STATUS STRING if succeeded string - Error receiving data: ERROR if failed

Options

no option is present


getTemperature

get temperatures of the printer

printer.getTemperature()

Supported options and possible results for the getTemperature method are listed below.

Returns

object if succeeded:

{
   nozzleCurrent: number,
   nozzleTarget: number,
   bedCurrent: number,
   bedTarget: number,
   extruder0Current: number,
   extruder0Target: number,
   extruder1Current: number,
   extruder1Target: number,
   heaterPower: number,
   bedHeaterPower: number
}

string - Error receiving data: ERROR if failed

Options

no option is present


getPrintingProgress

get printing progress (percentage)

printer.getPrintingProgress()

Supported options and possible results for the getPrintingProgress method are listed below.

Returns

number - between 0 and 100 if succeeded: string - Error receiving data: ERROR if failed

Options

no option is present


getPrintingTime

get elapsed print time

printer.getPrintingTime()

Supported options and possible results for the getPrintingTime method are listed below.

Returns

string - hh:mm:ss format if succeeded: string - Error receiving data: ERROR if failed

Options

no option is present


getPrintingFilename

get currently in print file name

printer.getPrintingFilename()

Supported options and possible results for the getPrintingFilename method are listed below.

Returns

string - FILENAME.gcode if succeeded: string - Error receiving data: ERROR if failed

Options

no option is present


getFilenames

get all files in 3d printer sd card

printer.getFilenames()

Supported options and possible results for the getFilenames method are listed below.

Returns

list: [string] - ['file1.gcode', 'file2.gcode', ...] if succeeded: string - Error receiving data: ERROR if failed

Options

no option is present


startPrinting

start printing the selected file

printer.startPrinting(filename)

Supported options and possible results for the startPrinting method are listed below.

Returns

string - ok if succeeded: string - Error receiving data: ERROR if failed

Options

filename

TypeDefault valueMandatory
stringnullyes

home

bring the hotend to the home position

printer.home()

Supported options and possible results for the home method are listed below.

Returns

string - ok if succeeded: string - Error receiving data: ERROR if failed

Options

no option is present


pause

pause the print

printer.pause()

Supported options and possible results for the pause method are listed below.

Returns

string - ok if succeeded: string - Error receiving data: ERROR if failed

Options

no option is present


resume

resume the print

printer.resume()

Supported options and possible results for the resume method are listed below.

Returns

string - ok if succeeded: string - Error receiving data: ERROR if failed

Options

no option is present


abort

abort the print

printer.abort()

Supported options and possible results for the abort method are listed below.

Returns

string - ok if succeeded: string - Error receiving data: ERROR if failed

Options

no option is present


startFan

start the fan

printer.startFan()

Supported options and possible results for the startFan method are listed below.

Returns

string - ok if succeeded: string - Error receiving data: ERROR if failed

Options

speed

TypeDefault valueMandatoryMinimumMaximum
number255no0255

stopFan

stop the fan

printer.stopFan()

Supported options and possible results for the stopFan method are listed below.

Returns

string - ok if succeeded: string - Error receiving data: ERROR if failed


setExtruderTemperature

set target extruder temperature

printer.setExtruderTemperature(temperature)

Supported options and possible results for the setExtruderTemperature method are listed below.

Returns

string - ok if succeeded: string - Error receiving data: ERROR if failed

Options

temperature

TypeDefault valueMandatoryMinimumMaximum
numbernullyes0280

you can set custom minmum and maximum temperature in the constructor

extruder

TypeDefault valueMandatoryMinimumMaximum
number0no01

you can set the extruder to use (0 for the first one, 1 for the second)


setBedTemperature

set target bed temperature

printer.setBedTemperature(temperature)

Supported options and possible results for the setBedTemperature method are listed below.

Returns

string - ok if succeeded: string - Error receiving data: ERROR if failed

Options

temperature

TypeDefault valueMandatoryMinimumMaximum
numbernullyes0100

you can set custom minmum and maximum temperature in the constructor


Authors

Keywords

FAQs

Package last updated on 17 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc