Closed jbaldwinroberts closed 11 years ago
Do you have pull-up resistors on the SDA and SCL?
I have tried both with and without and i get the same result. I don't think their needed as the pi has internal pull ups on the I2C lines.
Sending data works, just not receiving
Thanks
hmm, I'm not sure what's wrong. If I had an mbed device, i'd test it out, but a little difficult without one. I've had success reading from an Arduino and other devices.
Does anything change if you use readByte?
I have an Arduino, would you be able to post the code you tested it with and i'll see if it works. Thanks
Hi, so i tried readByte and it does not get into the callback, have I done something wrong?
var i2c = require('i2c');
var address = 0x08;
var wire = new i2c(address, {debug:false, device:'/dev/i2c-1'});
wire.readByte(function(err, res) {
console.log(res);
console.log("test");
});
Also my mBed is getting read twice when i run the above code not once?
Thanks
Here is a really basic example:
#include "Wire.h"
byte data[3] = {1, 2, 3};
void requestEvent()
{
Serial.println('requested');
Wire.write(data, 3);
}
void setup() {
Serial.begin(115200);
Wire.begin(4);
Wire.onRequest(requestEvent); // register event
}
void loop() {
delay(100);
}
Wire = require('i2c');
wire = new Wire(0x04, {
device: '/dev/i2c-0'
});
//0x00 cmd isn't used, but required
wire.readBytes(0x00, 3, function(err, res) {
return console.log(res);
});
Hi,
I'm having some problem with wire.readByteS
to.
wire.readByte
works on but wire.readByteS
never triggers requestEvent
.
Any ideas?
Hi,
Thanks for this.
Im trying to get communications working between a raspberry pi and an mBed.
My raspberry pi code is:
My mBed code is:
For some reason my mBed shows on my raspberry pi as 0x08 even though its address is set to 0x10, although i dont think this matters?
When i run the raspberry pi code my mBed outputs:
Write Addressed: 1 // This is equal to 49 converted to ASCII Read Addressed: 1234567890
and my raspberry pi outputs:
test 60 23 0 0 164 163 148 190 172 23
These numbers don't match what I'm sending and don't change when i change what I'm sending.
Any ideas?
Thanks
Joe