https://github.com/matzeema/wiring_pi_i2c
Dart implementation of the Wiring Pi I2C library.
https://github.com/matzeema/wiring_pi_i2c
dart ffi i2c wiring-pi
Last synced: about 2 months ago
JSON representation
Dart implementation of the Wiring Pi I2C library.
- Host: GitHub
- URL: https://github.com/matzeema/wiring_pi_i2c
- Owner: matzeema
- License: mit
- Created: 2021-02-07T20:31:59.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-11-15T13:48:10.000Z (over 3 years ago)
- Last Synced: 2025-02-08T16:39:39.922Z (4 months ago)
- Topics: dart, ffi, i2c, wiring-pi
- Language: Dart
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Wiring Pi I2C
Dart implementation of the Wiring Pi I2C library.
I mainly created this package for one of my own projects, so I haven't done a lot of testing yet. But I still hope this makes the creation of your flutter-pi app (or whatever you create) easier.
## Installing Wiring Pi
Visit this [guide](http://wiringpi.com/download-and-install/) to install the Wiring Pi library on your Raspberry Pi. If your are using a Raspberry Pi 4B you might also check this [post](http://wiringpi.com/wiringpi-updated-to-2-52-for-the-raspberry-pi-4b/).
## Using the package
The first thing todo is to create the `I2CDevice`. It takes the address of the I2C device. You can find this address by using the command `sudo i2cdetect -y 1`. Afterwards call the `setup` method.
```dart
final addr = 0x48;
final i2cDevice = I2CDevice(addr);
i2cDevice.setup();
```The `I2CDevice` is setup and ready to use. You can use all the commands mentioned in the [Wiring Pi documentation](http://wiringpi.com/reference/i2c-library/).
```dart
final register = 0x01;
final value = 0x8000;
i2cDevice.writeReg16(register, value);final output = i2cDevice.readReg16(register);
print("Value of register $register: $output");
```If any of the methods fails a `I2CException` will be throwen.