I2C Interface

Post Reply
WoHo
Posts: 4
Joined: Sat Dec 01, 2018 12:55 am
languages_spoken: english
ODROIDs: H2
Has thanked: 0
Been thanked: 0
Contact:

I2C Interface

Unread post by WoHo » Sat Dec 01, 2018 1:04 am

Hello!

I am very happy with my new H2, only one minor topic:

Have some issues getting the I2C interface working. I am sure, it is my fault. Any hint/link etc. would be great.
  • OS: Debian / Linux 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64 GNU/Linux
  • Added i2c-dev in /etc/modules
  • Installed the i2c-tools
There are no i2c devices in /dev listed.

Relevant parts of the syslog:

Code: Select all

Nov 29 21:26:14 … kernel: [ 4366.303820] i2c /dev entries driver
Nov 30 12:33:18 … kernel: [ 4661.452445] i2c /dev entries driver
Nov 30 12:57:02 … kernel: [    1.905167] i2c /dev entries driver
Nov 30 12:57:02 … systemd-modules-load[234]: Inserted module 'i2c_dev'
Nov 30 13:04:00 … kernel: [  421.061670] i2c-stub: Please specify a chip address
Nov 30 14:31:47 … systemd-modules-load[235]: Inserted module 'i2c_dev'
Nov 30 14:31:47 … kernel: [    2.001154] i2c /dev entries driver
Nov 30 16:47:01 … systemd-modules-load[236]: Inserted module 'i2c_dev'
Nov 30 16:47:01 … kernel: [    2.039288] i2c /dev entries driver
Hope, I read the Wiki carefully …

Thanks WoHo

User avatar
mad_ady
Posts: 6390
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 146 times
Been thanked: 109 times
Contact:

Re: I2C Interface

Unread post by mad_ady » Sat Dec 01, 2018 4:42 am

I think it was tested with ubuntu, kernel 4.18+. Any chance you can update the kernel? Also, does your kernel have a i2c module? It might not be enabled in its defconfig.

User avatar
odroid
Site Admin
Posts: 31852
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 89 times
Been thanked: 255 times
Contact:

Re: I2C Interface

Unread post by odroid » Sat Dec 01, 2018 10:00 am

Right. We tested the I2C functionality on Kernel 4.18.

You have to use a backport kernel 4.18 package for Debian.
Once you boot Kernel 4.18, you can access I2C #6 via /dev/i2c-2.

Code: Select all

root@odroid:~# i2cdetect -y -r 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- 27 -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --    

WoHo
Posts: 4
Joined: Sat Dec 01, 2018 12:55 am
languages_spoken: english
ODROIDs: H2
Has thanked: 0
Been thanked: 0
Contact:

Re: I2C Interface

Unread post by WoHo » Sat Dec 01, 2018 7:09 pm

Thanks a lot. Installed kernel 4.18.0-0.bpo.1-amd64 and now it works.

WoHo

berniejonnie
Posts: 5
Joined: Sat Jan 05, 2019 7:54 pm
languages_spoken: english
ODROIDs: H2
Has thanked: 0
Been thanked: 0
Contact:

Re: I2C Interface

Unread post by berniejonnie » Sat Jan 05, 2019 8:01 pm

Hi,
I've been running in the same prob but no solution!
I installed Debian 9 and OMV. I added the Realtek firmware and installed the backport kernel "Linux 4.18.0-0.bpo.1-amd64", but still no /dev/i2c !
When I look for the driver I see:

Code: Select all

   root@OMV:~# lsmod |grep i2
   i2c_algo_bit           16384  1 i915
   i2c_i801               28672  0
What is wrong ? what is the correct module to load ?
Thanks for any hint...
/BJ

berniejonnie
Posts: 5
Joined: Sat Jan 05, 2019 7:54 pm
languages_spoken: english
ODROIDs: H2
Has thanked: 0
Been thanked: 0
Contact:

Re: I2C Interface

Unread post by berniejonnie » Sun Jan 06, 2019 8:59 pm

Hmm, I have booted a Ubuntu 18.10 Live system and saw that i2c_i801 was blacklisted and all /dev/i2c* were present.
I did the same in my Debian 9 but no /dev/i2c*. !?

berniejonnie
Posts: 5
Joined: Sat Jan 05, 2019 7:54 pm
languages_spoken: english
ODROIDs: H2
Has thanked: 0
Been thanked: 0
Contact:

