Pass data from USB arduino to sketch

I'm using Processing 3.0 in android mode + Android Studio to develop my app. My app reads serial data from an Arduino over USB and the sketch displays the data. I had this working ok but it was too slow and jumpy so I changed the Arduino program to use the Multiwii Serial Protocol. That protocol works great if I use regular old Android and Views. When I try to go back to Processing and send the serial data from MainActivity to Papplet sketch, I get Null pointer errors. The Multiwii Serial protocol works great until I try to use Processing Android mode. I don't know what to do to get the received byte[] data into the sketch. I know the MainActivity receives over the USB when I get the toasts saying so.

How should I try to do this?


  • I should probably mention that the MainActivity uses a "service" to open and establish the serial connection. Heres where the serial message gets worked in MainActivity.

        public void handleMessage(Message msg) {
                case UsbService.MESSAGE_FROM_SERIAL_PORT:
                    byte [] data = (byte []) msg.obj;
                    for (byte b : data) {

    The parser.parse(b); reads the multiwii protocol and deciphers the different messages sent by the Arduino. I've tried sending byte[] data to the Papplet sketch and then worry about deciphering the messages in there but it is just Null. I've also tried parsing in MainActivity and put what I want into an int[] and send that and just get Null there too.

    Is there some way to do this and still be able to use Processing?

Sign In or Register to comment.