npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-3dprinter-mks-wifi

v1.0.15

Published

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

Downloads

853

Readme

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

| Type | Default value | Mandatory| | --- | --- | --- | | string | null | yes |

port

| Type | Default value | Mandatory| | --- | --- | --- | | string | null | yes |

minimumExtruderTemperature

| Type | Default value | Mandatory| | --- | --- | --- | | number | 0 | no |

maximumExtruderTemperature

| Type | Default value | Mandatory| | --- | --- | --- | | number | 280 | no |

minimumBedTemperature

| Type | Default value | Mandatory| | --- | --- | --- | | number | 0 | no |

maximumBedTemperature

| Type | Default value | Mandatory| | --- | --- | --- | | number | 100 | no |


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

| Type | Default value | Mandatory| | --- | --- | --- | | string | null | yes |


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

| Type | Default value | Mandatory| Minimum | Maximum | | --- | --- | --- | --- | --- | | number | 255 | no | 0 | 255 |


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

| Type | Default value | Mandatory| Minimum | Maximum | | --- | --- | --- | --- | --- | | number | null | yes | 0| 280|

you can set custom minmum and maximum temperature in the constructor

extruder

| Type | Default value | Mandatory| Minimum | Maximum | | --- | --- | --- | --- | --- | | number | 0 | no | 0| 1|

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

| Type | Default value | Mandatory| Minimum | Maximum | | --- | --- | --- | --- | --- | | number | null | yes | 0| 100|

you can set custom minmum and maximum temperature in the constructor


Authors