Bosse_B
Posts: 966
Joined: Thu Jan 30, 2014 9:53 am

Reading/Writing I2C devices in Raspbian?

Tue Nov 12, 2019 10:28 am

I need to read and write some I2C devices (RTC, EEPROM) on my RPi4.

I am not using C, C++ or Python so I would like to know if there are some Linux basic commands operating on the /dev/i2c-1 device I can use from any language that can handle files?
What I actually use is FreePascal and Lazarus IDE.

I have designed a board that will plug into the 40-pin connector and it has some relay drivers on board operated via GPIO pins, which I can work with already. But it also has some other devices hooked to the I2C bus, which I need to access.

Any suggestions appreciated, except for Python, which I can not use.
Thanks.
(I hope this is the right sub-forum to ask in)
Bo Berglund
Sweden

User avatar
joan
Posts: 14887
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Reading/Writing I2C devices in Raspbian?

Tue Nov 12, 2019 11:25 am

Linux communicates with the SMBus/I2C driver with standard read, write, and ioctl calls. You will need to use those.

User avatar
B.Goode
Posts: 10191
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Reading/Writing I2C devices in Raspbian?

Tue Nov 12, 2019 11:40 am

Bosse_B wrote:
Tue Nov 12, 2019 10:28 am
I need to read and write some I2C devices (RTC, EEPROM) on my RPi4.

I am not using C, C++ or Python so I would like to know if there are some Linux basic commands operating on the /dev/i2c-1 device I can use from any language that can handle files?
What I actually use is FreePascal and Lazarus IDE.

I have designed a board that will plug into the 40-pin connector and it has some relay drivers on board operated via GPIO pins, which I can work with already. But it also has some other devices hooked to the I2C bus, which I need to access.

Any suggestions appreciated, except for Python, which I can not use.
Thanks.
(I hope this is the right sub-forum to ask in)


A few seconds with an Internet search tool and the string lazarus Raspberry i2c came up with -
Turns out, it is VERY easy to access I2C with Free Pascal.
Ref: https://bigdanzblog.wordpress.com/2014/ ... ee-pascal/

and
https://wiki.freepascal.org/Lazarus_on_Raspberry_Pi

Return to “Interfacing (DSI, CSI, I2C, etc.)”