Arduino Leonardo Requests DTR to be high
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
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;
}