Hot answers tagged

34

The latest firmware implements device tree support. That will have broken things like I²C, SPI, and 1-wire bus. For fuller details see I²C, SPI, I2S, LIRC, PPS, stopped working? Read this.. Summary Add one or more of the following to your /boot/config.txt and reboot. I2C No longer add: dtparam=i2c1=on (or dtparam=i2c0=on on old models) Instead add: ...


23

There's a lot of information about RPi's GPIO here: http://elinux.org/Rpi_Low-level_peripherals According to it, you can program any GPIO pins for I²C, but: Pin 3 (SDA0) and Pin 5 (SCL0) are preset to be used as an I²C interface. So there are 1.8 kilohm pulls up resistors on the board for these pins. That wiki page also has some low-level GPIO code ...


15

Generally this happens because something is pulling SDA (pin 3) low. The i2cdetect program checks for the existence of a device by sending its address then letting SDA float high. If the device exists it should pull SDA low to signal its presence. Check your wiring to make sure SDA hasn't been inadvertently connected to ground.


12

Assuming the module loads using sudo modprobe i2c-dev, you should add i2c-dev to /etc/modules.


10

The short answer to your question, how to safely connect the RPi to an Arduino, is indeed given at the first link you posted: http://blog.oscarliang.net/raspberry-pi-arduino-connected-i2c/. I have used the method given there with great success, and without damaging any components. But your question suggests that you don't trust that method, and I think the ...


10

The whole point of I2C is it is a bus. You can therefore connect multiple I2C devices to the same GPIO provided they have different I2C device addresses. If the devices share an address which can't be changed you can use an I2C multiplexor chip to typically connect 8 devices to the same I2C bus. You send a command to the multiplexor to specify the device ...


10

The preliminary Raspberry Pi 4 Model B datasheet, section "5.1.1 GPIO Pin Assignments" says: As well as being able to be used as straightforward software controlled input and output (with programmable pulls), GPIO pins can be switched (multiplexed) into various other modes backed by dedicated peripheral blocks such as I2C, UART and SPI. In ...


8

i2c-bcm2708 is the low level driver. i2c-dev creates the convenient /dev/ entries


8

I²C protocol is very simple. It does not really define data structures that are sent over the wire. The frame consist of a slave address (with direction bit indicating if master wants to read or write) and (in case of writing) some bytes of data. Since it doesn't make sense to initiate write with 0 bytes of data, first byte is mandatory. This first byte is ...


8

But on a new Pi (Raspbian/B+) I could not get it to work until I followed the Advanced option in raspi-config and enbaled i2c there(and rebooted). This is because newer Raspbian kernels use device tree "to manage some resource allocation and module loading": The main impact of using Device Tree is to change from everything on, relying on module ...


7

There's a i2c-dev header in the Linux userspace. I can't remember if this header is shipped with the lm-sensors package, or if it will need to be installed from source. I'd check your distro's package repository. xGoat has a nice article covering preparation & usage. #include <linux/i2c-dev.h> /* Including i2c-dev header will allow the following ...


7

They are blacklisted in /etc/modprobe.d/raspi-blacklist.conf # blacklist spi and i2c by default (many users don't need them) blacklist spi-bcm2708 blacklist i2c-bcm2708 so comment these lines.


7

Lots of discussions going on about this. Here's what my reading and messing around with shows me: I2C support is not built into the default kernel with the Debian "squeeze" A custom kernel will have to be compiled with the i2cspi module (Here is a GIT tree excerpt) The drivers that have been written so far are only for the 3.2 kernel and later, and the ...


7

This should help you: AN10658 Sending I2C-bus signals via long communications cables If possible you should use a cable with the lowest capacitance, maybe Cat5 cable or something closer. Shielding won't hurt either. The maximum I2C cable capacitance is limited to 500pf, a cat5 cable has the capacitance of 50pf/meter. So, basically, for a 10m cable you will ...


7

If you don't want to spare your USB port of your Rpi, you can use GPIO Serial to communicate with your Arduino. There is a great tutorial of Conor O'Neill for connecting Rpi with a Arduino Pro Mini. The procedure is the same with your Arduino Uno. All you need is a LLC (Logic Level Converter) to be able to connect these two devices. As you've already ...


7

