Closed Duvel closed 11 years ago
I'm now using this for the constructor: var wire = new i2c(0x18, {debug:false, device:'/dev/i2c-1'});
Can you post your code from #1 with all the changes for 0.1.0?
I'm now using this:
var i2c = require('i2c'); //using in 0.0.5 as well 0.1.0 //var wire = new i2c('/dev/i2c-1'); //using only in 0.1.0 var wire = new i2c(0x18, {debug:false, device:'/dev/i2c-1'}); // point to your i2c device, debug provides REPL interface
//using in 0.0.5 //wire.write(4, ["RSI".charCodeAt(0), "RSI".charCodeAt(1), "RSI".charCodeAt(2)], function(err) {}); //using in 0.1.0 wire.writeBytes(4, ["RSI".charCodeAt(0), "RSI".charCodeAt(1), "RSI".charCodeAt(2)], function(err) {});
I think you need:
var wire = new i2c(4, {debug:false, device:'/dev/i2c-1'}) // 4 is the address for your arduino
wire.writeBytes(0x00, "RSI", function(err) {});
the first argument in writeBytes is a command byte which is required by the i2c-dev interface.
Yup, that works. I thought that was the address, that is assigned to the RPi.
The first argument is BTW also send to Arduino, so it seems that the i2c-dev doesn't do anything with it.
Sweet!
Most i2c device communication is a command, followed by a series of bytes. So, it's a little awkward in your case. I may try to abstract that bit in the code. So you could just pass in two or three arguments. In the meantime, this should work:
wire.writeBytes("R", "SI", function(err) {});
in the next release, this will work:
wire.writeBytes("RSI", function(err) {});
Yup, I thought of that workaround already as well. And it isn't really strange to do it, as it is my current way of telling, what I want to do and then send the arguments.
Thx for the help!
If I use my code from #1 and change it to the new writeBytes nothing happens at all, no clue at what is wrong.