New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

node-poweredup

Package Overview
Dependencies
Maintainers
1
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-poweredup

A Javascript module to interface with LEGO Powered Up components.

latest
npmnpm
Version
10.1.0
Version published
Weekly downloads
284
576.19%
Maintainers
1
Weekly downloads
 
Created
Source

NPM Version Docs

node-poweredup - A Javascript module to interface with LEGO Powered Up components.

Announcements

  • v10.0.0 brings node-poweredup up to date! Libraries updated, new ES style syntax, and more.

Introduction

LEGO Powered Up is the successor to Power Functions, the system for adding electronics to LEGO models. Powered Up is a collection of ranges, all of which are compatible with each other:

  • LEGO Education WeDo 2.0
  • LEGO Boost
  • LEGO Powered Up
  • LEGO Technic CONTROL+
  • LEGO Education SPIKE Prime
  • LEGO Education SPIKE Essential
  • LEGO Mindstorms Robot Inventor

Other products that speak the Powered Up protocol include the Duplo App-Controlled trains and LEGO Super Mario, both of which are compatible with this library.

This library allows communication and control of Powered Up devices and peripherals via Javascript, both from Node.js and from the browser using Web Bluetooth.

Sample Usage

import { PoweredUP } from "node-poweredup";
const poweredUP = new PoweredUP();

poweredUP.on("discover", async (hub) => { // Wait to discover a Hub
    console.log(`Discovered ${hub.name}!`);
    await hub.connect(); // Connect to the Hub
    const motorB = await hub.waitForDeviceAtPort("B"); // Make sure a motor is plugged into port B
    console.log("Connected");

    while (true) { // Repeat indefinitely
        console.log("Running motor A at speed 100 for 2 seconds");
        motorA.setPower(100); // Run a motor attached to port A for 2 seconds at maximum speed (100) then stop
        await hub.sleep(2000);
        motorA.brake();
        await hub.sleep(1000); // Do nothing for 1 second
        console.log("Running motor A at speed -30 for 1 second");
        motorA.setPower(-30); // Run a motor attached to port A for 2 seconds at 1/2 speed in reverse (-50) then stop
        await hub.sleep(2000);
        motorA.brake();
        await hub.sleep(1000); // Do nothing for 1 second
    }
});

poweredUP.scan(); // Start scanning for Hubs
console.log("Scanning for Hubs...");

More examples are available in the "examples" directory.

Documentation

Full documentation is available here.

Node.js Installation

Node.js v18.0+ required.

npm install node-poweredup --save

node-poweredup relies on the @stoprocent/noble library. Ensure any prerequisites documented here are satisfied.

Compatibility

While most Powered Up components and Hubs are compatible with each other, there are exceptions. For example, there is limited backwards compatibility between newer components and the WeDo 2.0 Smart Hub. However WeDo 2.0 components are fully forwards compatible with newer Hubs.

Device NameProduct CodeTypeWeDo 2.0 Smart HubBoost Move HubPowered Up HubControl+ HubAvailability
WeDo 2.0 Tilt Sensor45305SensorYesYesYesYes45300
WeDo 2.0 Motion Sensor45304SensorYesYesYesYes45300
WeDo 2.0 Medium Motor45303MotorYesYesYesYes45300
76112
Boost Color and Distance Sensor88007SensorPartialYesYesYes17101
Boost Tacho Motor88008Motor/SensorPartialYesYesYes17101
Powered Up Train Motor88011MotorYesYesYesYes60197
60198
Powered Up LED Lights88005LightYesYesYesYes88005
Control+ Large Motor22169Motor/SensorPartialNoYesYes42099
42100
Control+ XLarge Motor22172Motor/SensorPartialNoYesYes42099
42100
SPIKE Prime Medium Motor45678Motor/SensorPartialNoYesYes45678
SPIKE Prime Large Motor45678Motor/SensorPartialNoYesYes45678
SPIKE Prime Color Sensor45678SensorNoNoYesYes45678
SPIKE Prime Distance Sensor45678SensorNoNoYesYes45678
SPIKE Prime Force Sensor45678SensorPartialYesYesYes45678
SPIKE Essential Small Motor45607Motor/SensorPartialNoYesYes45345
SPIKE Essential 3x3 Color Matrix45608Motor/SensorPartialNoYesYes45345

In addition, the Hubs themselves have certain built-in features which this library exposes.

Hub NameProduct CodeBuilt-In FeaturesAvailability
WeDo 2.0 Smart hub45301RGB LED
Piezo Buzzer
Button
45300
Boost Move Hub88006RGB LED
Tilt Sensor
2x Tacho Motors
Button
17101
Powered Up Hub88009RGB LED
Button
60197
60198
76112
Powered Up Remote88010RGB LED
Left and Right Control Buttons
Button
60197
60198
Duplo Train Base28743RGB LED/Headlights
Speaker
Speedometer
Motor
Color and Distance Sensor
Button
10874
10875
Control+ Hub22127RGB LED
Button
Tilt Sensor
Accelerometer
42099
42100
Super Mario71360Pants Sensor
Barcode and Color Sensor
71360
SPIKE Essential Hub45609RGB LED
Button
Tilt Sensor
Accelerometer
45345

Known Issues and Limitations

  • The WeDo 2.0 Smart Hub uses an older firmware which is no longer being updated. As a result, only certain motors and sensors work with it. See the table above.

  • When used with the Boost Move Hub, the Control+ Motors and SPIKE Prime Motors/Sensors do not currently accept commands (This is a known bug which requires a firmware update from Lego to fix)

  • The SPIKE Prime Hub does not use Bluetooth Low Energy, so is not supported via this library. It is recommended you use MicroPython to develop for this Hub using the officially provided tools and software. The SPIKE Essential Hub however is supported, as it uses Bluetooth Low Energy.

  • On most Unix systems, you need root permissions to access Bluetooth devices. You may want to grant the node executable access to the Bluetooth adapter

Credits

Thanks go to Jorge Pereira (@JorgePe), Sebastian Raff (@hobbyquaker), Valentin Heun (@vheun), Johan Korten (@jakorten), and Andrey Pokhilko (@undera) for their various works, contributions, and assistance on figuring out the LEGO Boost, WeDo 2.0, and Powered Up protocols.

FAQs

Package last updated on 08 Jan 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts