mistertransistor
Posts: 1
Joined: Thu Feb 23, 2012 6:32 pm

Re: I2C bus - anyone planning to use it?

Thu Feb 23, 2012 6:50 pm

I want to connect an ADS1115 and do some data acquisition. I already have such a system under Arch linux on an HP Neoware e90 (also called CA21 for some reason) but I need to use serial port emulation over USB over I2C which is a pain. The R-Pi should cut all that out. My current software is in Java but I could switch to C.

Anyone else wanting to use I2C devices?

Andrew

Chris.Rowland
Posts: 239
Joined: Thu Jan 12, 2012 5:45 pm

Re: I2C bus - anyone planning to use it?

Thu Feb 23, 2012 8:47 pm

I can imagine hanging all sorts of things on the I2C bus, all manner of sensors and so on.  Not least a RTC chip.

I think there's a need for an I2C patch board, with the I2C bus, 3V3 to 5V level shifters on the bus and breadboard areas that can take different ICs or breakout boards.

And maybe a serial port.

The trick may be to avoid putting too much on.

Chris

error404
Posts: 351
Joined: Wed Dec 21, 2011 11:49 pm

Re: I2C bus - anyone planning to use it?

Thu Feb 23, 2012 11:07 pm

Definitely.

Don't think you'll really need level conversion for I2C, it's open-collector. Most devices will run fine on 3V3, and even if they are 5V devices, they should still operate properly with 3V3 pull-ups.

If you just want I2C on your PC though, using i2c-tiny-usb is a good solution. Couple bucks in parts if you have an AVR programmer already (or want to build one), and there's a driver in mainline. http://www.harbaum.org/till/i2.....ndex.shtml

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4257
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: I2C bus - anyone planning to use it?

Thu Feb 23, 2012 11:50 pm

I2C level conversion is really easy: http://ics.nxp.com/support/doc.....n97055.pdf

RAThomas
Posts: 7
Joined: Mon Feb 06, 2012 7:03 pm
Contact: Website

Re: I2C bus - anyone planning to use it?

Sat Feb 25, 2012 2:39 am

mistertransistor said:



Anyone else wanting to use I2C devices?

Andrew


