1

Topic: Arduino Leonardo OTG

Hello,

I would like to connect my Arduino Leonardo directly over USB OTG. (whitout USB to TTL converter)

When i generate an example Sketch on the RemoteXY Webpape for Arduino Mega, Uno, Nano or  Wemos D1 mini, everything works fine over USB OTG.

But when I generate an example Sketch for Arduino Leonardo, my Smartphone find the Arduino Leonardo, but can´t receiving the GUI Configuration.

Had someone the same Issues?

Regards
Andy
PS: ...sorry for my English...

2 (edited by Gunner 2021-07-04 03:38:30)

Re: Arduino Leonardo OTG

Hello.  This will hot be a solution, as I haven't figured it out myself... I have tried to get my own Leonardo board working and it too stalls out on receiving the GUI

But more informative I hope.

The Leonardo is a bit unique with it's USB connectivity... the following is excerpts from the Arduino site

The Leonardo differs from all preceding boards in that the ATmega32u4 has built-in USB communication, eliminating the need for a secondary processor

Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data using the ATmega32U4 hardware serial capability. Note that on the Leonardo, the Serial class refers to USB (CDC) communication; for TTL serial on pins 0 and 1, use the Serial1 class.

So basically I think the issue is that the RemoteXY library is trying to communicate over Serial, when with the Leonardo  think it needs to be Serial1... but who knows, I could be completely wrong as well smile

I have also noticed that the library keeps trying to use SoftwareSerial??  There is a HardwareSerial option in the library, but I haven't quite figured out how to get it to compile (let alone use Serial1)

"And voila, which is French for.......'and then I found out.'" - Ready Player One

3

Re: Arduino Leonardo OTG

We will check it.
Try to replase in code

//#define REMOTEXY_SERIAL Serial1
#define REMOTEXY_SERIAL Serial

4

Re: Arduino Leonardo OTG

"#define REMOTEXY_SERIAL Serial"

Unfortunately the sketch do not compile, when i change the line.

Regards
Andy

5 (edited by Gunner 2021-07-05 07:15:02)

Re: Arduino Leonardo OTG

It will only compile with Serial1... however, still no worky (for me).

"And voila, which is French for.......'and then I found out.'" - Ready Player One

6

Re: Arduino Leonardo OTG

remotexyknight wrote:

"#define REMOTEXY_SERIAL Serial"

Unfortunately the sketch do not compile, when i change the line.

Regards
Andy

Try download library 3.1.7 from github https://github.com/RemoteXY/RemoteXY-Arduino-library (press CODE button and Download ZIP)
And use next code:

#define REMOTEXY_MODE__CDCSERIAL

#include <RemoteXY.h>

#define REMOTEXY_SERIAL Serial
#define REMOTEXY_SERIAL_SPEED 9600


// RemoteXY configurate  
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 255,1,0,0,0,13,0,11,13,0,
  1,0,48,25,12,12,2,31,88,0 };
  
struct {

    // input variables
  uint8_t button_1; // =1 if button pressed, else =0 

    // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0 

} RemoteXY;
#pragma pack(pop)




void setup() 
{
  RemoteXY_Init (); 
  
}

void loop() 
{ 
  RemoteXY_Handler ();

}

7

Re: Arduino Leonardo OTG

Thank you for your reply.


I delete the old library and installed the new library 3.1.7    -  but it didn´t work.

The sketch compile without issues. But when i connect my Leonardo to the Smartphone, i become this error message...

...30.305 App version 4.8.01,API29
...30.305 Device started
...30.305 USB connection started
...30.305 Connecting to USB device: VID 2341, PID 8036 ...
...31.334 USB device connected
...31.363 Receiving GUI configuration...
...32.364 Read timeout error
...32.364 Receiving GUI configuration,try 2 ...
...33.365 Read timeout error
...33.365 Receiving GUI configuration,try 3 ...
...38.367 Read timeout error
...38.367 Receiving GUI configuration,try 4 ...
...38.368 Write error: Error writing 6 bytes at offset 0 length 6
...38.368 Disconnect


Regards,
Andy

8

Re: Arduino Leonardo OTG

Do you choose 9600 speed in the app?

9

Re: Arduino Leonardo OTG

Yes, i do.

10 (edited by Gunner 2021-07-08 22:04:34)

Re: Arduino Leonardo OTG

I have followed and even tested with my own ATmega32u4 based "Leonardo", in my case a Pro Micro that the IDE detects as a Leonardo... still no results. 

But I suspect the issue is caused by the same reason the Leonardo is unique... it's ability to appear to a connected computer as a mouse and keyboard, in addition to a virtual (CDC) serial / COM port.

remotexyknight wrote:

When i generate an example Sketch on the RemoteXY Webpape for Arduino Mega, Uno, Nano or Wemos D1 mini, everything works fine over USB OTG.

In my opinion, all the effort to make the Leonardo work with OTG effectively negates it's unique abilities, compared to other Arduinos... so just use an UNO and save the Leonardo for a task it is better suited for.

"And voila, which is French for.......'and then I found out.'" - Ready Player One