How to Communicate Between Arduino and Android using Serial

Nov 30, 2023

As follow up to “How to Communicate Between Arduino Uno and MacOS using Serial”: It’s also fairly easy to steer an Arduino via Android. Yes, Arduino and Android (those two words are just too similar). Just connect your Arduino to the USB-C port of your Android phone. Your phone will not only power the Arduino, but you can also transfer data!

Android has an official API to talk to USB devices connected to the phone’s USB-Port. Since the API for Serial communication is quite obscure in my opinion, I suggest to use a library for that. There are plenty, and many make use of some JNI magic. But that’s not necessary, since the official Java API is enough. I recommend usb-serial-for-android: no JNI, and it’s simple to use. It also comes with a handy Demo App to test the connection:

You see a Google Pixel 3a with an Arduino Nano connected via USB. If you use the same program as presented in “How to Communicate Between Arduino Uno and MacOS using Serial”, then you can now enable and disable the LED!

Cable

On last word about USB-C cables: Not all cables seem to work. To make it even more complex: Not all Arduino boards work with all cables. I tried boards that didn’t work with a specific cable, but the same cable worked with another kind of board. It looks like Arduino boards and also cables don’t implement the USB-C standard completely and consistently. However, what always worked for me (so far) is to use an USB-C-to-A Adapter and then connect a USB-A-to-C (or whatever connector your board uses). This worked consistently. So, if a cable doesn’t seem to work, try it with an Adapter.

Conclusion

I was quite surprised to learn that serial data communication via USB is possible on Android. Not only that, but also how easy it is to use. I hope this knowledge comes in handy for your next project!

You might also like