Oh, yes.  Sparkfun (and others, I"m sure) have some nice, small accelerometers, electronic gyros and other sensor modules for sale (big in the Arduino arena) that talk via I2C that I"d just *love* to interface with a Pi.

I really must research what drivers may already be out there for such devices first, but I"m ARMed (heh, heh) with a couple of Linux driver development books and ain"t afraid to get my hands dirty!

Simon H
Posts: 156
Joined: Sun Jan 08, 2012 2:41 pm

Re: I2C bus - anyone planning to use it?

Sun Feb 26, 2012 1:59 pm

Definately, it will be the first thing I will be getting working.

I use I2C for 24x4 LCD displays, DS1307 RTC, temerature sensor IC's and I/O expanders currently all connected to an Arduino for Home automation.

Also at work I2C is the main communication between many IC's on the system boards and the method of the boads talking to PSU's and Back Planes etc in the high end servers I work on.

Due to the limited IO currently on the PI I will probably still be using a Arduino connected to the PI instead of a PC as is currently the case but moving the I2C to the PI to cut out some of the inter board comms. Looking forward to making a nice HA Desktop/TV gui and a server for my android app on my PI.

strigona
Posts: 5
Joined: Sun Feb 26, 2012 7:02 pm

Re: I2C bus - anyone planning to use it?

Sun Feb 26, 2012 7:11 pm

mistertransistor said:


I want to connect an ADS1115 and do some data acquisition. I already have such a system under Arch linux on an HP Neoware e90 (also called CA21 for some reason) but I need to use serial port emulation over USB over I2C which is a pain. The R-Pi should cut all that out. My current software is in Java but I could switch to C.

Anyone else wanting to use I2C devices?

Andrew



Can I ask what libraries (if any) you used to communicate with I2C from Java?

PaulTech
Posts: 25
Joined: Sat Mar 03, 2012 1:21 am

Re: I2C bus - anyone planning to use it?

Sat Mar 03, 2012 2:04 am

Simon H said:


Definately, it will be the first thing I will be getting working.

I use I2C for 24x4 LCD displays, DS1307 RTC, temerature sensor IC"s and I/O expanders currently all connected to an Arduino for Home automation.

Also at work I2C is the main communication between many IC"s on the system boards and the method of the boads talking to PSU"s and Back Planes etc in the high end servers I work on.

Due to the limited IO currently on the PI I will probably still be using a Arduino connected to the PI instead of a PC as is currently the case but moving the I2C to the PI to cut out some of the inter board comms. Looking forward to making a nice HA Desktop/TV gui and a server for my android app on my PI.

Really need an Arduino Shield adaptor for R-Pi

Docteh
Posts: 32
Joined: Tue Jan 31, 2012 6:20 am

Re: I2C bus - anyone planning to use it?

Sat Mar 03, 2012 7:05 am

I plan on using i2c, i think the only 5v device i will be using is a battery backed rtc. Gotta make sure its voltage is above vbatt or it keeps running off of vbatt.

Recently bought the barometer and light sensors from adafruit for hooking up to raspberry pi actually.

Edit: i reread the datasheets for DS3231 and DS3232 not sure why i thought i had to run them at higher than vbatt. As long as vcc is above 2.73 it will run off vcc instead of vbatt.

johankj
Posts: 10
Joined: Tue Mar 06, 2012 2:07 pm

Re: I2C bus - anyone planning to use it?

Tue Mar 06, 2012 2:21 pm

Chris Rowland said:


I can imagine hanging all sorts of things on the I2C bus, all manner of sensors and so on.  Not least a RTC chip.

I think there's a need for an I2C patch board, with the I2C bus, 3V3 to 5V level shifters on the bus and breadboard areas that can take different ICs or breakout boards.

And maybe a serial port.

The trick may be to avoid putting too much on.

Chris



I plan to use the RPi's (as I see it's abriviated to ) I2C interface, and I too have been looking for a way to interface I2C directly. I see there are some suggestions to use USB-serial adapters and microcontrolers, as intermediaries, but for my part, this is out of the question.

There is a short example/tutorial on programming the GPIO in C, and would think the procedure for I2C would be similar. There may be some info in the datasheet for the CPU, I will read it when I get home.

The RPi's low power, high performance, small footprint, and Linux and I2C support, makes this THE ideal candidate for my project.

johankj
Posts: 10
Joined: Tue Mar 06, 2012 2:07 pm

Re: I2C bus - anyone planning to use it?

Tue Mar 06, 2012 2:27 pm


There is a short example/tutorial on programming the GPIO in C, and would think the procedure for I2C would be similar. There may be some info in the datasheet for the CPU, I will read it when I get home.


Here it is!

strigona
Posts: 5
Joined: Sun Feb 26, 2012 7:02 pm

Re: I2C bus - anyone planning to use it?

Wed Mar 07, 2012 12:52 am

johankj said:



There is a short example/tutorial on programming the GPIO in C, and would think the procedure for I2C would be similar. There may be some info in the datasheet for the CPU, I will read it when I get home.


Here it is!



The link doesn't work..

epam
Posts: 3
Joined: Wed Mar 07, 2012 1:24 am

Re: I2C bus - anyone planning to use it?

Wed Mar 07, 2012 1:36 am

Maybe these can be helpful:


linux/Documentation/i2c/dev-interface
linux/Documentation/i2c/instantiating-devices

Naturally, a library could make things easier.

strigona
Posts: 5
Joined: Sun Feb 26, 2012 7:02 pm

Re: I2C bus - anyone planning to use it?

Wed Mar 07, 2012 2:23 am

@epam, Thanks for the links, I have come across the C interface to I2C/SMBus through my own research.

I'm curious if anyone has any plans to use Java to communicate to I2C devices. As far as I can tell, there are no Java -> I2C libraries available. (I've found some that are for "bare metal" Java - which isn't compatible with Java for Linux).

If anyone else is looking for this functionality would you be interested in collaborating to create a JNI wrapper around the C methods? It'd be my first time developing JNI - but the C interface doesn't look very complicated so I'd like to think it's a fairly manageable project.

I'd love to hear some input on Java -> I2C.

