# mqtt-serial

> Virtual serial device over MQTT

Latest version **0.6.0** (published 2015-12-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install mqtt-serial
pnpm add mqtt-serial
yarn add mqtt-serial
bun add mqtt-serial
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.6.0 |
| Published | 2015-12-01 |
| First published | 2014-12-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Luis Montes |
| Maintainers | monteslu |

## Links

- npm: https://www.npmjs.com/package/mqtt-serial
- Repository: https://github.com/monteslu/mqtt-serial
- Homepage: https://github.com/monteslu/mqtt-serial#readme
- Issues: https://github.com/monteslu/mqtt-serial/issues
- npm.io page: https://npm.io/package/mqtt-serial

## Recent versions

- 0.6.0 (latest) — 2015-12-01
- 0.5.0 — 2015-04-30
- 0.4.2 — 2015-03-13
- 0.4.1 — 2015-03-02
- 0.4.0 — 2015-03-02
- 0.3.0 — 2014-12-17
- 0.2.1 — 2014-12-17
- 0.2.0 — 2014-12-17
- 0.1.0 — 2014-12-05

## README

mqtt-serial
=============

A virtual [node-serialport](https://github.com/voodootikigod/node-serialport) implementation that uses MQTT as the transport.


# MQTTSerialPort

Use mqtt to send/receive data to a remote physical device:

```js
var MQTTSerialPort = require('mqtt-serial').SerialPort;
var mqtt = require('mqtt');
var firmata = require('firmata');

// setup the mqtt client with port, host, and optional credentials
var client = mqtt.connect('mqtt://127.0.0.1:1883', {username: 'A USER', password: 'A PASSWORD'});

//create the mqtt serialport and specify the send and receive topics
var serialPort = new MQTTSerialPort({
  client: client,
  transmitTopic: 'REPLACE WITH YOUR TRANSMIT TOPIC',
  receiveTopic: 'REPLACE WITH YOUR RECEIVE TOPIC'
});

//use the virtual serial port to send a command to a firmata device
var board = new firmata.Board(serialPort, function (err, ok) {
  if (err){ throw err; }
  //light up a pin
  board.digitalWrite(13, 1);
});

```


# bindPhysical

Bind a physical serial port to receive/send data from an mqtt server:

```js
var SerialPort = require('serialport').SerialPort;
var bindPhysical = require('mqtt-serial').bindPhysical;
var skynet = require('mqtt');

// setup the mqtt client with port, host, and optional credentials
var client = mqtt.connect('mqtt://127.0.0.1:1883', {username: 'A USER', password: 'A PASSWORD'});

// setup a connection to a physical serial port
var serialPort = new SerialPort('/dev/tty.usbmodem1411',{
    baudrate: 57600,
    buffersize: 1
});

//connects the physical device to an mqtt server
bindPhysical({
  serialPort: serialPort,
  client: client,
  transmitTopic: 'REPLACE WITH YOUR TRANSMIT TOPIC',
  receiveTopic: 'REPLACE WITH YOUR RECEIVE TOPIC'
});

```

---
_Source: https://npm.io/package/mqtt-serial · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
