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..
Add one or more of the following to your /boot/config.txt and reboot.
No longer add: dtparam=i2c1=on (or dtparam=i2c0=on on old models)
Instead add: ...
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.
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:
Be sure to have commented out this line in your /boot/config.txt:
Next, install g++...
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 ...
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.
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 the pins to point one in the right direction - in practice, one might need capacitors to smooth signals or resitors to pull-up the SCL- and SDA-interface, ...
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-...
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 ...
The kernel has an API for SMBus/I2C. You just have to include a couple of headers:
There's no library that needs linking. I've used this to write C++ based interfaces to various I2C sensors, I'm sure it can be made to work with an RTC. The API isn't the complicated part, it's figuring out how ...
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 ...
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.
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.
• I2C ...
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.
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 structure is updated with new information.
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 portable to additional bitbanged I²C.
You limit yourself to one-application at a time which may use the I²C, while the kernel serializes requests on /dev/i2c-nnn ...
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 your case you can connect all the sensors I2C SDA pins to the Pi's SDA pin and all the sensors I2C SCL pins to the Pi's SCL pin.
Note you can also connect all the ...
Absolute safest would be Bluetooth serial. With a supported USB dongle on the Raspberry Pi and something like a Bluefruit EZ-Link on the Arduino, you could program and control the Arduino from the Raspberry Pi with no physical connection.
Next best would likely be through USB. There is a “standard” protocol (Firmata) for interacting with Arduino and sensors,...
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 resistors. If you are using a PI2, there is not much of a disadvantage to bit banging, since you have 4 CPUs. The nice thing about the bit bang commands is that ...
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 there could be issues with baud rate inaccuracies as well as insuring that the baud rate is the same on both sides.
I2C: since the master drives the clock, ...
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 tradeoffs depending on the communication medium. Getting 56kbps is a challenge over copper phone lines, but it can be used at rates over 1Mbps, although generally ...