Android: Bluetooth communication over pyserial

974 views
Skip to first unread message

Martin Flecmart

unread,
Jun 6, 2015, 8:10:51 AM6/6/15
to kivy-...@googlegroups.com
Hi,

is it possible to do serial communication in a Kivy Android App? I can compile the apk with pyserial included, but I don't know how to set up the connection because I have no /dev/rfcomm on my Android device. I had the idea of using pyjnius to open an rfcomm port somehow, but I was not able to manage opening a /dev/rfcomm for my paired device.

Thank you,
Martin

Rupert Lloyd

unread,
Jun 17, 2015, 8:45:44 AM6/17/15
to kivy-...@googlegroups.com
Martin,

Could you use an android.bluetooth.BluetoothSocket via pyjnius?

I have used this approach to implement some glue-code to enable support for the nxt-python (Lego Mindstorms NXT) library on Kivy+Android.

The repo:
The bluetooth glue-code:

Martin Flecmart

unread,
Jun 17, 2015, 9:09:33 AM6/17/15
to kivy-...@googlegroups.com
Hi Rupert,

thanks for your help! Meanwhile I implemented the whole bluetooth communication over pyjnius but I might look over your code and compare the solutions to see which will suit my project better.

Rupert Lloyd

unread,
Jun 18, 2015, 3:16:13 PM6/18/15
to kivy-...@googlegroups.com
Martin,

Can you tell me a little more about how you got pyserial running on Android? This is something I am interested in doing (for an Arduino project). I read that there is a dependency on termios which requires a compilation recipe?

Martin Flecmart

unread,
Jun 18, 2015, 6:28:25 PM6/18/15
to kivy-...@googlegroups.com
Hi Rupert,

yes - pyserial depends on termios which is blacklisted in buildozer. As adviced in this thread, I removed the entry for termios from the blacklist and could compile an app with buildozer for android (https://groups.google.com/forum/#!topic/python-android/VlcNlF6R4lE). From logcat output I saw that pyserial was loaded but from that point I didn't know how to set up my serial connection to start communicating.
Reply all
Reply to author
Forward
0 new messages