Home Reference Source Test Repository

nextion

Communicate with ITEAD's Nextion HMI Devices

pic of nextion device

Status

Basic Usage

COM Port, USB-to-UART adapter, etc.

const Nextion = require('nextion');

// CH340G usually shows up at this path on macOS
Nextion.fromPort('/dev/tty.SLAB_USBtoUART')
  .then(nextion => {
    console.log('Listening...');

    nextion.on('touchEvent', data => {
      console.log(data);
    });
  });

For port auto-detection, try:

const Nextion = require('nextion');

Nextion.create()
  .then(nextion => {
    // do exciting stuff here
  });

Tessel 2

const tessel = require('tessel');
const Nextion = require('nextion/minimal');

const uart = new tessel.port.A.UART({
  baudrate: 9600
});

Nextion.fromSerial(uart)
  .then(nextion => {
    // Yipper McCheese!
  });

The nextion/minimal module is for resource-constrained systems; it's compressed and does not include source maps.

Compatibility

As long as the argument passed into Nextion.fromSerial is a Duplex stream or a duck-typed one (a la serialport), you should be able to use it. Hack away!

API Docs

TODO

Development

Events

The Nextion instance (nextion) in above examples is an EventEmitter. If the device sends any of these over the UART channel, the Nextion instance will emit a corresponding event (w/ data, if any).

TODO: Describe shape of data for data-emitting events.

Motivation

Future:

Notes

Johnny-Five

Johnny-Five support is problematic, because:

ARM

If the serialport module supports the architecture, this module should work out-of-the-box, meaning RPi's and BBB's are theoretically covered.

MIPS

This shouldn't be too bad, because the Tessel 2 is MIPS-based, but we require Node.js v4. Other MIPS-based boards I've used have had trouble getting it compiled, packaged, or running at a respectable speed.

License

:copyright: 2017 Christopher Hiller. Licensed MIT.