0

Im trying to change the i2c sda1 and slc1 Pins from Pin 3 / 5 to Pin 19 / 21 I want to connect a DS3231 HW Clock to such Pins, and 3 / 5 are already used by other things.

I configured:

# cat /boot/config.txt
[...]
dtoverlay=i2c-gpio,i2c_gpio_sda=19,i2c_gpio_scl=21

And rebooted the device, but the pins are still in original configuration:

# gpio readall
+-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+
| BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
|     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
|   2 |   8 |   SDA.1 | ALT0 | 1 |  3 || 4  |   |      | 5V      |     |     |
|   3 |   9 |   SCL.1 | ALT0 | 1 |  5 || 6  |   |      | 0v      |     |     |
|   4 |   7 | GPIO. 7 |  OUT | 1 |  7 || 8  | 1 | ALT0 | TxD     | 15  | 14  |
|     |     |      0v |      |   |  9 || 10 | 1 | ALT0 | RxD     | 16  | 15  |
|  17 |   0 | GPIO. 0 |   IN | 0 | 11 || 12 | 0 | IN   | GPIO. 1 | 1   | 18  |
|  27 |   2 | GPIO. 2 |   IN | 0 | 13 || 14 |   |      | 0v      |     |     |
|  22 |   3 | GPIO. 3 |   IN | 0 | 15 || 16 | 0 | IN   | GPIO. 4 | 4   | 23  |
|     |     |    3.3v |      |   | 17 || 18 | 0 | IN   | GPIO. 5 | 5   | 24  |
|  10 |  12 |    MOSI |   IN | 1 | 19 || 20 |   |      | 0v      |     |     |
|   9 |  13 |    MISO |   IN | 1 | 21 || 22 | 0 | IN   | GPIO. 6 | 6   | 25  |
|  11 |  14 |    SCLK |   IN | 0 | 23 || 24 | 1 | IN   | CE0     | 10  | 8   |
|     |     |      0v |      |   | 25 || 26 | 1 | IN   | CE1     | 11  | 7   |
|   0 |  30 |   SDA.0 |   IN | 1 | 27 || 28 | 1 | IN   | SCL.0   | 31  | 1   |
|   5 |  21 | GPIO.21 |   IN | 1 | 29 || 30 |   |      | 0v      |     |     |
|   6 |  22 | GPIO.22 |   IN | 1 | 31 || 32 | 0 | IN   | GPIO.26 | 26  | 12  |
|  13 |  23 | GPIO.23 |   IN | 0 | 33 || 34 |   |      | 0v      |     |     |
|  19 |  24 | GPIO.24 |   IN | 0 | 35 || 36 | 0 | IN   | GPIO.27 | 27  | 16  |
|  26 |  25 | GPIO.25 |   IN | 0 | 37 || 38 | 0 | IN   | GPIO.28 | 28  | 20  |
|     |     |      0v |      |   | 39 || 40 | 0 | IN   | GPIO.29 | 29  | 21  |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
+-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+

Any ideas what i have to doto get this work?

Model is: Raspberry Pi 2 Model B.

EDIT: Bus was created:

# ls -l /dev/i2*
crw-rw---- 1 root i2c 89, 1 Aug 10 15:41 /dev/i2c-1
crw-rw---- 1 root i2c 89, 3 Aug 10 15:41 /dev/i2c-3

But the device does not appear:

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

Enabled internal pull-ups:

  sudo pigpiod
  pigs pud 12 u
  pigs pud 13 u

But still no luck. When connected to pins 1-5, the hwclocks shows up fine:

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

What configuration are you expecting? You are using software (bit banged) I2C. I expect the GPIO will change to INPUT or OUTPUT for SDA and OUTPUT for SCL when you actually send I2C traffic.

Does the device appear? E.g. does ls /dev/i2* show something other that bus 0 or bus 1?

Try i2cdetect -y 3 (as 3 is the likely bus created).

GPIO       pin  pin    GPIO
3V3         1    2      5V
2 (SDA)     3    4      5V
3 (SCL)     5    6      0V
4           7    8      14 (TXD)
0V          9   10      15 (RXD)
17 (ce1)   11   12      18 (ce0)
27         13   14      0V
22         15   16      23
3V3        17   18      24
10 (MOSI)  19   20      0V
9 (MISO)   21   22      25
11 (SCLK)  23   24      8 (CE0)
0V         25   26      7 (CE1)
           .......
0 (ID_SD)  27   28      1 (ID_SC)
5          29   30      0V
6          31   32      12
13         33   34      0V
19 (miso)  35   36      16 (ce2)
26         37   38      20 (mosi)
0V         39   40      21 (sclk)
7
  • Updated original question with your infos. Im just expecting that the hwclock shows up in i2cdetect on the new pins (works fine on pins 3/5)
    – embedded
    Aug 11 '16 at 10:14
  • Are there any pull-ups to 3V3 enabled? Pins 3 and 5 (I2C bus 1) have hard-wired 1k8 pull-ups to 3V3. You'll need to ensure there are pull-ups on the GPIO you are using for SDA/SCL. You could enable the internal pull-ups as a quick test.
    – joan
    Aug 11 '16 at 10:21
  • Ok. Perfect, something to work with. I have never done this, do i need to do something like this: github.com/fivdi/onoff/wiki/…
    – embedded
    Aug 11 '16 at 10:33
  • You could try the following: sudo pigpiod; pigs pud 19 u pud 21 u. Just to clarify, you are using GPIO 19 which is connected to pin 35 and GPIO 21 which is connected to pin 40.
    – joan
    Aug 11 '16 at 10:42
  • I was trying to use the physical pins 19 / 21 :) Ill change the dtoverlay part and the pigpiod to reflect the new numbers
    – embedded
    Aug 11 '16 at 10:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.