Question about USB SERIAL read

Your program doesn't work, but it doesnt matter., I guess this DTR solves everything.

I installed the SerialOTG application and tried connections with and without DTR. So the DTR resets the board and when it connects, it normally asks for the nickname, but I need to find out if the DTR affects the operation yet, or should it be turned off while downloading and uploading data from and to the arduino. I do not know what the DTR really is, but I will read it in a moment. Sorry for english.

I think the Arduino needs to be hard wired in order to allow an App to reset DTR.

I still think there may be a way to re-write the Sketch to prevent the issue, which is why I asked for a link to it on the Arduino forum.

I do not understand what you mean. I look at the arduino and with the option enabled, the led "power" icon on the arduino goes off (that is, it resets during serial connection) when the DTR option is off the led does not go out. which sketch do you need?

I want to see the forum posts from where you downloaded the Sketch.

This is interesting about DTR reset:

Try this?
A1_Test3.aia (194.5 KB)

If Test3 fails, I think we need to wait for Rolf Kardell's advice.

Sketch is a modified version of this:
https://nessy.info/?p=1439
I deleted everything except chat.

Where did it come from?

And this is a sketch after modification (pasted at the top):
PINS:
CE 9
CSN 10
VCC 5V
GND GND
MOSI 11
MISO 12
SCK 13

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#define CE_PIN   9
#define CSN_PIN 10

const byte Address[5] = {'N','e','s','s','y'};

RF24 radio(CE_PIN, CSN_PIN);

String username = "";
String dataInput;
char dataToSend[32];
char dataReceived[32];


void setup() {
    Serial.begin(115200);
    Serial.println("Enter username...");
    
    radio.begin();
    radio.setPALevel(RF24_PA_MAX);
    radio.setDataRate(RF24_1MBPS);
    radio.setRetries(3, 5);
    radio.openWritingPipe(Address);
    radio.openReadingPipe(1, Address);
}


void loop() {
  // set username
  while (username == "") {
    if ( Serial.available() ) {
      username = Serial.readStringUntil('\n');
      Serial.print("Welcome ");
      Serial.println(username);
    }
  }
  // listen for radio data
  radio.startListening();
   if ( radio.available() ) {
    // read data from radio
    radio.read( &dataReceived, sizeof(dataReceived) );
    Serial.println(dataReceived);  
}
    if( Serial.available() ) {
      // stop listening on radio
      radio.stopListening();
     
    // get serial input
    dataInput = "[" + username + "] " + Serial.readStringUntil('\n');
    Serial.println(dataInput);
    dataInput.toCharArray(dataToSend, 32);

    // send data
    radio.write( &dataToSend, sizeof(dataToSend) );  
    }
}

 
  

  

Please don't mark this Topic as Solved as it has not been. We have thousands of App developers visiting the forum so its important.

"I have no special talent . I am only passionately curious."

Google.

Ah - lost in language translation. I want to see where the Sketch originally came from (didn't you mention the Arduino forum?) as there could be key information about it.

Sorry that this sketch, my mistake.
https://nessy.info/?p=1439

Just read the above again. The App should never be running when the cable is plugged in or removed.

Also, because of Google Security Measures, we probably need to have Google Locate switched on (we have found this to be necessary for Apps that use Bluetooth for example).

I don't really understand what you mean. Could you write what the application is doing wrong? Which function specifically?

The phone and the Arduino should be connected to the USB cable before the App is run.

Sorry - my Polish is far worst than your English :grin:

You mean "permission" to use the device, I read somewhere that it can be set, but it's too much for me at once.

And in the application from the "Serial USB Monitor" play store, the permission itself is set once. But to connect, after pressing "connect" resets arduino.

And it shouldn't be connected before that because the message "nickname ..." would not be read by the application.

We have to ask for that permission in the App code, then we can store the granting of permission so that it does not get asked again. However, the SerialOTG extension does not ask and App Inventor does not either - hence the complex solution of editing the APK Manifest.

By 'it', do you mean the USB cable?