Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 21.5 ('Photomosaics')
Instant purchase and download via GumRoad!

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):

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