Article Preview
Buy Now
FEATURE
Rasp Pi Electronic Fun Part 3—I2C Electronics Communication
Using LibGPIOD Interface for Raspberry Pi Electronics
Issue: 21.5 (September/October 2023)
Author: Eugene Dakin
Author Bio: Eugene works as a Senior Oilfield Technical Specialist. He has university degrees in the disciplines of Engineering, Chemistry, Biology, Business, and a Ph.D. in Chemical Engineering. He is the author of dozens of books on Xojo available on the xdevlibrary.com website.
Article Description: No description available.
Article Length (in bytes): 21,978
Starting Page Number: 29
Article Number: 21504
Resource File(s):
project-21504.zip Updated: 2023-08-31 19:04:19
Related Web Link(s):
http:// abyz.me.uk/lg/lg.zip
Excerpt of article text...
The reason why Inter-Integrated-Circuit (I2C) electronics communication is popular is that many controllers, sensors, and remotes can be connected to a Raspberry Pi board and only use two wires. This leaves the other GPIO pins available for other items. I2C applications are typically low-speed and low-cost, which is comforting to the hobbyist.
An I2C communication bus can communicate with up to about 128 devices when using 7-bits and just about 1024 devices when using 10-bits in an address by using only two communication wires. The Raspberry Pi is the Master, which means the main communication is initiated from the Pi, and the devices that are connected are called the slaves (see Figure 1).
There is a clock (SCL) that the Raspberry Pi uses to synchronize data at the default speed of about 100 kilobits per second (kbps).
There are three sections of information that are sent and received by the Raspberry Pi with I2C communication, which is the File Handle Data, the Registry Address, and the Data (see Figure 2). In Xojo, the bits read/write, start conditions, acknowledgements, and other data and all handled for you through the
lgpiio
library. This makes I2C programming with Xojo and the Raspberry Pi much simpler, and only the values for each of the three properties are needed (File Handle Data, Registry Address, and Data). If you have the desire to create your own library, then you can bit-bang a solution, which means to code the individual bits yourself.There is some configuration on the Raspberry Pi that occurs to interact with I2C using Xojo. Here are the steps to do that.
Install LibGPOID for use with Xojo
...End of Excerpt. Please purchase the magazine to read the full article.