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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@danidoble/serial-node-arduino-tester

v0.0.2

Published

A Node.js tester module for Arduino devices using serial communication.

Readme

Serial Node Arduino

npm version License: GPL-3.0

A Node.js library for serial communication with Arduino devices. Provides a simple event-based interface to interact with Arduino devices through serial communication.

Features

  • Event-based serial communication
  • Automatic connection/disconnection management
  • Command sending with custom aliases
  • Support for timeouts and asynchronous responses
  • Typed and structured messages
  • Support for CommonJS and ES Modules
  • Native TypeScript with included type definitions

Installation

Important: This library requires the following peer dependencies that must be installed explicitly:

npm install @danidoble/serial-node-arduino-tester serialport serial-core

Or using yarn:

yarn add @danidoble/serial-node-arduino-tester serialport serial-core

Or using pnpm:

pnpm add @danidoble/serial-node-arduino-tester serialport serial-core

Requirements

  • Node.js >= 18.0.0
  • serialport ^13.0.0
  • serial-core ^0.2.0-dev.3

Usage

Basic Setup

import { Arduino } from '@danidoble/serial-node-arduino-tester';

// Configure Arduino connection
const arduino = new Arduino({
  path: '/dev/ttyUSB0', // Your Arduino serial port
  baudRate: 9600,
  autoOpen: true
});

// Listen to connection events
arduino.on('serial:connected', info => {
  console.log('Arduino connected:', info);
});

arduino.on('serial:disconnected', reason => {
  console.log('Arduino disconnected:', reason);
});

// Listen to Arduino messages
arduino.on('serial:message', message => {
  console.log('Message received:', message);
});

// Listen to errors
arduino.on('serial:error', error => {
  console.error('Error:', error);
});

Sending Commands

// Send predefined commands
await arduino.sayHi();
await arduino.sayCredits();

// Perform multiple actions
await arduino.doSomething();

// Stop the connection
await arduino.stop();

Message Structure

Received messages have the following structure:

interface SerialMessage {
  code: Buffer | string; // Raw code received
  name: string; // Message name
  description: string; // Message description
  request: string; // Alias of the command that generated the response
  no_code: number; // Numeric message code
}

Predefined Message Types:

  • connected (code: 100) - Connection established
  • thanks (code: 101) - Credits message from Arduino
  • hello there (code: 102) - Greeting message
  • ara ara (code: 404) - Easter egg message
  • unknown (code: 400) - Unknown/unrecognized message

Available Events

  • serial:status - Serial connection status changes
  • serial:connected - Connection established with the device
  • serial:disconnected - Device disconnected
  • serial:message - Structured message received from Arduino
  • serial:data - Raw data received from Arduino
  • serial:error - Communication errors

API Documentation

The library includes comprehensive JSDoc comments for all public methods and classes. For detailed information about the Arduino class and its methods, refer to the source code:

Arduino Class Methods

  • constructor(config: SerialConfig) - Creates an Arduino instance with configuration
  • start(): void - Starts the serial service
  • stop(): Promise<void> - Stops and disconnects from the Arduino
  • sayHi(): Promise<void> - Sends HI command to Arduino
  • sayCredits(): Promise<void> - Sends CREDITS command to Arduino
  • sayAra(): Promise<void> - Sends OTHER command (ara ara message)
  • doSomething(): Promise<void> - Executes all commands concurrently

Arduino Code Example

// serial.ino

void setup() {
  Serial.begin(9600);
}

void loop() {
  if (Serial.available() > 0) { // Check if data to read is available
    String comando = Serial.readStringUntil('\n'); // read the data until a new line is found
    comando.trim(); // remove leading/trailing whitespace and \r characters

    if(comando == "CONNECT"){
      Serial.println("connected");
    } else if (comando == "CREDITS") {
      Serial.println("created by danidoble");
    } else if (comando == "HI") {
      Serial.println("hello there");
    } else {
      Serial.println("ara ara, what are you doing?");
    }
  }
}

Development

Install Dependencies

npm install

Run Tests

npm run test

Build the Project

npm run build

Code Formatting

npm run format

Linting

npm run lint

Development Mode

npm run dev

Contributing

Contributions are welcome. Please read CONTRIBUTING.md for more details about our code of conduct and the process for submitting pull requests.

License

This project is licensed under the GPL-3.0 License - see the LICENSE.md file for details.

Author

Danidoble - [email protected]

Links