Hot answers tagged

35 votes
Accepted

Firmware 3.18.x breaks I²C, SPI, audio, lirc, 1-wire (e.g. /dev/i2c-1, No such file or directory)

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 ...
  • 67.9k
18 votes
Accepted

i2cdetect shows every possible address

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 ...
  • 67.9k
15 votes

Raspberry as an I2C SLAVE

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 ...
  • 151
14 votes
Accepted

What does raspi-config do when you enable i2c?

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 ...
  • 56.5k
13 votes

Can we use other GPIO pins as I2C

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 ...
  • 67.9k
13 votes

Pi 4 I/O interface options... and where to find them

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 ...
  • 15.6k
12 votes

Raspberry Pi DPI only works over short distances. Why?

All cables have a length limit. When you exceed that length limit, the signals in the cable attenuate due to resistance of the cable, get deformed due to capacitance and inductance in the cable, and ...
  • 794
10 votes
Accepted

PoE hat fan activation on OS other than Raspbian

I'm using Ubuntu Server 20.04 LTS. The dtparams setting does not work, instead you need a udev rule. The fan config is in /sys/class/thermal/cooling_device0/, if you cat /sys/class/thermal/...
8 votes
Accepted

What bitrate can I get from an i2c bus?

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 ...
  • 67.9k
8 votes
Accepted

How to use Adafruit TCA9548A 1-to-8 I2C Multiplexer Breakout in C#?

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 ...
8 votes
Accepted

How to Read I2C Address

The active address is 0x65. The row indicates the 16's place and the column indicates the one's place. So the answer is 0x60 + 0x05 = 0x65.
  • 1,542
7 votes

Firmware 3.18.x breaks I²C, SPI, audio, lirc, 1-wire (e.g. /dev/i2c-1, No such file or directory)

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

Why did my Pi die?

From Wikipedia: Overclocked use may permanently damage components enough to cause them to misbehave (even under normal operating conditions) without becoming totally unusable. [...] In ...
  • 56.5k
7 votes

Connecting multiple devices via I2C

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 ...
  • 67.9k
7 votes
Accepted

How to setup a MCP79410 real time clock?

In order to set up a MCP79410 real time clock (RTC, see manual), one needs to start by connecting it to one's RPi and a quartz crystal. The following is supposed to be a rough sketch on how to connect ...
7 votes
Accepted

Raspberry as an I2C SLAVE

This is almost identical to your previous question. You probably should have edited that rather than asking a new question. You need the bscXfer to be within the while loop. That is how the xfer ...
  • 67.9k
6 votes
Accepted

I2C device inside case + GPIO ribbon outside case

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). ...
  • 56.5k
6 votes
Accepted

Using I2C in C++ on Raspberry Pi

The kernel has an API for SMBus/I2C. You just have to include a couple of headers: #include <linux/i2c-dev.h> #include <sys/ioctl.h> There's no library that needs linking. I've used ...
  • 56.5k
6 votes
Accepted

Programming servo - What to use?

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. ...
  • 67.9k
6 votes
Accepted

Is there a tool to read and write data using I2C?

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 ...
  • 67.9k
6 votes
Accepted

Does the Raspberry Pi support I2C multi-master configurations?

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-...
  • 67.9k
6 votes

I2C Bus voltage

Some of the other comments are true, but not totally clear. You can use the Pi I²C to connect to another I²C device, even if it is powered by 5V provided there are no pull-up resistors to 5V. I ...
  • 54.8k
6 votes
Accepted

rPi3 I2C-LCD, do i need a logic level converter?

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 ...
  • 67.9k
6 votes
Accepted

/dev/mem vs /dev/i2c-1

Disadvantages using /dev/mem for accessing the I²C hardware of the Raspberry Pi directly: It's not portable to other hardware platforms. It's not portable to additional USB I²C adapters. It's not ...
  • 1,653
6 votes
Accepted

What is Rpi's I2C Maximum Speed?

Answer I have confirmed that Rpi4B 4GB v1.2 buster 2020feb13 I2C #1 can set speed other than 100kHz. Figures Appendices Appendix A - /boot/config.txt tlfong01 2020mar04 # /boot/config.txt ...
  • 4,394
6 votes
Accepted

How to connect multiple sensors to an rpi with the I2C?

I2C is a bus system and allows you to connect multiple sensors to the same pins. The master system (the Pi) lets the sensors know who should respond by placing that sensor's address on the bus. In ...
  • 67.9k
5 votes

Is there an I2C Library

I just started using the pigpio library and I am very impressed. I especially like the bit bang mode, since it allows you to use any two GPIO pins as an I2C interface, as long as they have pullup ...
  • 493
5 votes
Accepted

Controlling a official lego servo motor via Raspberry Pi

Assuming https://www.youtube.com/watch?v=ArEt9RWPbhE is correct the servo is not controlled as a servo with 50Hz updates and 1-2 ms pulses. Apply PWM to C1. C2 should be 0 for counterclockwise and 1 ...
  • 67.9k
5 votes
Accepted

How do you decide between communication protocols?

There are tradeoffs for each of the interfaces you mention: UART: setting up and reading/writing fron/to a UART port is fairly easy. However, UARTs typically cannot be driven at very high speeds and ...
5 votes
Accepted

Serial vs I2C speed

There is no real comparison, these are designed for different purposes. Serial communication is designed for long distance communication. I have used it over 1000km. There are often speed/distance ...
  • 54.8k

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