i2c-bus - A new Node.js I2C module

I’ve written a new Node.js module called i2c-bus for accessing I2C devices on Linux boards like the BeagleBone Black.

It can be found here on github: https://github.com/fivdi/i2c-bus

Can you describe any advantages it has over node-i2c?

Sure, here are a number of things that come to mind:

  • All methods have asynchronous and synchronous forms (i2c has the synchronous form although it looks like it has the asynchronous form)
  • It offers more complete support for the SMBus protocols (quick command, send byte, receive byte, write byte/word, read byte/word, I2C block transaction (I2C block transaction are not part of the SMBus specification))
  • It supports plain I2C (see methods i2cRead, i2cReadSync, i2cWrite, i2cWriteSync)
  • It offers runtime information about the functionality supported by the bus/adapter (like ‘i2cdetect -F 1’, see methods i2cFuncs and i2cFuncsSync, see example https://github.com/fivdi/i2c-bus/blob/master/example/i2cdetect.js)
  • One i2c-bus object can handle multiple devices
  • Because it supports the SMBus receive byte protocol (see methods receiveByte and receiveByteSync) it’s possible to scan for devices (like ‘i2cdetect -y -r 1’, see example https://github.com/fivdi/i2c-bus/blob/master/example/i2cscan.js). This resolves https://github.com/kelly/node-i2c/issues/27

There is one more thing:

  • i2c-bus is io.js and Node.js compatible - tested with io.js 1.0.2 on a BeagleBone Black running Ubuntu 14.04.1 LTS (GNU/Linux 3.14.26-ti-r43 armv7l)

Thanks for this, I was looking at node-i2c & how to implement scan & went all cross eyed.

Why do I get this error? I was just including i2c-bus in the project like this. I am using nodejs v0.10.40 on Raspberry Pi 2 Raspbian:

var i2c = require(‘i2c-bus’);

pi@raspberrypi ~/Projects/noderadio $ sudo nodejs noderadio2.js

throw e
Error: /home/pi/Projects/noderadio/node_modules/i2c-bus/build/Release/i2c.node: undefined symbol: node_module_register

This is an odd place for a question about the Raspberry Pi :slight_smile:

A guess would be that i2c-bus, which is a native addon, was installed with one version of Node.js but is being run with another version of Node.js. Reinstall i2c-bus and try again.