Giter Club home page Giter Club logo

cylon-intel-iot's Introduction

Cylon.js For Intel IoT

Cylon.js (http://cylonjs.com) is a JavaScript framework for robotics, physical computing, and the Internet of Things (IoT).

This repository contains the Cylon adaptor for the Intel Edison and Intel Galileo IoT platforms. It uses the MRAA node module (https://github.com/intel-iot-devkit/mraa) created by the Intel IoT team thank you!

This module currently supports the following Intel IoT hardware:

  • Intel Galileo Gen 1
  • Intel Galileo Gen 2
  • Intel Edison with the Arduino breakout board

Want to use Ruby on robots? Check out our sister project Artoo (http://artoo.io)

Want to use the Go programming language to power your robots? Check out our sister project Gobot (http://gobot.io).

Build Status Code Climate Test Coverage

How to Install

Setting up your Intel Edison

Everything you need to get started with the Edison is in the Intel Getting Started Guide located here. Don't forget to configure your Edison's wifi connection and flash your Edison with the latest firmware image!

In order to enable Ethernet over USB on your Edison, follow the appropriate guide for your OS

Windows
  • Go to control panel -> network and sharing center -> change adaptor settings
  • When you plug both usb cables into your computer, you should see a new network device show up
  • Right click on the new device and select properties
  • Scroll down to IPv4 and select properties
  • Select "Use the following IP address"
  • Set the IP information to:
    • IP address: 192.168.2.1
    • Subnet mask: 255.255.255.0
    • Default gateway: 192.168.2.255
    • Preferred DNS server: 8.8.8.8
  • Save the changes
  • open putty
  • ssh to 192.168.2.15
  • The user is 'root' and the password is what you configured during the getting started guide
OS X
Linux
  • Examine your /etc/network/interfaces file, if you do not have this line, you must add it and then restart your computer
iface usb0 inet dhcp
  • Plug your Edison into your computer
  • $ sudo ifconfig usb0 192.168.2.1 255.255.255.0
  • $ ssh [email protected]

The Edison is now able to use it's wifi connection to reach the internet and your local USB to Ethernet connection for local ssh access and programming. If you have problems reaching the internet, you may need to setup the DNS on your Edison.

Execute the following command on the Edison itself

# cat "nameserver 8.8.8.8 > /etc/resolv.conf"

If you have a valid wifi connection, you should be able to reach out of your network!

Ethernet over USB internet sharing

If you are using ethernet over USB then you can enable internet sharing on your Edison by executing this command on the Edison itself

/sbin/route add default gw 192.168.2.1

Now you're ready to install MRAA and Cylon.

Setting up your Intel Galileo

In order to use cylon-intel-iot on your Galileo, you need to install the Intel IoT linux boot image onto an sd card. You can download the latest image here.

For Windows hosts you can follow the instruction for flashing your sd card image here.

For Mac or Linux hosts, it's as easy as extracting the image from the downloaded archive and executing the command

$ sudo dd if=/path/to/iot-devkit-latest-mmcblkp0.direct of=/dev/sdX bs=1M && sudo sync

where /dev/sdX is the location of your sd card. For help determing the location of your sd card, consult the appropriate guide for your OS below.

OS X Users

To prepare your SD card for flashing on OS X, you need to find out it's drive name and eject the volume.

To find the name, use the built-in diskutil utility:

$ diskutil list
/dev/disk0
  #:                       TYPE NAME                    SIZE       IDENTIFIER
  0:      GUID_partition_scheme                        *500.3 GB   disk0
  1:                        EFI EFI                     209.7 MB   disk0s1
  2:                  Apple_HFS Macintosh HD            499.4 GB   disk0s2
  3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
/dev/disk1
  #:                       TYPE NAME                    SIZE       IDENTIFIER
  0:     FDisk_partition_scheme                        *15.7 GB    disk1
  1:             Windows_FAT_32 NO NAME                 15.7 GB    disk1s1

According to this, our SD card is found at /dev/disk1.

Before you flash it with the above dd command, use diskutil to eject the existing volume (disk1s1):

$ diskutil unmount /dev/disk1s1
Linux Users

To prepare your SD card for flashing on Linux, you need to find the device location of your SD card. An easy way to determin the location is by filtering the /dev/ directory for new storage devices. Before you plug in your SD card, execute the following ls command

$ ls -l /dev/sd*
brw-rw---- 1 root disk 8,  0 Sep 16 21:48 /dev/sda
brw-rw---- 1 root disk 8,  1 Sep 16 21:48 /dev/sda1
brw-rw---- 1 root disk 8,  2 Sep 16 21:48 /dev/sda2
brw-rw---- 1 root disk 8,  5 Sep 16 21:48 /dev/sda5

You can see that I only have one storage device /dev/sda. Now plug in your SD card and execute the ls command again

$ ls -l /dev/sd*
brw-rw---- 1 root disk 8,  0 Sep 16 21:48 /dev/sda
brw-rw---- 1 root disk 8,  1 Sep 16 21:48 /dev/sda1
brw-rw---- 1 root disk 8,  2 Sep 16 21:48 /dev/sda2
brw-rw---- 1 root disk 8,  5 Sep 16 21:48 /dev/sda5
brw-rw---- 1 root disk 8, 16 Sep 17 17:46 /dev/sdb
brw-rw---- 1 root disk 8, 17 Sep 17 17:46 /dev/sdb1
brw-rw---- 1 root disk 8, 18 Sep 17 17:46 /dev/sdb2

You can see from this output that I now have a new storage device /dev/sdb. That is the location of my SD card, so in this instance the /dev/sdX in our dd command will be /dev/sdb.

After the image has been flashed to your sd card, install the sd card into the Galileo, connect it to your local network and power it up!

Now you're ready to install MRAA and Cylon.

Install MRAA

After you have flashed your Intel board and connected it to a network, you must now install the latest version of the Intel MRAA library. In order to update MRAA you simply log into your Intel board, through ssh or the uart serial connection, and follow the steps here.

Install Cylon.js

Once you have flashed your Intel board with the latest firmware as well as updated MRAA, you will now install cylon-intel-iot. To do this you must be logged into the board, through ssh or the uart serial connection, and execute the following command

$ npm install cylon cylon-intel-iot

Once cylon-intel-iot has been installed , you're ready to start programming!

How to Use

Blinking the built in LED

var Cylon = require('cylon');

Cylon.robot({
  connections: {
    edison: { adaptor: 'intel-iot' }
  },

  devices: {
    led: { driver: 'led', pin: 13 }
  },

  work: function(my) {
    every((1).second(), my.led.toggle);
  }
}).start();

Bluetooth Programming on the Intel Edison featuring Sphero

The Edison includes a bluetooth radio right on the board itself, so it's easy to get started programming bluetooth devices out of the box. First we need to enable bluetooth on the Edison.

  • ssh into your Edison
  • # rfkill unblock bluetooth
  • # bluetoothctl
    • [bluetooth]# scan on
    • Find your Sphero and take note of the MAC address
    • [bluetooth]# scan off
    • [bluetooth]# pair [MAC address of Sphero]
    • [bluetooth]# exit
  • # rfcomm bind 0 [MAC address of Sphero] 1
  • This will create a sphero connection bound to /dev/rfcomm0
  • # npm install cylon cylon-intel-iot cylon-sphero

This example will flash the built in LED whenever the Sphero detects a collision

var Cylon = require('cylon');

Cylon.robot({
  connections: {
    edison: { adaptor: 'intel-iot'},
    sphero: { adaptor: 'sphero', port: '/dev/rfcomm0' }
  },

  devices: {
    led: { driver: 'led', pin: 13, connection: 'edison' },
    sphero: { driver: 'sphero', connection: 'sphero' }
  },

  work: function(my) {
    console.log("Setting up Collision Detection...");
    my.sphero.stop();
    my.sphero.detectCollisions();

    my.sphero.on('collision', function() {
      console.log("Collision");
      my.led.toggle();
    });
  }
}).start();

How to Connect

The Intel Edison Getting Started Guide details connection instructions for Windows, Mac and Linux.

Documentation

We're busy adding documentation to our web site at http://cylonjs.com/ please check there as we continue to work on Cylon.js

Thank you!

Contributing

For our contribution guidelines, please go to https://github.com/hybridgroup/cylon/blob/master/CONTRIBUTING.md .

Release History

For the release history, please go to https://github.com/hybridgroup/cylon-intel-iot/blob/master/RELEASES.md .

License

Copyright (c) 2013-2015 The Hybrid Group. Licensed under the Apache 2.0 license.

cylon-intel-iot's People

Contributors

deadprogram avatar edgarsilva avatar stewart avatar zankavrogin avatar zankich 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.