Error when trying to send data to Arduino

Hi,

So for a home security project, I am working on I am gonna be using a phone to be the "Main thingy). And in order to control certain things I need to connect them to an Arduino. In this case an Arduino Uno R3. The problem I am facing now is that I get this error:

int android.hardware.usb.UsbDeviceConnection.bulkTransfer(android.hardware.usb.UsbEndpoint, byte, int, int)

When trying to send data. My code looks like this at the moment. Anyone an idea what causes this? I am using an official Arduino cable with a Samsung OTG usb-c to usb female adapter. Sometimes it will ask to connect to null on my phone.

Thanks for reading :slight_smile:

blocks(1)
blocks

I connect my arduino via bluetooth but maybe you could try …

It works! TYSM!

1 Like

Actually, have another question. Hope you know that too ;). So I cant seem to actually read data from the Arduino. If I do it nothing happens. Never triggers the After Read

Can I see your arduino code ?

1 Like

@dora_paz is is what I use atm. I saw it in a tutorial. My thoughts are it should read the println’s

int incomingByte = 0; // for incoming serial data

void setup() {
  Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
  pinMode(13, OUTPUT);
}

void loop() {
  // send data only when you receive data:
  if (Serial.available() > 0) {
    // read the incoming byte:
    incomingByte = Serial.read();

    // say what you got:
    Serial.print("I received: ");
    Serial.println(incomingByte, DEC);
    Serial.println("A!");

    if(incomingByte == 65){

      digitalWrite(13, HIGH);
    }
  }
}

I actually got it working by using this https://github.com/rkl099/Appinventor-SerialOTG/blob/main/com.SerialOTG.aix extension instead of the Arduino one! Thanks for trying to help anyway!

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.