According to my experience and to various information, such as



...the Arduino Micro board will not write data to the host unless "DTR is set to high".

I have been successfully interfacing Mathematica with Arduinos (such as Mega), but am stuck with the Micro, because of the above issue.

Does anyone know how to set the DTR to "high" on the Mathematica side?

Are there any options to given in DeviceOpen when opening the port, to set the DTR to high?

Many thanks for any hint. Ioan


On Windows, a solution is to access the port through NETLink. That allows setting the port's DTR Enable property as follows:

InstallNET[]; (* if not already installed *)
ser = NETNew["System.IO.Ports.SerialPort", "COM5"]
ser@DtrEnable = True

You can then use the methods on the SerialPort object e.g. ser@ReadExisting[] to read from the port, or serOnDataReceived = AddEventHandler[ser@DataReceived, onDataReceived] to register a callback.

| improve this answer | |
  • $\begingroup$ Many thanks. Precious input. I will try this. I just figured out what this syntax (@) means, never used it before. I actually will want to read from the buffer, as I need the last 16 values in there. I used to use (with other Arduinos, connected to by means of DeviceOpen[]), the expression values=DeviceReadBuffer[ArduinoData] $\endgroup$ – Ioan Alexandre Jan 13 '17 at 10:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.