The rev. 2 model A and B both have a breakout for a second I2C bus, with the caveat that you can't use it and the camera header at the same time (this is software switchable while the pi is running). The eight hole breakout is easy to see just inside of the GPIO header. This is usually referred to as the P5 header in documentation, but on one (of two) of ...


7

You can use sudo raspi-config and in Advanced Options disable Device Tree. Might be faster than changing the configuration manually.


7

From Wikipedia: Overclocked use may permanently damage components enough to cause them to misbehave (even under normal operating conditions) without becoming totally unusable. [...] In general, overclockers claim that testing can ensure that an overclocked system is stable and functioning correctly. Although software tools are available for ...


7

Since this topic is very poorly covered and Sebastião's snippet and helped me to solve this problem I want add a complete solution on how to setup a RaspberryPi right here (tested on a RPi 3 and Zero W)! Setting up a working slave: Preparations Be sure to have commented out this line in your /boot/config.txt: dtparam=i2c_arm=on Dependencies Next, ...


6

According to the wiki, I2C is exposed on pins 3 (SDA) and 5 (SCL). Using from Python on Debian (Untested) Based on reading this forum post. Run sudo apt-get install python-smbus to install the drivers. At the time of writing, there is a test script here. Note: Someone needs to test this.


6

Questions 1 to 3 are answered the same: Current kernel at github is already 3.2. It includes I2C and SPI drivers in the source tree. You just have to activate it in the configuration and compile your own kernel.


6

Depending on the LEDs you are using, It may be possible to use a multiplexing scheme to reduce the number of drivers you need. It's probably simpler to use a bunch of 4094 shift registers daisy chained. You can bitbang the clock/data or use the SPI hardware to drive them Each 4094 can control 8 LEDs. You'll most likely need a small driver (eg transistor) ...


6

The various releases are listed here the Debian Wheezy python-smbus page. I assume you can just install via apt-get, although I believe you need to i2c tools package as well: sudo apt-get install i2c-tools sudo apt-get install python-smbus When you create your virtual environment you should be able to inherit the system site packages using the --system-...


6

The I2C clock bps (bits per second) can be set between 125 Mb/s and 3826 b/s (250Mhz core clock with even divider between 2 and 65536). BCM2835 ARM Peripherals pages 28-36. In practice speeds higher than 30 Mb/s are unlikely to work. The maximum bps I've heard of is 3.4 Mb/s but I don't remember any evidence being offered. Bit rates of 400 kb/s (a sort of ...


6

You can drive as many servos from the Pi as you can find spare gpios. You have to use hardware timed PWM rather than software timed PWM. People who report jitter have been using software timed PWM. My pigpio library generates independent hardware timed PWM on all the user gpios and is suitable for servos. I think the defaults used mean it has ...


6

sudo apt-get install i2c-tools Then use i2cset, i2cget, i2cdump. man i2cset # for help man i2cget # for help man i2cdump # for help Aternatively my pigpio library supports I2C from the command line usings pigs, see the i2c* commands, e.g. i2co.


6

I'm fairly sure the Raspberry Pi does NOT support I2C multi-master mode. There is no mention of muli-master in the documentation. The Broadcom Serial Controller (BSC) controller is a master, fast-mode (400Kb/s) BSC controller. The Broadcom Serial Control bus is a proprietary bus compliant with the Philips® I2C bus/interface version 2.1 January 2000....


6

I2C is a bus. You can connect multiple devices to a bus. I2C requires that each device on the bus has a unique address (generally a small number between 0 and 127). Manufactures tend to give different types of device different addresses, so normally there is no need to do anything special. As far as wiring is concerned just connect each device to SDA and ...


6

A code sample is right there on Adafruit website (in Python, but it's very simple). The TCA9548A multiplexer is interesting in that it has an I2C address (0x70 by default) - and you basically send it a command to tell it which I2C multiplexed output you want to talk to, then you can address the board you want to address. So, you'll need to select the ...


6

You can't just write to an I2C bus. The SCL line is an output from the master (Pi) but the SDA line is an input and an output. The LCD should not have pull-ups to 5V on board but many do. Perhaps connect it to 5V and ground and then measure the voltage on the LCD's SDA pin. If it's 5V you definitely should use a level converter.


Only top voted, non community-wiki answers of a minimum length are eligible