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 ...
You should measure the bus between the Pi and the multiplexer: if the bus between the multiplexer and the sensor is silent when the issue appears, then by all means the problem should be in that the multiplexer doesn't understand the commands that the Pi is sending to it.
I didn't tread the datasheet but my gut feeling tells me there might be a timeout or an ...
The INA219 does not have a maximum measured current, only a maximum measured voltage (26V). I suspect you've run afoul of this annoying recent trend of naming a breakout board the same as the IC it is breaking out.
To be clear, this is what an INA219 looks like:
And this is what a popular INA219 breakout from Adafruit looks like (the actual INA219 is below ...
There is not a 1 to 1 mapping.
You need to get a handle to the I2C device at the start of your program using i2c_open.
At the end of your program release the handle with i2c_close.
To write one or more bytes use i2c_write_device.
To read one or more bytes use i2c_read_device.
The SMBus i2c_smbus_read_i2c_block_data() command just does an I2C write as does your open, ioctl and write.
It really doesn't matter which you use, it's really a matter of personal taste.
Whichever you use I would put a comment in the code saying that the other may be used instead (in case the code is ported to a different environment where only the other ...
I²C is designed to operate over short distances, typically on the same board.
Attempting to use over long distances is unlikely to succeed.
The application to UART is rather less clear.
The RS232 specification uses ±15V bipolar and is supposed to work over 1000', although this was very conservative. No modern systems actually implement this; ±12V was common ...
It's a wiring problem.
You have something pulling the SDA line to ground. This makes it appear that a device is present at every address.
The test you have run confirms that GPIO2 has been destroyed. Presumably 9V has found its way to GPIO2 from the audio module. A possibility is there is a pull-up on the module to Vcc. Anyhow, you need a new Pi. If you ...
I think you just read two or four bytes from the sensor depending on which type of sensor you have.
Your pressure sensor provides 2 byte readings.
To test use pigpio as follows.
sudo pigpiod # start the pigpio daemon
pigs i2co 1 0x78 0 # get handle to I2C bus 1 device 0x78
The i2co should return 0 as the handle (0 being the first handle).
Then to get a ...
The Pi 4 appears to support clock stretching on the software I2C bus:
The hardware I2C bus is affected by the same bug as earlier models which makes it incompatible with clock stretching, as the screenshot in your referenced post shows:
I don't see how disabling pullups would cause any problems.
In general you can access an I²C device powered by 5V provided there are no pullup to 5V.
How much current do these unnamed devices use?
I doubt it would exceed the ~800mA the Pi can safely supply.
All the 8 hardware I2C buses on the Pi 4 are identical.
The Broadcom Serial Control (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.
Chapter 3 of the available documentation states that all of the hardware-based I2C buses on the BCM2711 (RPi 4) operate under the control of the Broadcom Serial Controller, or BSC. The RPi hardware and firmware are closed-source, but relying on the documentation, a reasonable assumption is: "No - none of the hardware-based I2C channels are faster than ...
You will need to use the device tree to accomplish this.
You may also need to make some changes to the AdaFruit software. It's likely using the default i2c1 channel - you'll have to locate this in the software, and change it to match the i2c channel you choose (as shown below).
RPi 4 gives you a choice of 6 hardware-based i2c channels. These are available ...
I used I2C sensors on appx. 3M cable (with ESP8266) in my weather station for few months without any problem, that was normal sensor data cable, no twisted wires etc. With Cat 6 successs should be higher. It is reliable and based on your cable lenght connection speed will be affected, not signal. If possible, try using smaller pullup resistors on SDA and SCL ...
It means you need to bridge the gap between the two metal pads of AD0 and / or AD1. Normally you would do that with a little blob of solder.
If you bridge the two pads of AD0 you add 1 to the address, if you bridge the gap of AD1 you add 2. If you do both you add 3 to the address.
Yes, you can use smbus to talk to your I2C devices rather than using the busio and/or board modules.
Personally I would always use smbus for control unless the underlying device being controlled is very complex.
If you use smbus you can more easily port the code to a different board and more easily tailor the code to your own needs. The ...
How to use python packages with importing "busio" and "board"?
Well I guess you are using modules/boards/HATs from AdaFruit. For a particular modules, eg temperature sensor, AdaFruit has different version for different MCU and SBC, say M0, Arduino, and Rpi.
If you are using a Rpi compatible module, then your ...
smbus2.SMBus(1).i2c_rdwr(smbus2.i2c_msg.write([ADDRESS],[[ARRAY OF BYTES]]))
Smbus2 has an i2c read and write feature.
For read you would do this:
smbus2.SMBus(1).i2c_rdwr(smbus2.i2c_msg.read([ADDRESS],[NUMBER OF BYTES]))
(smbus2 is a rewrite of smbus, and includes this feature which makes it easier to use with i2c than smbus)
If you don't ...
This is not your problem but I would be cautious with QIFEI branded ADS1115. I bought two from different UK eBay resellers in 2020 and both had the same bizarre fault, they are 12-bit but with upper 4 bits fixed at 0 and the i2c communication at 100kHz is unreliable. More detail in Adafruit Forums: Strange Case of Adafruit ADS1115 and QIFEI ADS1115.
No, the ADC isn't broken. It can measure any value on unconnected channels, including a value which depends on the signal on neighboring connected channels.
If you want to create a slow "amplitude" signal from a faster signal, you need an envelope detector. That's how AM radios used to work.
Thanks to everyone's comments I've come to a solution. All comes down to not letting the wires float (as suggested by @Dougie). Connecting the wires in a breadboard does not guarantee that they be actually connected, so I soldered them, and that stabilized the address of the MCP23008 on the I2C bus.
Here are some methods using my Python modules.
You can also use the Python smbus module.
pi = pigpio.pi()
h = pi.i2c_open(1, 0x78)
(b, d) = pi.i2c_read_device(h, 6)
print(d, d, d, d, d, d)
sbc = ...
Does using an intermediate controller count? Use e.g. Blue Pill, configure both SPIs on it, SPI1 in receive only slave mode, SPI2 in transmit only slave mode. Both RPis will be SPI masters (which is supported). Then you develop a simple firmware which copies data from SPI1 to SPI2. Both SPI on Blue Pill run at up to 18 Mbit/s.
P.S. And no, both WiFi and ...
OK, I've found out what had been wrong here: the two i2c_write_byte_data () methods from pigpio. They send the following signals to the corresponding I²C slave:
Start Address WriteBit [A] Register [A] Payload [A] Stop
So, after the first byte has been written, a stop bit is emitted, followed by a start bit for the second byte. The ADC looks for a 2-byte ...
I've figured it out! This is confusing and I do not know why this caused a problem, but the values report properly in python if I don't set PowerOnReset. Comment out that function call and they report properly:
$ sudo ./test.py
INFO:root:voltage read: 16594
INFO:root:voltage swapped: 53824
INFO:root:voltage return: 4.205
Yes - and since the introduction of the RPi 4B and the BCM2711 SoC, the number of I2C buses available has increased. The number of physical pins didn't increase with the RPi 4B, but these additional I2C buses are accessed through the the i2c_mux_pinctrl kernel module. Most of these "newly exposed" i2C channels may be configured through the /boot/...