Git Product home page Git Product logo

cylon-i2c's Introduction

Cylon.js For i2c

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

This module provides drivers for i2c devices (https://en.wikipedia.org/wiki/I%C2%B2C). You must use this module alongside Cylon.js adaptors that have i2c support, such as cylon-firmata.

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

Getting Started

Install the module with: npm install cylon cylon-i2c

Note you must also install whichever adaptor you want to use, such as: npm install cylon-firmata

Example

var Cylon = require('cylon');

// Initialize the robot
Cylon.robot({
  connections: {
    arduino: { adaptor: 'firmata', port: '/dev/ttyACM0' }
  },

  devices: {
    blinkm: { driver: 'blinkm'}
  },

  work: function(my) {
    var lit = false;
    my.blinkm.off()
    every((1).seconds(), function() {
      if (lit === true) {
        lit = false;
        my.blinkm.rgb(0xaa, 0, 0);
      } else {
        lit = true;
        my.blinkm.rgb(0, 0, 0);
      }
    });
  }
}).start();

Hardware Support

Cylon.js has a extensible system for connecting to hardware devices. The following 15 different i2c devices are currently supported:

  • BlinkM RGB LED
  • BMP180 Barometric Pressure + Temperature sensor
  • Direct I2C
  • HMC5883L 3-Axis Digital Compass
  • HMC6352 Digital Compass
  • JHD1313M1 LCD with RGB Backlight
  • LCD
  • LIDAR-Lite
  • LSM9DS0G 9 Degrees of Freedom IMU
  • LSM9DS0XM 9 Degrees of Freedom IMU
  • MAG3110 3-Axis Digital Magnetometer
  • MPL115A2 Digital Barometer & Thermometer
  • MPU6050 Triple Axis Accelerometer and Gyro
  • PCA9544a 4-Channel I2C Mux
  • PCA9685 16-Channel 12-bit PWM/Servo Driver

More drivers are coming soon...

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-i2c/blob/master/RELEASES.md .

License

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

cylon-i2c's People

Contributors

deadprogram avatar edgarsilva avatar jribble avatar justindevelopment avatar rafmagana avatar stewart avatar szimano avatar wojtekerbetowski avatar xixebombilla avatar zankavrogin avatar zankich avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cylon-i2c's Issues

Driver MPU6050 not working as expected.

Hello!
I'm starting with Cylon, I'm testing with arduino and mpu6050, but I am getting this error below. Any idea?

C: \ Users \ Marcelo \ node_modules \ cylon-i2c \ lib \ mpu6050.js: 84
var x = makeSignedInteger (data [0], data [1]),
^
TypeError: Can not read property '0 'of null
at C: \ Users \ Marcelo \ node_modules \ cylon-i2c \ lib \ mpu6050.js: 84:36
at null (C:. \ Users \ Marcelo \ node_modules \ cylon-Firmata \ lib \ Firmata
. js: 103:5)
at g (Events.js: 180:16)
emit at (Events.js: 95:17)
at Object.SYSEX_RESPONSE (anonymous function) the 119
at SerialPort (C:. \ Users \ Marcelo \ node_modules \ cylon-Firmata \ node_
modules \ Firmata \ lib \ firmata.js: 444:59)
at SerialPort.emit (Events.js: 95:17)
Object.module.exports.raw at the parser
at SerialPort.options.dataCallback (C: \ Users \ Marcelo \ node_modules \ cylon-firm
ata \ node_modules \ Firmata \ node_modules \ serialport \ serialport.js: 145:15)

I'm sorry if you're making a mistake in the form to request help for this error.

Moved this from cylon to cylon-i2c, @MarceloTomaz @solojavier

I2C lcd backlight flickering on Arduino Yún

I am having issues running the i2c lcd example on my Arduino Yùn. (https://cylonjs.com/documentation/drivers/lcd/)
I have a SunFounder I2C LCD1602. I am using OpenWrt. I setup everything on the Yún following the instructions on the CylonJs website.
I am guessing the problem is with the cylon I2C driver library since other Cylon js examples work fine.
Problem:
When I do the wiring of the example, the backlight of the lcd is bright and stable but when I start the script the text shows fine but the backlight starts to flicker. I tried both with and without the 4.7k resistors even though they shouldn't be necessary since the arduino has integrated pull-up resistors.

Any help would be really appreciated!! Thanks

i2c blocking with multiple devices

I tried using two i2c devices but i get event errors with this setup.

    devices: {
        pca: { driver: 'pca9685' },
        gyro: { driver: 'mpu6050' }
    },

The error is

events.js:141
      throw er; // Unhandled 'error' event
      ^

Error: ENXIO, No such device or address
    at Error (native)

I have to comment out one device for it to work. I wasn't able to pin point the exact point in the code(cylon core or i2c driver) that does the blocking but if anyone can please point it out and i'll work on it. @deadprogram. There might be a callback that gets executed and closes out i2c after the first device.

BMP180 not working

I couldn't make the BMP180 example run. I'm using the BMP version with only 4 pin and an RPi3, though I'm guessing those two should not make a difference.
I was using the example code found in cylon website, and after compiling there were no measurements at all. Temp at 0 and pressure at infinite. Later, I added the bmp180.start before taking measurements and I started seeing some rawTemp numbers, but they just didn't make sense.

Is my screen incompatible ?

Hello,

I've bought a kit with some components, and in this kit there was a 1602 LCD screen (16*2) : kit here

After trying this in my code :

lcdScreen: {driver: 'lcd'}

and this :

my.lcdScreen.print("test");

It doesn't work at all.

So I've tried using this LCD Library, and with this code it worked.

So I just wanted to know if I'm doing something bad, or if it's not compatible at all.

Thanks

How to register just created new driver

Here is the issue:
Take a look at this project structure:

as always package.json has all dep

{
"dependencies": {
    "cylon": "^1.3.0",
    "cylon-firmata": "^0.24.0",
    "cylon-gpio": "^0.29.0",
    "cylon-i2c": "^0.26.1"
  }
}

e.g. I install dependencies.
Than i want to install my custom driver for now all custom is in folder
drivers

here is the index.js
/drivers/ultrasonic/lib/ultrasonic.js
and the driver

here is the actual program that i am running

so i made following steps:

  1. $ npm i
    2)$ npm i ./drivers/ultrasonic
    3)$ node src/js/ultrasonic

  2. and i get Cannot find the 'cylon-ultrasonic' module.
    This problem might be fixed by installing it with 'npm install cylon-ultrasonic' and trying again.

