fivdi / i2c-bus

I2C serial bus access with Node.js
MIT License
348 stars 57 forks source link

write method error #2

Closed wakatanka closed 9 years ago

wakatanka commented 9 years ago

Hi, i'm trying to use you module to connect a raspberryPi with a i2c temperature sensor (sht21) My problem is that i've got this error when i try to write the first command:

buffer.js:246 switch (encoding && encoding.toLowerCase()) { ^ TypeError: Object 1 has no method 'toLowerCase'

here is my code, it seems that the error is on the length parameter

ar i2c = require('i2c-bus'), i2c1 = i2c.openSync(1);

var tm = 0x40, bff = new Buffer(4); bff = 0xF3;

i2c1.i2cWrite(tm, 1, bff, function(err, bytesWritten,buffer) { console.log(err); });

thanks

fivdi commented 9 years ago

The third argument bff passed to i2cWrite in the example code is a number but should be a buffer. I guess:

bff = 0xF3;

Should be:

bff[0] = 0xF3;