Re: I2C Interface

Unread post by berniejonnie » Mon Jan 07, 2019 3:55 am

OK,
I finally remembered to insert "i2c-dev" into /etc/modules and now it works!
I was irritated by the fact that there is no package to install named "i2c-dev", but now.....
Thanks,
/BJ

umbynos
Posts: 1
Joined: Wed Jul 17, 2019 7:56 am
languages_spoken: english
Has thanked: 0
Been thanked: 0
Contact:

Re: I2C Interface

Unread post by umbynos » Wed Jul 17, 2019 8:19 am

Hello Guys, I'm a noob in linux stuff..
On my H2 I installed Ubuntu server 19.04 (which comes with kernel 5.0.0-20-generic).
i2c is not working (I connected an i2c LCD and `sudo i2cdetect -y -r 5` does not give an address).
I suspect I have to use kernel 4.18 but I don't know how to install it..
Any help would be appreciated, thanks

User avatar
odroid
Site Admin
Posts: 31852
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 89 times
Been thanked: 255 times
Contact:

Re: I2C Interface

Unread post by odroid » Wed Jul 17, 2019 10:19 am

Kernel 5.0 must be fine with the stock I2C drivers.
Try this first on Kernel 5.0
i2cdetect -y -r 2
https://wiki.odroid.com/odroid-h2/appli ... tion_check

domih
Posts: 108
Joined: Mon Feb 11, 2019 4:48 pm
languages_spoken: English, French
ODROIDs: UX4, HC2, N2, H2.
Has thanked: 34 times
Been thanked: 23 times
Contact:

Re: I2C Interface

Unread post by domih » Thu Jul 18, 2019 11:40 pm

I'm too having a trouble with the LCD.

Code: Select all

domih@h2a:~/i2c_20x4_lcd$ sudo python3 hello_world.py
Traceback (most recent call last):
  File "hello_world.py", line 6, in <module>
    lcd = lcd.lcd()
  File "/home/domih/i2c_20x4_lcd/lcddriver.py", line 66, in __init__
    self.write(0x03)
  File "/home/domih/i2c_20x4_lcd/lcddriver.py", line 91, in write
    self.write_four_bits(mode | (cmd & 0xF0))
  File "/home/domih/i2c_20x4_lcd/lcddriver.py", line 86, in write_four_bits
    self.device.write_cmd(data | LCD_BACKLIGHT)
  File "/home/domih/i2c_20x4_lcd/i2c_lib.py", line 10, in write_cmd
    self.bus.write_byte(self.addr, cmd)
OSError: [Errno 6] No such device or address
domih@h2a:~/i2c_20x4_lcd$ sudo i2cdetect -y -r 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- 27 -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
domih@h2a:~/i2c_20x4_lcd$ lsmod |grep i2
i2c_algo_bit           16384  1 i915
i2c_i801               32768  0
domih@h2a:~/i2c_20x4_lcd$ uname -a
Linux h2a 5.0.0-20-generic #21-Ubuntu SMP Mon Jun 24 09:32:09 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
domih@h2a:~/i2c_20x4_lcd$
I have in lcddriver.py:

Code: Select all

import i2c_lib
from time import sleep

# LCD Address
#ADDRESS = 0x3F
ADDRESS = 0x27

# I2C bus
BUS = 7

.../...

lsc1117
Posts: 151
Joined: Thu Aug 22, 2013 12:46 am
languages_spoken: english
Location: South Korea
Has thanked: 0
Been thanked: 2 times
Contact:

Re: I2C Interface

Unread post by lsc1117 » Fri Jul 19, 2019 9:42 am

Hi domih,

You need to edit the bus number to 2.

https://github.com/hardkernel/i2c_20x4_ ... iver.py#L9
These users thanked the author lsc1117 for the post:
domih (Fri Jul 19, 2019 1:24 pm)

RomaT
Posts: 214
Joined: Thu Oct 23, 2014 4:48 pm
languages_spoken: Russian
ODROIDs: -H2 rev.B, -XU3, -XU4, -C1, -C2, -W, -VU, CloudShell
Location: Perm, Russia
Has thanked: 5 times
Been thanked: 33 times
Contact:

Re: I2C Interface