Simon

johankj
Posts: 10
Joined: Tue Mar 06, 2012 2:07 pm

Re: I2C bus - anyone planning to use it?

Wed Mar 07, 2012 8:46 am

johankj said:


Database Error
Error establishing a database connection


Sorry, here it is:

epam
Posts: 3
Joined: Wed Mar 07, 2012 1:24 am

Re: I2C bus - anyone planning to use it?

Wed Mar 07, 2012 10:39 am

Well Johankj, in the link you have mentioned it reads:


The Foundation will not include an I2C driver in the initial release, we hope the community might provide one, standard linux I2C drivers should work with minimal modification.


There is a possibility that initially i2c is not fully operational but be patient. The main issue for you would be to open the i2c device and call ioctl from JNI, which probably cannot be done. However, you could create a wrapper to a complete C library, like i2c-tools, and not just to the particular functions.

Unfortunately, you have a C, C++ and Assembly fan here so good luck!

johankj
Posts: 10
Joined: Tue Mar 06, 2012 2:07 pm

Re: I2C bus - anyone planning to use it?

Wed Mar 07, 2012 11:34 am

epam said:


Well Johankj, in the link you have mentioned it reads:


The Foundation will not include an I2C driver in the initial release, we hope the community might provide one, standard linux I2C drivers should work with minimal modification.


There is a possibility that initially i2c is not fully operational but be patient. The main issue for you would be to open the i2c device and call ioctl from JNI, which probably cannot be done. However, you could create a wrapper to a complete C library, like i2c-tools, and not just to the particular functions.

Unfortunately, you have a C, C++ and Assembly fan here so good luck!



So, to get I2C working, I see two options:


Interface directly with the chip, see page 28-37 here.



modify existing Linux drivers so that they are compatible with this particular chip.

I'll be doing one of the above, probably 1., as I have no experience in writing Linux drivers.

I won't be using java (I don't speak java), probably just C, so I won't be able to help with those you use java.

RAThomas
Posts: 7
Joined: Mon Feb 06, 2012 7:03 pm
Contact: Website

Re: I2C bus - anyone planning to use it?

Fri Apr 13, 2012 2:38 pm

Is there anyone already working on developing a driver for the Broadcom BSC?  I'm looking into morphing an existing i2c driver into one to support the BSC and while it doesn't look like an onerous task, but I'd hate to spend time on redundant work.

If I am the only one looking at this now and since I don't have an RPi to test with yet, is there anyone out there who's in a position to test a new I2C driver in the near term?

strigona
Posts: 5
Joined: Sun Feb 26, 2012 7:02 pm

Re: I2C bus - anyone planning to use it?

Fri Apr 13, 2012 2:46 pm

I'm not aware of anyone developing a driver at this point. I hope to write a Java interface to the driver when one becomes available.

I'd be willing to help however I can with the driver development - even if it's just testing it.

selsinork
Posts: 151
Joined: Mon Apr 16, 2012 8:31 am

Re: I2C bus - anyone planning to use it?

Sun Apr 22, 2012 12:22 pm

RAThomas said:


Is there anyone already working on developing a driver for the Broadcom BSC?  I'm looking into morphing an existing i2c driver into one to support the BSC and while it doesn't look like an onerous task, but I'd hate to spend time on redundant work.

If I am the only one looking at this now and since I don't have an RPi to test with yet, is there anyone out there who's in a position to test a new I2C driver in the near term?


Someone else posted here http://www.raspberrypi.org/for.....io/#p52803 that he was going to write a driver, but I don't see anything else about his progress.

I have a Pi and would be willing to test anything you have - just thought I'd do a search first before I started looking at writing one myself !

larsth
Posts: 55
Joined: Sat Aug 27, 2011 9:51 pm
Contact: Website

Re: I2C bus - anyone planning to use it?

Sun Apr 22, 2012 3:07 pm

selsinork said:


RAThomas said:


Is there anyone already working on developing a driver for the Broadcom BSC?  I'm looking into morphing an existing i2c driver into one to support the BSC and while it doesn't look like an onerous task, but I'd hate to spend time on redundant work.

