# Device connection failed

**URL:** <https://discourse.processing.org/t/device-connection-failed/46408>\
**Category:** Electronics (Arduino, etc.)\
**Created:** [May 17, 2025, 11:28pm UTC](https://discourse.processing.org/t/device-connection-failed/46408 "2025-05-17T23:28:08Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![UZEW8](https://avatars.discourse-cdn.com/v4/letter/u/9de0a6/32.png) [@UZEW8](https://discourse.processing.org/u/UZEW8)\
**Post date:** [May 17, 2025, 11:28pm UTC](https://discourse.processing.org/t/device-connection-failed/46408/1 "2025-05-17T23:28:08Z")

</div>

I cannot run the very first board example. “Oscilloscope”. Processing sees 2 COM ports, tries to connect to one and then the other, but then announces “failed to connect”. Please help (board is blinking BLU at 2 Hz)

Console report  
16:24:56 Detected serial port: COM1 COM3  
16:24:56 Attempt to connect COM1…  
16:24:59 Attempt to connect COM3…  
16:25:1 Device connection failed

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [May 18, 2025, 12:09am UTC](https://discourse.processing.org/t/device-connection-failed/46408/2 "2025-05-18T00:09:24Z")

</div>

Hello @UZEW8 ,

Please provide a link to the code (Processing and microcontroller) you are using.

Which microcontroller are you using?  
Operating system?  
Processing version?

`:)`

---

<div class="post-metadata">

**Author:** ![UZEW8](https://avatars.discourse-cdn.com/v4/letter/u/9de0a6/32.png) [@UZEW8](https://discourse.processing.org/u/UZEW8)\
**Post date:** [May 18, 2025, 8:05pm UTC](https://discourse.processing.org/t/device-connection-failed/46408/3 "2025-05-18T20:05:27Z")

</div>

Thanks for the quick response

My DELL All-In-One computer info is

 ![image.png](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/5/f/5f14053c021a038961172a197b6caa08bbfa97c5.png)

I’m using Processing 4.4.1

My hardware is:

Starter Kit ESP32  
FNK0047 A3B0

From the starter user guide Chapter 1 - Oscilloscope and SerialDevice (first project “ellipse” works OK)

Email disallows any more attachments

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [May 19, 2025, 7:29pm UTC](https://discourse.processing.org/t/device-connection-failed/46408/4 "2025-05-19T19:29:58Z")

</div>

> [@UZEW8](#):
>
> Thanks for the quick response

Hello,

I am not familiar with this hardware or the protocols they are using.

Is there a very simple serial communication example that you can start with just to verify a connection?

`:)`

---

<div class="post-metadata">

**Author:** ![UZEW8](https://avatars.discourse-cdn.com/v4/letter/u/9de0a6/32.png) [@UZEW8](https://discourse.processing.org/u/UZEW8)\
**Post date:** [May 19, 2025, 8:05pm UTC](https://discourse.processing.org/t/device-connection-failed/46408/5 "2025-05-19T20:05:49Z")

</div>

Thank you for engaging

Starter Kit ESP32  
FNK0047 A3B0

My Dell All-In-One computer

 ![image.png](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/5/f/5f14053c021a038961172a197b6caa08bbfa97c5.png)

The Processing tutorial I am working to - Chapter 1 of Processing.pdf 4/23/2025

[image]

The Sketch where I run into trouble. Processing Version 4.4.1

[image]  
Library Oscilloscope and  
SerialDevice

V 4.4.1 Preferences

[image]

---

<div class="post-metadata">

**Author:** ![RichardDL](https://avatars.discourse-cdn.com/v4/letter/r/f475e1/32.png) [@RichardDL](https://discourse.processing.org/u/RichardDL)\
**Post date:** [May 19, 2025, 8:38pm UTC](https://discourse.processing.org/t/device-connection-failed/46408/6 "2025-05-19T20:38:16Z")

</div>

Hi @UZEW8, Please would you look in Device Manager, at the Ports (COM & LPT) (No Processing program trying to talk to the Arduino while you are doing this.)

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/4/b/4b50c008b8068f8b5b30af0b70d320e9742fad2c.png)

While watching that please connect your Arduino, wait at least 10 sec, and disconnect. You should see an extra com port appear and disappear. (None shown in my image) When it is there it should be normally coloured (as shown) without a yellow triangle. Try each port on your PC. If this works correctly you know the driver is creating the COM port correctly, and you know the correct name.

---

<div class="post-metadata">

**Author:** ![UZEW8](https://avatars.discourse-cdn.com/v4/letter/u/9de0a6/32.png) [@UZEW8](https://discourse.processing.org/u/UZEW8)\
**Post date:** [May 19, 2025, 10:39pm UTC](https://discourse.processing.org/t/device-connection-failed/46408/7 "2025-05-19T22:39:12Z")

</div>

Richard  
This is what I get before and after connecting the board to USB

 ![image.png](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/e/a/eabcdb332cff4ce85b22ad12294a960ff069eca9.jpeg)

COM4 goes away when I disconnect the board.  
When connecting to other USB ports I get COM5 and COM6. A similar “connection failed” results.  
Steve

---

<div class="post-metadata">

**Author:** ![RichardDL](https://avatars.discourse-cdn.com/v4/letter/r/f475e1/32.png) [@RichardDL](https://discourse.processing.org/u/RichardDL)\
**Post date:** [May 20, 2025, 9:51am UTC](https://discourse.processing.org/t/device-connection-failed/46408/8 "2025-05-20T09:51:48Z")

</div>

Hi Steve, It’s good that the COM port is created and shows up cleanly in Device Manager. The board has the CH340 chip (usb-serial interface). A feature (?) of this chip and driver is that the COM port number is differen depending on which usb socket you connect to. The serial properties of the port don’t matter, the sketch will set what it wants.

The Oscilloscope sketch seems to be trying each port, looking for something, not finding what it wants. Have you loaded the Arduino with whatever software does the scope’s data gathering? If you have why is it not working? Hmm… Suggest you examine the sketch where it looks and rejects. You are using an ESP32? Is that the only Ard/ESP you have? We may need another channel to see what’s going on e.g. LCD screen, software serial, WEB? (slow to put together but I have used it).

---

<div class="post-metadata">

**Author:** ![UZEW8](https://avatars.discourse-cdn.com/v4/letter/u/9de0a6/32.png) [@UZEW8](https://discourse.processing.org/u/UZEW8)\
**Post date:** [May 20, 2025, 5:24pm UTC](https://discourse.processing.org/t/device-connection-failed/46408/9 "2025-05-20T17:24:49Z")

</div>

Richard  
This board is an ESP32 and is my first and only Arduino. And this is the first sketch I have tried. I’m going to load and try this on another Windows 10 laptop. Next.  
Steve

---

<div class="post-metadata">

**Author:** ![RichardDL](https://avatars.discourse-cdn.com/v4/letter/r/f475e1/32.png) [@RichardDL](https://discourse.processing.org/u/RichardDL)\
**Post date:** [May 20, 2025, 7:06pm UTC](https://discourse.processing.org/t/device-connection-failed/46408/10 "2025-05-20T19:06:56Z")

</div>

Steve, I have these progs loaded on a W7 laptop and an Arduino Nano. Considering this is a published example for new users I’m surprised it doesn’t work first time. Please confirm that I’m using the same 4 files:

> <https://github.com/Freenove/Freenove_Starter_Kit/blob/master/Processing/Arduino/SerialDevice/SerialCommand.h>

> <https://github.com/Freenove/Freenove_Starter_Kit/blob/master/Processing/Arduino/SerialDevice/SerialDevice.ino>

> <https://github.com/Freenove/Freenove_Starter_Kit/blob/master/Processing/Processing/Oscilloscope/Oscilloscope.pde>

> <https://github.com/Freenove/Freenove_Starter_Kit/blob/master/Processing/Processing/Oscilloscope/SerialDevice.pde>

I’m trying to see why it’s not going. I don’t think another PC will help. I asked about ESP/Ard because if you are investigating and repeatedly loading then ESP is much slower to load. I poke at this for a little longer but don’t let me stop you or anyone else trying anything.

---

<div class="post-metadata">

**Author:** ![UZEW8](https://avatars.discourse-cdn.com/v4/letter/u/9de0a6/32.png) [@UZEW8](https://discourse.processing.org/u/UZEW8)\
**Post date:** [May 20, 2025, 11:19pm UTC](https://discourse.processing.org/t/device-connection-failed/46408/11 "2025-05-20T23:19:34Z")

</div>

Richard  
Here is my SerialCommand - looks the same  
/\*  
Class SerialCommand  
Author Ethan Pan @ Freenove  
Date 2016/8/8  
Brief This class is used to save serial command.  
Copyright Copyright © Freenove  
License Creative Commons Attribution ShareAlike 3.0

Here is my SerialDevice - different  
/\*  
Sketch SerialDevice  
Author Zhentao Lin @ Freenove  
Date 2020/07/11  
Brief This sketch is used to communicate to Processing sketch running  
on PC. The Processing sketch will automatically detect and  
connect to this board which use the same trans format.  
Copyright Copyright © Freenove  
License Creative Commons Attribution ShareAlike 3.0  
\*/  
#include “SerialCommand.h”

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [May 20, 2025, 11:51pm UTC](https://discourse.processing.org/t/device-connection-failed/46408/12 "2025-05-20T23:51:32Z")

</div>

Hello @UZEW8,

Please give programs below a try to test communication between Arduino and Processing with your system, software and hardware.

They were _Google Gemini_ generated.  
I asked for a simple program to send data from Arduino to Processing.  
It could have been simplified.  
It works!

Arduino side:

```auto
// Arduino Code to send a simple counter value to Processing

int counter = 0; // Initialize a counter variable

void setup() {
  Serial.begin(9600); // Start serial communication at 9600 baud rate
                      // This speed must match the Processing sketch
}

void loop() {
  Serial.println(counter); // Print the counter value followed by a newline character
                           // The newline character is important for Processing to read full lines
  counter++; // Increment the counter
  if (counter > 255) { // Reset counter to keep it within a reasonable range (0-255 for byte)
    counter = 0;
  }
  delay(100); // Wait for 100 milliseconds before sending the next value
                           // This prevents overwhelming Processing with too much data
}

```

Processing:

```auto
// Processing Code to receive data from Arduino

import processing.serial.*; // Import the serial library

Serial myPort; // Create a Serial object
int val; // Variable to store the incoming data

void setup() {
  size(400, 300); // Set the window size (optional, but good practice)

  // Print a list of available serial ports to the console
  println(Serial.list());

  // IMPORTANT: Replace "COM3" (or "dev/cu.usbmodem1411" on Mac/Linux)
  // with the actual serial port your Arduino is connected to.
  // You can find this in the Arduino IDE under Tools > Port, or by looking at the output of Serial.list()
  String portName = Serial.list()[0]; // Assumes Arduino is the first port in the list, adjust if needed
                                       // A more robust way is to specifically look for your Arduino's port
  myPort = new Serial(this, portName, 9600); // Initialize the serial port at 9600 baud rate
                                              // This speed must match the Arduino sketch
}

void draw() {
  background(0); // Clear the background
  // Check if there's data available in the serial buffer
  if (myPort.available() > 0) {
    // Read the incoming data as a line (until a newline character is encountered)
    String inString = myPort.readStringUntil('\n');

    if (inString != null) { // Make sure the string is not null
      inString = trim(inString); // Remove leading/trailing whitespace (especially the newline)
      try {
        val = Integer.parseInt(inString); // Convert the string to an integer
        println("Received from Arduino: " + val); // Print the received value to the console
      } catch (NumberFormatException e) {
        println("Error parsing integer: " + inString);
      }
    }
  }

  // You can use the 'val' variable to do something in your Processing sketch,
  // like drawing a rectangle or changing its color based on the received value.
  fill(val, 100, 200); // Example: Use the received value to control the red component of a color
  rect(width/2 - 50, height/2 - 50, 100, 100);
}

void serialEvent(Serial p) {
  // This function is an alternative way to read serial data,
  // it's called automatically when new data arrives.
  // For this simple example, reading in draw() is sufficient,
  // but for more complex scenarios, serialEvent can be useful.
  // String inString = p.readStringUntil('\n');
  // if (inString != null) {
  // inString = trim(inString);
  // try {
  // val = Integer.parseInt(inString);
  // println("Received (serialEvent): " + val);
  // } catch (NumberFormatException e) {
  // println("Error parsing integer (serialEvent): " + inString);
  // }
  // }
}

```

This is what you should see in the Processing console:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/2/1/216e900212848c3a404550e0d84485e72dcd67e2.png)

I have been embracing AI tools for some code generation.  
Do not assume AI code is always correct or the best example and do a thorough examination of code and scrutinize it.  
As an experienced programmer I can use these tools effectively and getting better at being a prompt engineer.

Google Gemini responded to above with:

> That’s an excellent approach! It’s smart to leverage AI for code generation while maintaining a critical eye. As an experienced programmer, you’re perfectly positioned to use these tools effectively. You know that AI-generated code, while often a great starting point, benefits immensely from careful review, optimization, and validation to ensure it meets your specific project requirements, performance needs, and best practices.
> 
> It’s like having a very fast junior developer: they can draft a lot of code quickly, but the experienced hand is essential for quality control and bringing it up to production standards. Keep up the great work!

You must still strive to understand the code.

References can be found here:  
_[Libraries / Processing.org](https://processing.org/reference/libraries)_ \< Serial library!  
_[Prompt engineering - Wikipedia](https://en.wikipedia.org/wiki/Prompt_engineering)_

Here to help if you have any questions!

I did try the _oscilloscope code_ from here but was not successful:

> **[Freenove Ultimate Starter Kit for ESP32-WROVER CAM](https://store.freenove.com/products/fnk0047)**
>
> Overview:ESP32-WROVER is a powerful and small controller with onboard wireless and camera.This kit helps you learn and use it with its tutorial and project examples.We provide free technical support to help you with any questions and problems.Main...

There is a download link in there for code.

`:)`

---

<div class="post-metadata">

**Author:** ![UZEW8](https://avatars.discourse-cdn.com/v4/letter/u/9de0a6/32.png) [@UZEW8](https://discourse.processing.org/u/UZEW8)\
**Post date:** [May 22, 2025, 12:51am UTC](https://discourse.processing.org/t/device-connection-failed/46408/13 "2025-05-22T00:51:55Z")

</div>

I have the system working now. I am using a windowx64 laptop now, but more importantly I had some incorrect selection for th ESP32 configuration. Thanks for your help  
Steve

---

<div class="post-metadata">

**Author:** ![RichardDL](https://avatars.discourse-cdn.com/v4/letter/r/f475e1/32.png) [@RichardDL](https://discourse.processing.org/u/RichardDL)\
**Post date:** [May 23, 2025, 9:35am UTC](https://discourse.processing.org/t/device-connection-failed/46408/14 "2025-05-23T09:35:59Z")

</div>

@glv thanks for trying the oscilloscope code, good to have 2nd opinion.

@UZEW8 The oscilloscope is working now? Good. Would you like to share the download link please?

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [May 24, 2025, 3:00am UTC](https://discourse.processing.org/t/device-connection-failed/46408/15 "2025-05-24T03:00:46Z")

</div>

Hello @UZEW8 ,

I managed to get this working with a WEMOS D1 Mini ESP8266 WiFi IoT Module 4MB.

I had to do disconnect\connect after programming this device (clone) to be able to connect to it.

`:)`