Unread post by RomaT » Fri Jul 19, 2019 12:18 pm

odroid, You have an error in the wiki https://wiki.odroid.com/odroid-h2/appli ... em_monitor

Code: Select all

sudo apt install python3-psutil lm-sensor hdparm
"lm-sensor" must be "lm-sensors"

domih
Posts: 108
Joined: Mon Feb 11, 2019 4:48 pm
languages_spoken: English, French
ODROIDs: UX4, HC2, N2, H2.
Has thanked: 34 times
Been thanked: 23 times
Contact:

Re: I2C Interface

Unread post by domih » Fri Jul 19, 2019 1:31 pm

lsc1117 wrote:
Fri Jul 19, 2019 9:42 am
Hi domih,

You need to edit the bus number to 2.

https://github.com/hardkernel/i2c_20x4_ ... iver.py#L9
Yeah, my first baby step in I2C solved in less than a day thanks to the community.

TYVM lsc1117!

I guess I have to read a little bit more the man page of i2cdetect and understand what the output table means, I thought seeing 27 under the 7 column meant "bus 7" :-(

In addition, 7 was the value in the original file. The tragic part is that I tried 5,6,7,8,9 but did not think about trying 1,2,3,4...
Attachments
Screenshot at 2019-07-18 21-23-20.png
Screenshot at 2019-07-18 21-23-20.png (466.22 KiB) Viewed 339 times

User avatar
odroid
Site Admin
Posts: 31852
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 89 times
Been thanked: 255 times
Contact:

Re: I2C Interface

Unread post by odroid » Fri Jul 19, 2019 1:39 pm

@RomaT, Typo has been fixed. Thanks.

@domih , Glad to see your LCD is working. :D

domih
Posts: 108
Joined: Mon Feb 11, 2019 4:48 pm
languages_spoken: English, French
ODROIDs: UX4, HC2, N2, H2.
Has thanked: 34 times
Been thanked: 23 times
Contact:

Re: I2C Interface

Unread post by domih » Fri Jul 19, 2019 1:41 pm

RomaT wrote:
Fri Jul 19, 2019 12:18 pm
odroid, You have an error in the wiki https://wiki.odroid.com/odroid-h2/appli ... em_monitor

Code: Select all

sudo apt install python3-psutil lm-sensor hdparm
"lm-sensor" must be "lm-sensors"
Same thing for:

sudo apt install i2c-tool

i2c-tool --> i2c-tools

User avatar
odroid
Site Admin
Posts: 31852
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 89 times
Been thanked: 255 times
Contact:

Re: I2C Interface

Unread post by odroid » Fri Jul 19, 2019 1:43 pm

@domih, Fixed. :oops:
These users thanked the author odroid for the post:
domih (Fri Jul 19, 2019 1:45 pm)

domih
Posts: 108
Joined: Mon Feb 11, 2019 4:48 pm
languages_spoken: English, French
ODROIDs: UX4, HC2, N2, H2.
Has thanked: 34 times
Been thanked: 23 times
Contact:

Re: I2C Interface

Unread post by domih » Fri Jul 19, 2019 1:45 pm

domih wrote:
Fri Jul 19, 2019 1:41 pm
RomaT wrote:
Fri Jul 19, 2019 12:18 pm
odroid, You have an error in the wiki https://wiki.odroid.com/odroid-h2/appli ... em_monitor

Code: Select all

sudo apt install python3-psutil lm-sensor hdparm
"lm-sensor" must be "lm-sensors"
Same thing for:

sudo apt install i2c-tool

i2c-tool --> i2c-tools
Plus in:

Code: Select all

sudo python3 hello_world.py 2

Or

sudo python3 hello_world.py 3
The 2 or 3 are unnecessary because hello_world.py does not handle arguments.

lsc1117
Posts: 151
Joined: Thu Aug 22, 2013 12:46 am
languages_spoken: english
Location: South Korea
Has thanked: 0
Been thanked: 2 times
Contact:

Re: I2C Interface

Unread post by lsc1117 » Fri Jul 19, 2019 2:43 pm

@domih

Thank you for the typos.
I have corrected them and also added the parameter.

https://github.com/hardkernel/i2c_20x4_ ... 7a0cb68b01

Thank you.

Post Reply

Return to “Hardware and peripherals”

Who is online

Users browsing this forum: No registered users and 0 guests