Pololu Robotics & Electronics
Menu
My account Comments or questions? About Pololu Contact Ordering information Distributors

Pololu Forum

Raspberry Pi connect to tic with I2C

Hi,

I am trying to connect one tic with my raspberry Pi with I2C and follow the guidelines according to the manual. I added the dtoverlay=i2c-gpio line to the config.txt file and also connected the tic with SCL to GPIO24 and SDA to GPIO 23.

When I try to run the example code for python on the raspberry pi I get the following error

FileNotFoundError: [Errno 2] No such file or directory: ‘/dev/i2c-3’

It seems like the tic was not detected by the pi. If I run i2cdetect -y 1 I also do not see any device in the list.

I use a 12V,5A power supply.

Best wishes,
Tobia

Hello, Tobia.

Which version of the Raspberry Pi are you using?

Can you reboot your Raspberry Pi and run cat /boot/config.txt then ls /dev/i2c* and post the results here?

- Amanda

Hi Amanda,

I am using a RaspberryPi B+

If I run these command lines I get:

pi@raspberrypi:~ $ cat /boot/config.txt
# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1

# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
disable_overscan=1

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720

# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

# Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on
#dtparam=i2s=on
dtparam=spi=on

# Uncomment this to enable infrared communication.
#dtoverlay=gpio-ir,gpio_pin=17
#dtoverlay=gpio-ir-tx,gpio_pin=18

# Additional overlays and parameters are documented /boot/overlays/README

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
dtoverlay=vc4-fkms-v3d
max_framebuffers=2

[all]
#dtoverlay=vc4-fkms-v3d

# NOOBS Auto-generated Settings:
dtoverlay=spi1-3c

# Addition for Pololu motor controller I2C
dtoverlay=i2c/gpio



pi@raspberrypi:~ $ ls /dev/i2c*
/dev/i2c-1

Best wishes,
Tobia

It looks like you mistyped; you have dtoverlay=i2c/gpio instead of dtoverlay=i2c-gpio in your /boot/config.txt file. Can you change the forward slash (/) to a hyphen (-), save and restart the Raspberry Pi, run the ls /dev/i2c* command again and post the result here?

- Amanda

Hi Amanda,

Now I get the desired /dev/i2c-1 /dev/i2c-3. However, the example code still does not work and if I run i2cdetect -y 1 I do not get any device there. If I connect the pins with GPIO 2 and 3 instead, I get a device with the address 0e. How would I need to convert it so I can write it into the example code?

Best wishes,
Tobia

Just to clarify, when you connected the Tic’s SDA and SCL pins to GPIO23 and GPIO24 on the Raspberry Pi, respectively, the Python example did not work and running i2cdetect -y 1 did not return anything for you, is that correct?

The i2cdetect command you used is incorrect. When the Tic is connected to GPIO23 and GPIO24, you should be using the command i2cdetect -y 3 in order to scan /dev/i2c-3. See the the man page for i2cdetect for more information on the command and its options, and the overlay documentation for i2c-gpio.

Can you connect the Tic’s SDA and SCL pins to GPIO23 and GPIO24, run i2cdetect -y 3, and post the results here?

The Tic’s I2C address, 0x0E, is 14 in decimal and is the default address value used in the code, so that looks fine and you wouldn’t need to make any changes to the code.

- Amanda

Thanks for your help! Now it works, I am able to actuate the stepper motors. I was able to detect them with i2cdetect -y 3, the tic was on channel 14 as you said.

Best wishes,
Tobia

1 Like