@danidoble/serial-node-boardroid
v0.0.1
Published
Node.js library to interact with Boardroid vending machines via serial port.
Readme
@danidoble/serial-node-boardroid
A comprehensive TypeScript library for controlling vending machine hardware via serial communication. Control coin purses, banknote recyclers, card readers, product dispensers, and more with type-safe, event-driven architecture.
Features
- Coin Purse Management - Accept, dispense, and track coins
- Banknote Recycler Control - Handle banknotes with ICT and generic recyclers
- Card Reader Integration - Process card payments
- Product Dispensing - Control up to 80 product channels
- Event-Driven Architecture - React to all hardware events in real-time
- Type-Safe - Full TypeScript support with comprehensive types
- Testing Utilities - Built-in matrix testing for all motors
- Environment Monitoring - Temperature and door sensors
- Change Calculation - Automatic change dispensing logic
Installation
npm install @danidoble/serial-node-boardroid serialport serial-coreQuick Start
import { Boardroid } from '@danidoble/serial-node-boardroid';
const boardroid = new Boardroid({
path: '/dev/ttyUSB0',
baudRate: 9600,
autoConnect: true
}, 1);
boardroid.on('serial:connected', () => {
console.log('Connected to vending machine');
// Configure peripherals
boardroid.coinPurseConfigure({ enable: true });
boardroid.banknotePurseConfigure({ enable: true, scrow: true });
});
boardroid.on('money:inserted', ({ type, money, where }) => {
console.log(`${money.name} inserted (${type}) -> ${where}`);
});
boardroid.start();Usage Examples
Configuring Purses
// Configure Coin Purse
await boardroid.coinPurseConfigure({
enable: true,
high: 0xFF, // Enable all coins
low: 0xFF
});
// Configure Banknote Recycler
await boardroid.banknotePurseConfigure({
enable: true,
scrow: true // Enable scrow for holding bills before stacking
});
// Enable/Disable cooling relay
await boardroid.coolingRelayConfigure({ enable: true });Dispensing Products
// Simple dispense
await boardroid.dispense({
selection: 1, // Channel 1
sensor: true, // Use drop sensor
retry: true // Retry if failed
});
// Dispense with fallback/time
await boardroid.dispense({
selection: 2,
sensor: false,
seconds: 1.5 // Run motor for 1.5s
});Dispensing Change
// Dispense specific coins
await boardroid.coinPurseDispense({
$_1: 2, // 2 x $1 coins
$_5: 1 // 1 x $5 coin
});
// Dispense banknotes (ICT Recycler)
await boardroid.banknotePurseDispense({
$_20: 1, // 1 x $20 bill
$_50: 1 // 1 x $50 bill
});Handling Events
// Temperature monitoring
boardroid.on('status:temperature', ({ temperature }) => {
console.log(`Current temp: ${temperature}°C`);
});
// Door opening
boardroid.on('door:event', ({ open }) => {
console.log(`Door is ${open ? 'OPEN' : 'CLOSED'}`);
});Documentation
For complete API documentation, usage examples, and guides, visit the GitHub repository.
License
GPL-3.0-only © Danidoble
