Raspberry Pi I2C Connectors and Pinout

I2C - Inter Integrated Circuit


I2C pins in BCM mode are: 2, 3

I2C pins in WiringPi are: 8, 9

The UART pins are 14 and 15, TXD, RXD. /dev/serial0


The Raspberry Pi's I2C pins are an extremely useful way to talk to many different types of external peripheral; from the MCP23017 digital IO expander, to a connected ATmega.
The I2C pins include a fixed 1.8 kohms pull-up resistor to 3.3v. This means they are not suitable for use as general purpose IO where a pull-up is not required.
You can verify the address of connected I2C peripherals with a simple one-liner:
  1. sudo apt-get install i2c-tools
  2. sudo i2cdetect -y 1
You can then access I2C from Python using the smbus library:
  1. import smbus
  2. DEVICE_BUS = 1
  3. DEVICE_ADDR = 0x15
  4. bus = smbus.SMBus(DEVICE_BUS)
  5. bus.write_byte_data(DEVICE_ADDR, 0x00, 0x01)

  1. Example with a pimoroni scrollphathd
pi@raspberrypi:/usr/lib/python3/dist-packages/scrollphathd $ sudo i2cdetect -y 1 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- 74 -- -- --
Thanks to our friends at: https://pinout.xyz/pinout/i2c

Enable the built in Serial Port TXD/RXD UART:
Enable Your UART Serial port by using:
sudo raspi-config
and then find serial port in the menu, then ansswer NO to the login shell question, and YES question about serial hardware port.
use a MAX232 adapter to connect RS232 devices to the TXD / RXD pins.
use /dev/serial0


Comments

Popular posts from this blog

Microsoft Visio 2010 Premium Product Keys

Mercedes Benz Diesel CDI EGR Emulator Circuit Diagrams

Fix: The Diagnostic Service Host service failed to start due to the following error. [ solved, no kidding ]