5

I am trying to build a project based on IoT with flutter, android things, and raspberry pi. For that, I need to access raspberry pi GPIO pins through my flutter app.

Firstly I have installed android things os onto the raspberry pi and connect a display to it. After that, I have to build a flutter app and uploaded and it's working perfectly but now I need to control GPIO so I have googled it but found nothing except the rpi_gpio dart library which can access raspberry pi GPIO pins but apparently it is not working on flutter dependencies.

So is there a way then suggest me so that I can complete my project.

Samet ÖZTOPRAK
  • 3,112
  • 3
  • 32
  • 33

4 Answers4

2

I know that this posting is a bit old, but another option might be to use the pigpio library. It has a feature that pushes the entire API out to a network connection (this feature is called "pigs").

I struggled trying to use FFI to interface with the C-based pigpio library on a Pi Zero W. Then I was reminded that Dart support for the older, less powerful devices had been dropped from Dart, so I was stuck with no graceful solution until I tried out pigs. The pigs interface completely removed the headaches associated with either FFI on Dart or JNI in Java and just made it a happy Socket interface over the network. I was doing an I2C interface to a temperature/humidity sensor. Pigs should also make a browser-based Flutter app happy as long as you deal properly with the single origin requirements.

Here's a link to pigs on pigpio

Phen
  • 53
  • 6
1

I've recently seen a Dart library for the Raspi's GPIOs. As Dart is the underlying language of Flutter, shouldn't you be able to then use the pins by importing this library?

https://pub.dev/packages/rpi_gpio

Johan vN
  • 23
  • 5
0

As far as I know there is no plugin for Flutter to interact with Peripheral IO. Given Flutter's nature of targeting multiplatform and Android Things being very specific, I do not think something like that will exist.

Most IoT applications have quite simple logic, so it should be reasonable easy to write the UI on Android directly (given you are not planning to release in any other platform anyway.

Your other option would be to create a Flutter plugin for GPIO and port it only to Android, but IMHO it will be harder to do than just code the UI of the app directly on Android.

shalafi
  • 3,926
  • 2
  • 23
  • 27
0

There is now another FFI-based gpio on RPI Dart package called gpiod. Its use is described in this article on running Flutter on a RPI based device.

Maks
  • 7,562
  • 6
  • 43
  • 65