Message Boards Message Boards

2
|
16480 Views
|
9 Replies
|
12 Total Likes
View groups...
Share
Share this post:

Can't connect to Serial Device using Mathematica 10 under Windows 7

Posted 10 years ago

Following instructions as listed in the documentation Serial (RS-232 / RS-422 serial protocol I'm unable to successfully connect to the device (Arduino Uno) using

DeviceOpen["Serial",{"COM10","BaudRate"->9600}]
(*SerialLink`SerialPortOpen::nopen: Could not open the port COM10.*)

Port COM10 is alive, well and tested in the computer, using another program to link the device, send byte codes and receive values back. enter image description here

POSTED BY: Diego Zviovich
9 Replies

Diego... My apologies for bringing an out of subject issue. I have been going back and forth between Arduino and Mathematica Devices forums. At some point the line got blurred. Thank you for the links.

POSTED BY: Jose Calderon
Posted 10 years ago

Hola Jose, Serial.println and Serial.write are Arduino functions and not from mathematica.

For Serial.println > http://arduino.cc/en/Serial/Println

For Serial.write > http://arduino.cc/en/Serial/Write

POSTED BY: Diego Zviovich

@Fahim Chandurwala This is ver interesting.. I just puzzled.. How did you figure this out?

Another thing,, I an confuse as to when to use Serial.println[] and when to use Serial.write[]? Can anyone comment here?

POSTED BY: Jose Calderon
Posted 10 years ago

@Fahim Chandurwala, thank you very much. It worked!!

I hope our friends from Wolfram update the documentation. There was no way that I would have figured that out without your help.

Now this works. Using the Arduino Sketch mentioned above.

DeviceOpen["Serial", {"\\.\COM10", "BaudRate" -> 9600}]
readSensor[connection_, type_] := 
     Module[{}, DeviceWrite[connection, type]; Pause[.1]; 
     FromCharacterCode[DeviceReadBuffer[conn]]]
(*Read Temperature*)
readSensor[conn,"T"]
(*31.00000*)
(*Read Humidity*)
readSensor[conn,"H")
(*42.00000*)
POSTED BY: Diego Zviovich
POSTED BY: Arnoud Buzing

@Diego Try "\\.\COM10" instead of "COM10" as a workaround.

DeviceOpen["Serial", {"\\.\COM10", "BaudRate" -> 9600}]
POSTED BY: Arnoud Buzing
Posted 10 years ago
POSTED BY: Diego Zviovich

What is the set up in your Arduino? Can you show the sketch? Have you see the serial monitor ? I had similar problems. It looks like the Matematica kernel gets hang. Close the notepad or quick and restart kernel.

Also, you are using he putty client to capture the Port 10, therefore, Mathematica will not be able to capture it the same time.

POSTED BY: Jose Calderon
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract