Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arduino Leonardo Requests DTR to be high #37

Open
placic opened this issue Jul 19, 2020 · 1 comment
Open

Arduino Leonardo Requests DTR to be high #37

placic opened this issue Jul 19, 2020 · 1 comment

Comments

@placic
Copy link

placic commented Jul 19, 2020

Hi,
I tried to use Arduino Leonardo with the latest Solid Arduino and Standard Firmata 2.5.8., but up to now I had no luck. My Arduino not answered on any command I sent.
The Microsoft Windows Remote Experience was working perfectly.
Then I made some investigation, so I used serial port monitor to find out what happening.
The only difference I realized that Microsoft Windows Remote Experience is turning DTR signal high each time it communicates, but Solid Arduino not.
In the source code of SolidSoils Arduino where the serial port opened I put the following:
base.DtrEnable = true;
Since this change the software is works also with Arduino Leonardo

@bradmartin333
Copy link

bradmartin333 commented Nov 30, 2022

Hey @placic - I had the same issue with the Arduino Nano Every. My solution was to add this before calling connection.Open();

SerialPort p = new(connection.PortName, connection.BaudRate) { DtrEnable = true };
p.Open();
Thread.Sleep(250);
p.Close();

The delay is important as you need enough time for the arduino to receive the DTR signal and write back.

Full GetConnection() method:

private static ISerialConnection? GetConnection(string name)
{
    ISerialConnection connection = new SerialConnection(name, SerialBaudRate.Bps_57600);
    if (connection == null) Console.WriteLine("No Arduino found");
    else
    {
        try
        {
            // Unfortunate, but have to ping the port to enable coms
            // This is equal to toggling on the Serial Port Monitor in the Arduino IDE
            SerialPort p = new(connection.PortName, connection.BaudRate) { DtrEnable = true };
            p.Open();
            Thread.Sleep(250);
            p.Close();

            connection.Open();
            Console.WriteLine($"Connected Arduino at port {connection.PortName}");
        }
        catch (Exception)
        {
            Console.WriteLine($"Cannot connect to arduino on {connection.PortName}. Close open connections and try again.");
            return null;
        }
    }
    return connection;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants