Arduino Firmata wont register arduino

Hello, I’m actually not very experienced with coding but my friend who wrote this is out of town and i was hoping i could find a solution soon.

So the basic part of the issue is that this code has always been problematic. You can throw a dart at a board of computers and maybe 1 or 2 out of 10 will actually work. Up until last week my hp spectre could run the code and my friends hp pavilion could run it. But my computer did an update (20h1) and now it isn’t working. So i am basically screwed by Microsoft once again.

What im trying to do is use processing to control some esc’s on an arduino through firmata. xbox controller ->laptop ->Aduino->ESC->BLDC motor

This is the problem bit of code.
arduino = new Arduino(this, Arduino.list()[8], 57600); // finds arduino usb location

Whats happening is what happens when their is no Arduino attached. Regardless of the arduino, usb port, or polling rate i am getting a failed connection and no display of serial communication.

I.E. ArrayIndexOutOfBoundsException: 8
Could not run the sketch (Target VM failed to initialize).

This is a major frustration and i have attempted to use linux but I’m not very experienced and i couldn’t install processing on Ubuntu. I may have to do the unthinkable and get a used mac.

Hello,

This connects to the serial port you chose with the 8; it does not find it.

Make sure that you are connecting to the correct serial port.

Try this to list your serial ports and select the one the Arduino is connected to:
https://processing.org/reference/libraries/serial/Serial_list_.html

If it is not in the list you will get this error:

References:
https://processing.org/reference/libraries/serial/Serial.html
https://processing.org/reference/libraries/serial/index.html

:)

We have that piece of code and i know for sure that COM8 is the Arduino because it is identified in device manager and with the code you mentioned. The issue is that no matter what USB port i use and what Arduino i use with whichever cable the software has no communication with the Arduino. I’m fairly sure its either an incompatibility with the library or a driver incompatibility in windows because it works well on some computers but not others. I wouldn’t be surprised because the library was last updated in 2017.

It’s so frustrating. It seems not to work on any USB 2.0 port for some reason and will only function on laptops with USB 3.1 extensible hosts. that is, until my laptop did an update and now it wont work.

Because its so hit and miss i think my only option is to get a used mac or something. And i cant afford to reset my laptop back to windows 20h0 right now.

Also, i know their is no communication at all because the TX and RX leds aren’t responding.

Thanks, i appreciate your response. Its good to double-check things.

ANOTHER tid bit. i figured out with another firmata based software that the communication is possible it is just something messed up with processing. It seems like processing is unable to fetch the Arduino even with it specified. IE it is proceeding’s issue with a driver on windows.

Try @glv’s suggestion and print the list of serial ports. If the Arduino port is not present then you have confirmed that Processing is not ‘seeing’ the port and possibly you have a driver issue. For example, if the Arduino is a clone it may not be using the FTDI Serial-USB chip but perhaps the CH340 and the Windows update may have removed the old driver…

I’m not using Firmata but I have no problems in Processing connecting to various Arduinos that I use e.g. Nano, Uno and ATmega varieties all work.

Regards, Phil

As i said, i have used that piece of code and it does identify 3 com ports, specifically COM-8 is the Arduino and even after selecting it still fails to connect. I am also using two genuine Arduino Uno’s. It is such a conundrum because the software knows their is a come device but cannot connect.

I will try to find some older Arduino drivers and use them. The really frustrating is that other firmata based software’s can connect to the Arduino. I tried to use windows remote Arduino service which could connect and initialize the motors. i am also having no issues installing the code on the Arduino. there are no issues writing to it.

The issue is that somewhere along the line processing cant write to the Arduino.

Thanks fro the response, i appreciate it.
These issues are seriously testing my patience and stress.

I know how you feel! Maybe you should write a very simple sketch on the Arduino and one in Processing to send some simple ASCII text strings from Processing to the Arduino. You can’t run the Arduino Serial monitor to show what it’s receiving because the port will already be in use but if you use Serial.println() in the Arduino sketch to echo what it’s receiving back to the Processing IDE you will be able to read them in Processing’s console.

