Hot answers tagged

6

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 ...


3

I googled and find this Pico I2C Slave class in microPython: i2cSlave.py. Use Pico as an I2C slave? - danjperron, rpi.org.forums, 2021feb20


2

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 ...


2

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 ...


2

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.


2

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 ...


2

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 ...


2

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 ...


2

Try setting the core frequency to a constant value in config.txt: core_freq=250 This should still let the governor to set the CPU frequency (arm_freq) depending on the system load.


2

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 ...


2

The Pi 4 appears to support clock stretching on the software I2C bus: dtoverlay=i2c-gpio,bus=3 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:


2

This type of connection should do the trick. Right?


2

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.


2

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.


2

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 ...


2

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 ...


1

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 ...


1

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.


1

Factual Yes, you can use smbus to talk to your I2C devices rather than using the busio and/or board modules. Opinion 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 ...


1

Question How to use python packages with importing "busio" and "board"? Answer 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 ...


1

I got my answer I did a silly mistake I forgot to enable the i2c module of raspberry pi form raspbian configuration.


1

import smbus2 and 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 ...


1

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.


1

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.


1

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.


1

Here are some methods using my Python modules. You can also use the Python smbus module. pigpio import time import pigpio pi = pigpio.pi() h = pi.i2c_open(1, 0x78) pi.i2c_write_device(h, [0xAC]) time.sleep(0.05) (b, d) = pi.i2c_read_device(h, 6) print(d[0], d[1], d[2], d[3], d[4], d[5]) pi.i2c_close(h) pi.stop() rgpio import time import rgpio sbc = ...


1

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 ...


1

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 ...


1

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 Voltage: 4.21V INFO:root:capacity ...


1

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/...


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