Git Product home page Git Product logo

node-mindstorm-bt's Introduction

Mindstorms BlueTooth

Mindstorms bluetooth is a nodejs module to communicate with your mindstorm brick using the direct api over bluetooth.

How to install:

npm install mindstorms_bluetooth

How to use:

First setup your Lego Mindstoms NXT brick. It will create a serial port, get that name. On Mac OS X is it on the form: /dev/tty.NXT-DevB, or at least on my mac is it so.

Require it, initialize and use.

var Nxt = require('mindstorms_bluetooth');

var nxt = new Nxt("/dev/tty.NXT-DevB");
nxt.play_tone(440, 1000);

API:

Please see the nxt.js for now. I will create a better api documentation soon.

Linux settings

origin: http://bricxcc.sourceforge.net/nbc/doc/nxtlinux.txt

For ubuntu and other recent linux distributions here is a new procedure that I recommend using to configure your Linux box for use with the NXT:

  1. Add a legonxt group. From a terminal prompt type
sudo addgroup legonxt
  1. Add your account to the legonxt group. From a terminal prompt type
sudo adduser YourUserName legonxt
  1. Create a file called 45-legonxt.rules using your favorite text editor. Its contents should look like this:
# NXT brick 
SUBSYSTEM=="usb", ATTRS{idVendor}=="0694", ATTRS{idProduct}=="0002", SYMLINK+="legonxt-%k", GROUP="legonxt", MODE="0666"

# NXT brick in firmware update mode (Atmel SAM-BA mode)
SUBSYSTEM=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="6124", SYMLINK+="legonxt-%k", GROUP="legonxt", MODE="0666"
  1. Copy this file to /etc/udev/rules.d. From a terminal prompt type
sudo cp 45-legonxt.rules /etc/udev/rules.d
  1. That should be all you need to do (aside from reboot) to make sure that your NXT will always be accessible via USB for any user who is a member of the legonxt group. Whenever you plug in your NXT it should show up in /dev as
/dev/legonxt-x-y

where x and y depend on which USB port you plug the NXT into. On my laptop which has 4 USB ports I get 1-1, 1-2, 2-1, and 2-2 depending on which port I plug into. There will be other entries such as /dev/legonxt-usbdevx.y where y increments but you should be able to use the above device alias without any problems.

  1. That should take care of USB support. Now let's work on Bluetooth support.

  2. The procedure below is described by Tony Buser here: http://www.juju.org/articles/2006/10/22/bluetooth-serial-port-to-nxt-in-linux

  3. You may need to install bluetooth support using apt-get. If hcitool doesn't work then from a terminal prompt type

sudo apt-get install bluetooth
  1. Get your NXT's bluetooth address using hcitool. From a terminal prompt type
sudo hcitool scan
  1. Edit a file called /etc/bluetooth/rfcomm.conf using your favorite text editor. Add an entry for your NXT that looks like this:
rfcomm0 {
	# Automatically bind the device at startup
	bind yes;
	# Bluetooth address of the device
	device 00:16:53:FF:01:56;
	# RFCOMM channel for the connection
	channel	1;
	# Description of the connection
	comment "JCH2";
}

Make sure you enter your NXT's bluetooth address as shown by the hcitool scan. If you have more than one NXT you can create additional entries in this file with incremental rfcomm names (e.g., rfcomm1, rfcomm2, etc...).

  1. Now restart your bluetooth services. From a terminal prompt type
sudo /etc/init.d/bluetooth restart

You may have to use /etc/init.d/bluez-utils restart but on my ubuntu system it uses bluetooth instead.

  1. Make sure rfcomm is working properly. From a terminal prompt type
rfcomm

You should see

rfcomm0: 00:16:53:FF:01:56 channel 1 clean

with your NXT's bluetooth address instead, of course.

  1. Make sure the device shows up in /dev and that you have permission to read/write to it. On my system it shows it associated with the dialout group and my user account is in the dialout group as shown below. Make sure yours looks similar.
john@john-laptop:~/Desktop$ ls -l /dev/rfcomm0
crw-rw---- 1 root dialout 216, 0 2008-04-02 20:52 /dev/rfcomm0

john@john-laptop:~/Desktop$ groups
users adm dialout cdrom floppy audio dip video plugdev scanner lpadmin admin netdev powerdev legonxt
  1. As Tony mentions, the first time you try to connect to /dev/rfcomm0 you should be prompted on your PC and your NXT to enter or accept the PIN number. Use 1234. Once that has been exchanged once you should not have to do that again.

In other utilities you should be able to use /dev/legonxt-x-y or /dev/rfcomm0 to communicate with your NXT by USB or Bluetooth respectively.

Bigger example

TODO

node-mindstorm-bt's People

Contributors

chilijung avatar kenany avatar nikswap avatar szolotykh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.