This should establish if Processing is communicating correctly with the Arduino. I always start off simple and build things up in stages!

Regards Phil.

Hello,

Can you provide an MCVE (minimal, complete and verifiable example) for us to test?
I am confident others will also want to test this out.

Please provide formatted code:
https://discourse.processing.org/faq#format-your-code

I do a lot of work with serial programming and generally able to sort out any issues. These can be a challenge at times but I like a challenge.

If there is a problem with the Processing serial library that I can verify I will submit an issue.

I have the most recent Windows update and have no serial issues with Processing and other devices.

I updated my Arduino software (always a ZIP), did a driver update (manually), installed Firmata library and tried this simple example:
https://adestefawp.wordpress.com/learning/using-arduino-firmata-and-processing-together/

It worked fine.

:)

1 Like

Just a thought. COM8 will actually be index 7, not 8 in the serial port list array.

COM ports on Windows start numbering from COM1 = [0], COM2 = [1] etc. … COM8 = [7].

Could it be this simple?

Phil.

1 Like

Good catch! :)

This means there are 3 elements in the list [0], [1], [2] in the list and [8] is certainly not one of them and will give the error:

ArrayIndexOutOfBoundsException: 8

Examples:

:)

1 Like

You’re right of course. I was assuming all COM ports were present but the OP needs to find the actual index for his “COM8”. That was why I suggested he follow your original advice and print out the Serial.list() to the console. :slight_smile:

Phil.

1 Like

@PhilHaw

That was a good catch indeed!

I went back and looked again thanks to you.

:)

We often miss the wood for the trees :crazy_face:

You wouldn’t believe the hours I’ve spent over the years looking for some ‘complex bug’ only to find it was something simple staring me in the face the whole time.

:smiley:

Phil.

I just looked back at my post, I tried using assigning it a number bellow with no luck. here is the code PROCESSING CODE FOR CONTROLL - Google Drive

Here is all the code! thanks so much, you guys are awsome!!! and this is the robot im trying to get working. We are a small robotics team in port townsend working on ocean reclamation with it. I was being kinda coy because i wasn’t sure what kind of reception i would get.

https://drive.google.com/drive/folders/1w0fo9eic1HRE2yNYLIgHTfZxfJSZp4Oi?usp=sharing

1 Like

I still think you should use the simple test code that @glv provided earlier to make doubly sure the COM port is what you think it is. The original error you posted “ArrayIndexOutOfBoundsException: 8” would indicate that you are using the wrong array index. If you know that your Arduino is definitely COM8 then run the test sketch and you will be able to read the index value [x] for the “COM8” entry in the Serial ports list.

Phil.

I am 100% sure i am using the correct port. We were using the code before i made this posting to identify the com port.

Are you using the same computer and plugged into the same USB port? If not, the COM port assigned to the Arduino could be different. Can you please open Windows Device Manager control panel, expand the Ports (COM & LPT) entry, take a screenshot and post it here so we can see. BTW you don’t need to host the image just copy and paste it in your reply :slight_smile:

It is displaying the same, and i know that it is the correct port because it shows up the same in both processing and device manager.

Try this:

arduino = new Arduino(this, "COM8", 57600);

I did give you a hint about this a few posts above in the picture.

:)

2 Likes

DUDE I COULD FREAKING GIVE YOU A HUG. This worked, I have no idea why this slight syntax change fixed it but i love you man. I have been ripping my hair out for a while with why this wasn’t working. I cannot say thanks enough.

I would be interested to know why the change from
this, (arduino = new Arduino(this, Arduino.list()[8], 57600):wink:
to this (arduino = new Arduino(this, “COM8”, 57600):wink:
fixed the issue, especially given that it worked on some computers but not others?

2 Likes