Close

Initial steps

A project log for Raspberry Pi I2C Interfacing

A quick go at talking to a few devices

keithKeith 11/03/2020 at 01:520 Comments

2020-10-27 Ordered modules to play with:

That should be enough to get on with. The level shifter is for interfacing to 5V devices.

2020-10-27 Setting up R-Pi with fresh installation of Raspbian on Micro-SD card.

Had some issues with this. Installed Raspbian and Kodi from the NOOBS card. After updating itself, Raspbian fails to boot, producing repetitive 4-flash sequence on green LED, indicating it cannot find the loader program. I used the Windows Raspbian disk-image creator, which produced an SD card that booted reliably.

Second issue is that my display (Dell) goes blank every few seconds. Google results suggest this is due to inadequate earthing of the monitor. It looks fine to me. Other results suggest changing the HDMI drive boost settings of the Pi.

I guessed that the USB PSU could not supply enough current, and thus the Pi failed while re-writing the card. I have replaced it with a bigger PSU. Swapped displays - my LG 2753EV does not blank.

2020-11-02 Set Locale Country and Keyboard to GB.
In Settings-->Configuration-->Interfaces tab, enable I2C and SPI.

Run Thonny IDE interface for Python. Ran the example program LED.py and this seemed to work.

Opening a console to run from the command line,

i2cdetect -y 1

returns a scan of devices like so:

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

All seems ready to proceed. I2C devices cannot be plugged in while the Pi is running, so they must be connected to a bit of breadboard and connected first.

Looked around for existing software for the devices I bought. No point reinventing wheels! The manufacturers provide documentation and sometimes Pi Python code examples.

2020-11-03

Quick check of expected addresses, in case of conflicts. None apparent.
Addresses from https://learn.adafruit.com/i2c-addresses/the-list

010 0xxx = 2x = MCP23017
011 110x = 3C = SSD1306
100 10xx = 48 = ADS1115
110 0xxx = 60 = MCP4725
110 100x = 68 = MPU6050

2020-11-12

Googled for further information, there is plenty at Adafruit:

https://learn.adafruit.com/search?q=MCP23017
https://learn.adafruit.com/search?q=ADS1x15
https://learn.adafruit.com/search?q=SSD1306
https://learn.adafruit.com/search?q=MCP4725
https://learn.adafruit.com/search?q=MPU-6050

At this point there is not much I can add to this project that is not already on the web.

Discussions