If I am the only one looking at this now and since I don't have an RPi to test with yet, is there anyone out there who's in a position to test a new I2C driver in the near term?


Someone else posted here http://www.raspberrypi.org/for.....io/#p52803 that he was going to write a driver, but I don't see anything else about his progress.

I have a Pi and would be willing to test anything you have - just thought I'd do a search first before I started looking at writing one myself !


I am the "he" in the above text.

You cannot interface with a host adapter driver from Java. It is impossible, because only a I²C client device driver inside the kernel can do that.

That you can do is to create to create a  generic JNI[1] Linux UIO  I²C client device driver. The UIO device driver will use system calls to speak with the "i2c-dev" I²C client device driver in kernel space. The i2c-dev client device driver does not directly speak with the hardware. The host adapter driver is responsible for that, because it know how to do I²C communication with the real I²C hardware.

[1]: http://java.sun.com/docs/books/jni/

- looks like to be a download-for-free book, knowledge of the C programming language is required to create JNI interfaces.

willanth
Posts: 4
Joined: Thu Apr 19, 2012 2:47 am

Re: I2C bus - anyone planning to use it?

Thu Apr 26, 2012 11:24 am

I plan to use most of the facilities on the GPIO, I2C especially.  Getting a good driver going for this would be great, I'd support that effort however I could.  My C is pretty rusty, but I would be willing to help out where I could.

Not, however, a big fan of Java.

Cheers,

Will

rotok
Posts: 3
Joined: Tue Sep 04, 2012 3:30 pm

Re: I2C bus - anyone planning to use it?

Wed Oct 03, 2012 8:54 am

Hi,

I haven't found i2c examples for java (maybe my fault), so I started to play with it.
It works with the Raspian Wheezy kernel driver, tested with Adafruit 16 channel pwm/servo driver (based on PCA9685).

Java files:
http://simonp.uw.hu/linuxi2c/linuxi2c_java_v0_1.zip

Setup the i2c driver:
http://www.skpang.co.uk/blog/archives/575

Install the proper jna package on raspberry and use the jna.jar, jna-platform.jar libs for the java app from /usr/share/java folder:
apt-get install libjna-java

Peter

User avatar
xranby
Posts: 539
Joined: Sat Mar 03, 2012 10:02 pm
Contact: Website

Re: I2C bus - anyone planning to use it?

Wed Oct 03, 2012 10:01 pm

rotok wrote: It works with the Raspian Wheezy kernel driver, tested with Adafruit 16 channel pwm/servo driver (based on PCA9685).

Java files:
http://simonp.uw.hu/linuxi2c/linuxi2c_java_v0_1.zip

Setup the i2c driver:
http://www.skpang.co.uk/blog/archives/575

Install the proper jna package on raspberry and use the jna.jar, jna-platform.jar libs for the java app from /usr/share/java folder:
apt-get install libjna-java

Peter
Thank you Peter! People have been looking for a Linux I2C Java binding for years and your code is the first publicly available binding, nice!
http://www.raspberrypi.org/phpBB3/viewt ... p?p=171691 - I2C with Java?
http://www.raspberrypi.org/phpBB3/viewt ... p?p=178646 - PI4J possibly a good project to host your I2C Java binding.
Xerxes Rånby @xranby I once had two, then I gave one away. Now both are in use every day!
twitter.com/xranby

User avatar
savageautomate
Posts: 230
Joined: Thu Aug 16, 2012 3:20 pm
Location: USA
Contact: Website

Re: I2C bus - anyone planning to use it?

Thu Oct 04, 2012 12:42 am

I would love to have I2C Java interface in the Pi4J project. @rotok, please contact me if you would like to join the project and commit. It may be nice to avoid the JNA dependency if possible and move whatever logic is necessary into the existing JNI layer. Pi4J already includes a native library with JNI wrappers around WiringPi.

There is a direct WiringPi wrapper class for SPI here:
https://github.com/Pi4J/pi4j/blob/maste ... i/Spi.java
I was hoping to create a "Javafied" wrapper around this ... just have not had the time to do so yet.
Robert Savage | Follow me @savageautomate
http://www.pi4j.com | http://www.pislices.com
http://www.savagehomeautomation.com

Return to “Other projects”