I2C on Cubieboard with Lubuntu

I2C bus is used by many integrated circuits and is simple to implement. Any microcontroller can communicate with I2C devices even if it has no special I2C interface so I wanted to enable I2C also in my Cubieboard2 to get direct access to sensors.

Following commands are useful for I2C interface:

  • i2cdetect (used to detect slaves address in the bus)
  • i2cdump (used get a range of values)
  • i2cget (used to get a value)
  • i2cset (used to set a value)

You can install them from one package:

sudo apt-get install i2c-tools

To check your connected I2C devices run:

 sudo i2cdetect -y -r 1

No device is recognized yet

I followed the how-to by cubieboard to enable I2C port on my lubuntu cubieboard2:

sudo mount /dev/nanda /mnt
cd /mnt
sudo bin2fex script.bin script.fex
sudo vi script.fex

I changed only i2c (twi)- I selected the one that was already configured to PB18/19 twi1_para. Pin #6 is SCL and pin #7 is SDA (U15 – the pin array near the USB-Ports). Refer to pin definition (or this PDF) :

5 PG0 (CSI1-PCLK/SDC1-CMD) 6 PB18 (TWI1-SCK)
7 PB19 (TWI1-SDA) 8 PG3 (CSI1-VSYNC/SDC1-D1)

[twi1_para]
twi1_used = 1
twi1_scl = port:PB18<2><default><default><default>
twi1_sda = port:PB19<2><default><default><default>

Save the file and convert it back to script.bin:

sudo fex2bin script.fex script.bin
sudo reboot

 

Connect your I2C device (BMP085 sensor in my case) and now test the I2C interface.

BMP085 connected to cubieboard2 and powered from arduino 3.3V (you can power the sensor also from the cubieboard 3.3V PIN/GND)

sudo i2cdetect -r 1


I have connected BMP085 that is preconfigured with address 0x77 detected by i2cdetect.
In my next post, you can see how I programmed cubieboard to get data from the BMP085 barometric pressure sensor –> cubieboard-with-bmp085-barometer
In Cubian the /dev/i2c/1 is already preconfigured (cubian follow this guide http://wp.applesandoranges.eu/?p=48)
Other usefull links:


Related Posts

Cubieboard2 – Lubuntu – Xterm Copy/Paste

As you can find out the normal copy paste is not working in Lubuntu Xterm.This blog: http://www.davidsimmons.com/soft/xtermhacks/ looks to me too complicated. I just have to get used to my mid mouse button that will copy+paste the[…]

Continue reading ...

Cubieboard with BMP085 Barometer, Alittute, Temperature

I’ve bought  BMP085 barometric pressure sensor and my goal was to get pressure and temperature data via I2C interface to my Cubieboard running linux (cubieboard2-lubuntu-installation).

Continue reading ...

Cubieboard2 – Lubundu – Extending NAND from 2GB to 4GB

When I install new Lubuntu NAND image to my new Cubieboard2 I had only 2GB of space out of 4GB available. I followed this forum to expand the filesystem to 4GB. sudo nand-part In my[…]

Continue reading ...