Reading USB Serial from an Arduino?

  1. 2 years ago

    I have been browsing the web and looking at existing topics, but I'v had no luck.

    I am trying to read data via USB from an Arduino Nano. I can't seem to find any simple serial reading examples. All I am trying to do at present is read the USB serial and dump it into a textfield. Eventually, I want to parse the data, but that is pointless if I can't even get a TextField dump.

    1. Do I have to somehow specify I am using the USB? Or is that automatically assumed?
    2. Yes, I set both interfaces at 9600 baud
    3. Using Serial.ReadAll puts nothing in my TextField using the DataAvailable Event

    This should be so simple. Can anyone lead me in the right direction?

  2. Jean-Yves P

    28 Jan 2018 Pre-Release Testers, Xojo Pro Europe (France, Besançon)

    did you open the right usb port ?
    do you see your usb-serial adapter in one of the available system.serialport ?

  3. I set the port using

    Serial1.SerialPort = System.SerialPort("/dev/cu.wchusbserial1420")

    And still nothing. I get blank data every time I Serial1.ReadAll — and I am getting no errors. I was expecting my TextField to be inundated with data of some type.

    Also, say I have multiple USB devices, a printer, a mouse receiver, and arduino. How does XOJO know which USB to read the data from?

    Any other ideas?

  4. José M

    28 Jan 2018 Pre-Release Testers, Xojo Pro Spain

    There is an example in Communication -> Serial -> Serial Port Bar Code Reader Example, that i think must work for that test.

  5. Edited 2 years ago

    If you can read it with a normal serial terminal, you can most certainly read it in Xojo. Do you have some example code? This lines probably means you are on a Mac: "Serial1.SerialPort = System.SerialPort("/dev/cu.wchusbserial1420")". Google shows some issues with this Chinese USB-serial device on some systems. Once you program your device via Arduino, do you exit the Arduino IDE before trying to connect with Xojo?

    There are quite a few threads about serial. Below are just a couple samples:
    https://forum.xojo.com/36880-data-from-arduino
    https://forum.xojo.com/12492-need-a-simple-serial-terminal/0

or Sign Up to reply!