if i add my driver here: .\node_modules\cylon-i2c\lib\ultrasonic.js

and add it to the index.js file .\node_modules\cylon-i2c\index.js

var Drivers = {
  // ...
  "ultrasonic": require("./lib/ultrasonic")
};
  • the problem is became solved when we add it to the node_modules folder

So for now i has resolved that by forking i2c and link to my fork in the package.json but i need to update fork manually all the time is there any better solution for that?

Any advice on edison + LSM9DS0

Thanks for the module, I have used it successfully with a Yun with MPU6050, but having a problem getting the gyro example to work.

My setup is an Intel Edison, LSM9DS0 (https://www.sparkfun.com/products/13033) and the cylon-intel-iot as the adapter.

i2c seems to have correct addresses on the edison for the gyro and accel/mag

i2cdetect -y -r 1

 0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f

00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- 1d -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- 6b -- -- -- --
70: -- -- -- -- -- -- -- --

I modified the gyro example as so

"use strict";

var Cylon = require("cylon");

Cylon
.robot()
.connection("edison", { adaptor: "intel-iot"})
.device("gyro", { driver: "lsm9ds0g" })

.on("ready", function(bot) {
setInterval(function() {
bot.gyro.getGyro(function(err, data) {
console.log(data);
});
}, 1000);
});

Cylon.start();

But the output is not correct, and doesn't change in relation to the movement of the device.

I, [2015-02-12T23:58:31.435Z] INFO -- : Initializing connections.
I, [2015-02-12T23:58:31.450Z] INFO -- : Initializing devices.
I, [2015-02-12T23:58:31.725Z] INFO -- : Starting connections.
I, [2015-02-12T23:58:31.730Z] INFO -- : Starting devices.
I, [2015-02-12T23:58:31.741Z] INFO -- : Working.
{ x: 8224, y: 8224, z: -515 }
{ x: 8224, y: 8224, z: -515 }
{ x: 8224, y: 8224, z: 8297 }
{ x: 8224, y: 8224, z: 8297 }
{ x: 8224, y: 8224, z: 8297 }
{ x: 8224, y: 8224, z: 8297 }
{ x: 8224, y: 8224, z: 8297 }
{ x: 8224, y: 8224, z: 8297 }
{ x: 8224, y: 8224, z: 8297 }

The same output for similar changes to demo for getAccel.

I appreciate any advice on approaches I might take to identify the issue and/or get this to work? I have limited experience with i2c on linux, so may be a basic mistake.

Thanks much!

i2c connection problem with hmc 6352 compass module

Currently I'm working on a drone navigation project using AR_Drone2 with Arduino Yun.

Basic setup to install cylon.js on Arduino Yun was based on this page with @edgarsilva 's help.

hybridgroup/cylon#212 (comment)

And now I'm trying to use the compass module (hmc6352) to get the heading of my drone but when i run a simple code

var Cylon = require('cylon');

Cylon.robot(
{connection:
{name: 'arduino', adaptor: 'firmata', port: '/dev/ttyATH0'},

device:
{name: 'hmc6352', driver: 'hmc6352'},

work: function(my) {
every((1).second(), function() {
my.hmc6352.heading(function(data) {
Logger.info("heading: " + data);
});
});
}}
).start();

I get this error

/root/drone/node_modules/cylon/lib/utils.js:124
return target[method].apply(target, arguments);
^
TypeError: Cannot call method 'apply' of undefined
at Adaptor.base.(anonymous function) as i2cConfig
at Connection.base.(anonymous function) as i2cConfig
at Hmc6352.start (/root/drone/node_modules/cylon-i2c/lib/hmc6352.js:26:19)
at Device.start (/root/drone/node_modules/cylon/lib/device.js:60:22)
at /root/drone/node_modules/cylon/node_modules/async/lib/async.js:568:25
at /root/drone/node_modules/cylon/node_modules/async/lib/async.js:118:13
at Array.forEach (native)
at _each (/root/drone/node_modules/cylon/node_modules/async/lib/async.js:39:24)
at Object.async.each (/root/drone/node_modules/cylon/node_modules/async/lib/async.js:117:9)
at _parallel (/root/drone/node_modules/cylon/node_modules/async/lib/async.js:567:20)

What is wrong with this code?
(I connected the compass module's sda scl pins to Arduino Yun's sda scl pins)

Device agnostic driver

Is there no way to use this module for a device not part of the driver list ?

I have a TI fuel gauge (BQ-27441), which is a battery sensor that reads battery information like current, voltage , temp etc. of the battery. I have connected it to my ras-pi, via I2C.

Any way I can leverage this module for use with that ?

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.