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-mysensor

v2.1.13

Published

MySensor serial gateway communication interface for Nodejs

Downloads

7

Readme

node-mysensor

Install

You can install node-mysensor with npm or yarn

npm install -s node-mysensor

OR

yarn add node-mysensor

Usage

There is ONLY class NodeMysensor. It will be constructed by 2 params port and baudRate

port is the serial communication port, like /dev/ttyUSB0 on Linux OR COM1 on Windows

baudRate is the speed of serial, it usualy is 115200

const Mysensor = require('./index.js');

const sensor = new Mysensor("/dev/tty.usbserial-A800H5SE", 115200);

sensor.on('message', console.table); 

/**
┌─────────┬─────────────────────────────┐
│ (index) │           Values            │
├─────────┼─────────────────────────────┤
│ nodeID  │              0              │
│ childID │             255             │
│ command │              3              │
│   ack   │              0              │
│  type   │             14              │
│ payload │ 'Gateway startup complete.' │
└─────────┴─────────────────────────────┘
 */

sensor.on('presentation', (message) => {
  console.log("Device presentation", message);
}) // it will show when device send presentation information

sensor.on('internal', (message) => {
  console.log("Device presentation", message);
}) // it will show internal command

sensor.on('set', (message) => {...})
sensor.on('req', (message) => {...})
sensor.on('stream', (message) = {...})

sensor.send(15,1,2,3,0,1) // Send message to node

Static variable

  • MySensor.DEBUG The switch to show debug message

Methods

  • instance.send(nodeID, childID, command, type, ack, payload)

    Send raw data to node

    • nodeID Target node's id
    • chidID Target node's child id
    • command Send command type
    • type Date type
    • ack Force node replay message
    • payload Real set data

    You can read detail document from offical site at here

Events

  • message
  • presentation
  • internal
  • req
  • set
  • stream

All events supply only one param for callback function, it is parsed message, the struct of message you can SEE BELOW Message Section

Message

The message is parsed by MySensor protocol 2.0

| key | type | value | |---------|-------|---------------| | nodeID | Number| The unique id of the node that sends or should receive the message (address)| | childID | Number|Each node can have several sensors attached. This is the child-sensor-id that uniquely identifies one attached sensor| | command | Number|Type of command sent | | ack | Number|The ack parameter has the following meaning: Outgoing: 0 = unacknowledged message, 1 = request ack from destination node, Incoming: 0 = normal message, 1 = this is an ack message | | type | Number|Depending on command, the type field has different meaning. | | payload | Number OR String| The payload holds the message coming in from sensors or instruction going out to actuators. |