← Back to rwaldron/johnny-five

How to Deploy & Use rwaldron/johnny-five

Johnny-Five Deployment and Usage Guide

Prerequisites

Before getting started with Johnny-Five, ensure you have the following:

  • Node.js (version 10 or higher)
  • npm (Node Package Manager)
  • Arduino IDE (for uploading Firmata firmware to Arduino boards)
  • Hardware (Arduino board, Raspberry Pi, or other supported platform)
  • Breadboard and jumper wires (for connecting components)
  • Basic electronics knowledge (understanding of circuits, resistors, LEDs, etc.)

Installation

1. Install Node.js and npm

Download and install Node.js from nodejs.org. This will also install npm.

2. Clone the Johnny-Five Repository

git clone https://github.com/rwaldron/johnny-five.git
cd johnny-five

3. Install Dependencies

npm install

4. Upload Firmata Firmware (for Arduino)

  1. Open the Arduino IDE
  2. Go to File > Examples > Firmata > StandardFirmata
  3. Select your board and port
  4. Click Upload

Configuration

Environment Variables

Johnny-Five doesn't require specific environment variables, but you may need to configure:

  • Serial port (automatically detected, but can be specified)
  • Board type (automatically detected, but can be specified)

Hardware Configuration

  1. Connect your hardware components to the board
  2. Ensure proper power supply
  3. Verify connections match your code

Build & Run

Running Examples

Johnny-Five includes numerous examples in the eg/ directory. To run an example:

node eg/led-blink.js

Development Server

Johnny-Five doesn't include a built-in development server. For web-based projects, integrate with frameworks like Express.js:

const { Board, Led } = require("johnny-five");
const board = new Board();

board.on("ready", () => {
  const led = new Led(13);
  led.blink(500);
});

Production Deployment

For production applications:

  1. Bundle your application with tools like Webpack or Rollup
  2. Use process managers like PM2 for reliability
  3. Implement proper error handling and logging

Deployment

Platform Options

Johnny-Five can be deployed on various platforms:

1. Raspberry Pi

# Install Johnny-Five on Raspberry Pi
npm install johnny-five

2. Cloud Platforms

  • AWS IoT Greengrass
  • Google Cloud IoT Core
  • Microsoft Azure IoT Hub

3. Container Deployment

FROM node:14
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
CMD ["node", "app.js"]

Troubleshooting

Common Issues and Solutions

1. Board Not Detected

Problem: Johnny-Five can't find your board Solution:

const board = new Board({
  port: "/dev/cu.usbmodem1411" // Specify your port
});

2. Permission Denied

Problem: Serial port access denied Solution:

# Add user to dialout group (Linux)
sudo usermod -a -G dialout $USER
# Restart your computer

3. Firmata Not Responding

Problem: Board connected but not responding Solution:

  • Verify Firmata firmware is uploaded
  • Check board power and connections
  • Try different USB cable

4. Component Not Working

Problem: LED, sensor, or other component not responding Solution:

  • Verify wiring connections
  • Check component orientation
  • Test with multimeter

5. Node.js Version Compatibility

Problem: Johnny-Five not working with older Node.js versions Solution:

# Update to latest LTS version
nvm install --lts
nvm use --lts

Debugging Tips

// Enable debug mode
process.env.DEBUG = "johnny-five:*";

// Add error handling
board.on("error", (error) => {
  console.error("Board error:", error);
});

Community Support