Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: Node-red on mac osx - Teensy 3.1 question?

  1. #1

    Node-red on mac osx - Teensy 3.1 question?

    I downloaded the node.js installer for osx here (in terminal):
    http://nodejs.org/dist/v0.10.26/node-v0.10.26.pkg
    and installed it.

    With nodejs installed I can run npm commands (in terminal), so now I can install node-red:
    Code:
    git clone https://github.com/node-red/node-red.git
    cd node-red
    npm install --production
    after installation i can run (in terminal):
    Code:
    node red.js
    Now in Chrome browser i type the address:
    http://localhost:1880/

    Now with node-red setup on my mac, I am hoping that I may be able to do something with in & my Teensy 3.1 connected via USB?
    I guess I will need a library to connect Teensy to node.js ??

    Am I barking up the wrong tree, can node-red be used with Teensy 3.1?
    Does anyone here have any experience withe node-red?

    There is a Firmata Library for Teensy here:
    http://www.pjrc.com/teensy/td_libs_Firmata.html
    Last edited by rootScript; 04-17-2014 at 12:20 AM.

  2. #2
    Here is a little extra info as to what node-red is:
    Node-RED is a tool for wiring together hardware devices, APIs and online services; it provides a browser-based flow editor that makes it easy to wire together flows using the wide range of palette of nodes.
    IBM researchers were looking for a way to simplify the process of hooking together systems and sensors... Node-RED is an event-processing engine... that talks to a serial port.
    Click image for larger version. 

Name:	Screenshot.png 
Views:	445 
Size:	67.9 KB 
ID:	1821
    Node-RED is an application based on node.js, a server side JavaScript platform that uses an event-driven, non-blocking I/O model suited to creating data-intensive, real-time applications that run across distributed devices.
    For a device or a service to work with Node-RED there needs to be a node.js library or module capable of talking to them.

    There are two main ways for interacting with an Arduno using Node-RED. They both assume the Arduino is connected to the host computer via a USB connection.

    Serial:
    As the Arduino appears as a Serial device, the Serial in/out nodes can be used to communicate with it.

    Firmata:
    Firmata is a protocol for communicating between an Arduino (as well as other microcontrollers) and the host computer, providing direct access to the IO pins.
    Last edited by rootScript; 04-17-2014 at 12:18 AM.

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,743
    I don't know anything about Node-Red. This thread is the first I've ever heard of it.

    I can tell you both Firmata and USB Serial work great on Teensy. To use Firmata on Teensy 3.1, open File > Examples > Firmata > StandardFirmata. Make sure Tools > USB Type is set to "Serial". Then click upload.

    The main Firmata website has a stand along test program, called "firmata_test" (I'm the author....) If you're trying to get a Firmata device (Teensy, Arduino, or otherwise) to work with some program that speaks Firmata, the test program is a nice stand-alone test that can check if things are working.

  4. #4
    Ok Paul,

    Thanks to your help I have a working example; so I thought I would report back.

    I loaded the StandardFirmata example (in Arduino IDE), and uploaded to the Teensy 3.1 board.
    I tested with your firmata_test app in OSX; and it works.
    So to get in working with node-red I installed the Firmata node, like so:
    Code:
    cd node-red
    npm install firmata
    node red.js -v
    Then open Chrome at http://localhost:1880/
    In the menu, Import from..> Clipboard
    and paste the following code:
    (Change "/dev/ttyUSB0" to your current Teensy serial USB connection, for example: "/dev/tty.usbmodem30851")

    Code:
    [{"id":"d7663aaf.47194","type":"arduino-board","repeat":"25","device":"/dev/ttyUSB0"},{"id":"8c09ca6c.a975d","type":"arduino out","name":"","pin":"13","state":"OUTPUT","arduino":"d7663aaf.47194","x":509.16667556762695,"y":162.16666984558105,"wires":[]},{"id":"e37b6a97.610968","type":"inject","name":"tick","topic":"","payload":"","repeat":"0.5","once":false,"x":116.16668319702148,"y":62.16666507720947,"wires":[["60b4aeaa.800d58"]]},{"id":"60b4aeaa.800d58","type":"function","name":"Toggle output on input","func":"\n// initialise level as a context variable if currently undefined \n// (context variables persist between calls to the function)\ncontext.level = context.level || false;\n\n// if it's a 0 make it a 1 else make it a 0...\ncontext.level = !context.level;\n\n// set the payload to the level and return\nmsg.payload = context.level;\nreturn msg;","outputs":1,"x":298.1666793823242,"y":113.16665458679199,"wires":[["8c09ca6c.a975d"]]}]
    This will create 3 linked nodes, one will be called "Pin 13". You can double click on it to to see your serial port, for example "/dev/tty.usbmodem30851".
    When you click "Deploy" (in node-red) Pin 13 LED is now blinking.

    Possible problems (If you didn't change your Serial Port in the Paste code above):
    When you started node-red in Terminal with the -v option, you can see any error messages; you probably will have "Error: Cannot open /dev/ttyUSB0", so in node-red double click Pin 13, add your Teensy Serial Port, then click the "config" panel & delete the ttyUSB0.

    That is as far as I have got, hopefully it is enough to get anyone interesting in using node-red with Teensy started.
    )
    Carlos
    Last edited by rootScript; 04-19-2014 at 01:54 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •