kelly / node-i2c

Node.js native bindings for i2c-dev. Plays well with Raspberry Pi and Beaglebone.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem connecting DS1672 (RTC)

omkarkhair opened this issue · comments

commented

I'm new to I2C on Node.js and I'm not sure about the address to use, while connecting the RTC with my BeagleBone Black.

I want to periodically read data from the RTC. Here's my code.

var i2c = require('i2c');
var address = 0xD1;
var wire = new i2c(address, {device: '/dev/i2c-1', debug: false});

function read(){
        wire.readBytes(0x00,10,function(err,byte){
                console.log(byte);
        });
}

setInterval(read, 2000);

I am using 0xD1 as the address as per the datasheet, but this gives me a 'Failed to set address' error.

try sudo ...

commented

I'm as root on a beaglebone black. Can't sudo.

Also, The address is supposed to be the device address right? The datasheet says the device is at 0xD1 while i2cdetect shows it at 0x68.

Which one should it be?

try 0x68

commented

0x68 works. I couldn't just go ahead without an explanation. This might have been obvious, but took me a while when I gave it look again this weekend.

The datasheet uses a 7-bit address which translates to 0xD0, the library adds a 0 prefix to make it 0x68