Code Monkey home page Code Monkey logo

Comments (11)

todd-herbert avatar todd-herbert commented on July 30, 2024 1

I am using a Chinese clone of an Arduino Nano

This would possibly be my best guess at the problem so far. I have personally had a few odd experiences with mislabeled chips before, so it's not impossible.

If you still need some pictures of my setup let me know.

  • You wiring was tested working with the Uno
  • You are using a classic Nano.
  • Your Nano is a clone.

I think this is pretty much all that pictures would have investigated, so probably no need right now.


It might be an idea to write a sketch confirming pins 2, 4, and 5 are working correctly as digital inputs and outputs.

Another idea would be to poke around in usbconfig.h. Changing the pins might help something, but you have to be sure to change the other settings in the file to match.

  • Pin 2 could only be move to Pin 3, and you would have to adjust the "Optional MCU Description" section at the end of usbconfig.h. I have never experimented with this.

  • Pins 4 and 5 could be changed for any pin 0 to 7, without needing to further rearrange the code.


I suspect it will be ~2 weeks before the Nano I ordered arrives. At that point I will be able to confirm for you whether the issue is related to the clone or not.

If you make any progress on the issue before then, let me know! I'm not sure what other help I can be right now, but if you have any questions, feel free to ask.

from unohid.

todd-herbert avatar todd-herbert commented on July 30, 2024

I tested this with Uno board as well and its working perfectly but not with Nano.
That's very interesting..

I don't have a nano to test it unfortunately, but as it supposedly also uses ATmega328, I would have expected it to work!

I should double check, that you are definitely using a "Nano", and not "Nano Every", "Nano 33 BLE", "Nano 33 BLE SENSE", "Nano 33 IOT", "Nano RP2040 Connect", or other variant?

I assume something needs to be tweaked in usb_descriptor.h in order for this board to be recognized
I don't think this will be the case. The descriptor describes the "keyboard and mouse" to the host machine. There is no specific information there about the Arduino itself.

I'm really not sure what the cause of this issue is. Starting with the basics, do you think you could share some close-up pictures of your setup: the Nano and the V-USB wiring?

I am interested in solving this: I will order a Nano to investigate, but that could take a while.

from unohid.

Hogar665 avatar Hogar665 commented on July 30, 2024

Hello Todd,

Thanks a lot for writing back.
I am using a Chinese clone of an Arduino Nano but I am pretty sure it has ATmega328P as it says on a chip.
I made a small board size of a a tump drive with rest of the components and USB A connector but I am sure that everything works fine with it become I tested it with Arduino Uno and it worked perfectly.

Thanks again for taking interest in solving this.
If you still need some pictures of my setup let me know.

If there is something I can find out from a serial monitor that can help you guess the cause maybe let me know as well.
I am also opened to idea to try troubleshooting this together on some private chat room or something and then post the results here for everyone else.

from unohid.

todd-herbert avatar todd-herbert commented on July 30, 2024

After-thoughts:

from unohid.

todd-herbert avatar todd-herbert commented on July 30, 2024

I have tested with a genuine Arduino Nano today, and I can confirm that there is some strange behaviour.

@Hogar665 Would you be able to check for me whether the issues are resolved by running the sketch on your nano while the IDE serial monitor is open?

from unohid.

todd-herbert avatar todd-herbert commented on July 30, 2024

@Hogar665 Looking underneath your Nano clone, is the USB IC FT232 or CH340?

from unohid.

todd-herbert avatar todd-herbert commented on July 30, 2024

I am not sure if the issue I have noticed with the genuine Nano is the same as the issue you faced.
They may be different, but related:

In certain conditions, Arduino Nano fails to begin USB connection.
On my setup, the issue occurs only when all of these conditions are met:

  • Board is Arduino Nano
  • The Nano's on-board "Mini-B USB connection" is connected to a Windows PC
  • The Nano's serial port is not open on the Windows PC (serial monitor)

The exact cause is still unknown, but after a lot of experimenting, it seems to be an issue with the Windows driver for the Nano's USB serial adapter. This issue has a handful of reports over the years, however it doesn't seem acknowledged by the Arduino community.

The computer's driver seems to reset the virtual COM port, which triggers the Nano's USB Serial IC to send the DTR signal, which resets the ATmega328P. On my setup, this issue can be prevented by holding the Nano's reset pin HIGH.

To make this action as easy as possible, I have added a workaround:

#define PIN_KEEPALIVE 6
#include "unoHID.h"

// Continue as normal
void setup() {
    Keyboard.begin();
}

Define PIN_KEEPALIVE however you like, then connect the pin directly to RST.
Sketch upload should still work as normal; the pin is only held HIGH during crucial setup moments.

from unohid.

Hogar665 avatar Hogar665 commented on July 30, 2024

Hello todd,

Sorry for not being responsive these day I have been busy.
Thanks for looking into this without me ill try your workaround and let you know if it works.

USB IC on my board is CH340C

from unohid.

Hogar665 avatar Hogar665 commented on July 30, 2024

I just tried adding PIN_KEEPALIVE and got some errors in IDE:

In file included from C:\Users\Username\AppData\Local\Temp.arduinoIDE-unsaved202381-12048-zeqiyw.4qdjg\sketch_sep1a\sketch_sep1a.ino:2:0:
C:\Users\Username\Documents\Arduino\libraries\unoHID\src/unoHID.h:19:25: note: #pragma message: Connect RST pin to PIN_KEEPALIVE
#pragma message "Connect RST pin to PIN_KEEPALIVE"

Also I don't believe I understood you what I have to do for this workaround.
Do I have to connect some pins on the arduino board or should PIN_KEEPALIVE 6 work with the sketch that you made with the default pins?

from unohid.

todd-herbert avatar todd-herbert commented on July 30, 2024

Sorry for not being responsive these day I have been busy.

No need for sorry! I wouldn't have been surprised if you had simply moved on with your project.

USB IC on my board is CH340C

Hmm, it could be a different issue than the one I faced, but still worth a try with the workaround.

I just tried adding PIN_KEEPALIVE and got some errors in IDE:

Ah, sorry, that isn't an error, just a reminder to do the physical wiring part.
It's probably not clear enough. I may need to reword the message.

Also I don't believe I understood you what I have to do for this workaround.

Two steps:

  • #define PIN_KEEPALIVE 6 at the top of your code
  • Connect a wire between pin 6, and the reset pin on your nano

connection

It doesn't need to be pin 6, any pin should work.

Seeing how your Nano has a different USB Serial chip, I do doubt whether this workaround will help, but please, give it a go and let me know the result!

from unohid.

todd-herbert avatar todd-herbert commented on July 30, 2024

@Hogar665
I have now tested the library using a generic Nano clone, which has a CH340 USB Serial IC.
I have not been able to replicate the issue you mentioned. With the clone, everything seems to work fine.

It is worth noting, that with a genuine Nano, I did see a similar issue to the one you mentioned.
In my case, this was fixed by #define PIN_KEEPALIVE 6, and connecting pin 6 directly to pin RST.
Did you ever manage to try this out?

from unohid.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.