serial0 not available

Discussion in 'General Discussion' started by nathans, Aug 9, 2018.

  1. nathans

    nathans New Member

    Joined:
    Jun 22, 2018
    Messages:
    4
    Likes Received:
    0
    Hello Everyone,
    Trying to use a UDOOneo to receive and send serial data from my PC to test a communication protocol I am trying (trying being the key word) to write.

    Anyways using the following code I should be able to see a single byte being received but nothing happens in the Serial Monitor window, but I am not super familiar with programming for adruino so I may be missing something obvious



    int incomingByte = 0;
    void setup() {
    Serial.begin(9600, SERIAL_8N1);
    }

    void loop() {
    if (Serial0.available() > 0) {
    //receive input
    incomingByte = Serial0.read();
    //say what you got
    Serial0.print("I received: ");
    Serial0.println(incomingByte);

    }
     
  2. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,091
    Likes Received:
    529
    The Neo arduino has 2 serial devices, Serial and Serial0. Serial is connected to the Linux side, Serial0 is connected to pin 0 and 1. You are mixing the devices in your sketch. Replace Serial0 by Serial and it will work.
     
  3. nathans

    nathans New Member

    Joined:
    Jun 22, 2018
    Messages:
    4
    Likes Received:
    0
    I have tried using Serial, and Serial1 but neither appear available to me,
    by running the code below
    int incomingByte = 0;
    void setup() {
    Serial.begin(9600, SERIAL_8N1);
    }

    void loop() {
    if (Serial0.available() > 0) {
    digitalWrite(13, HIGH); //Turn LED ON when Serial Available
    //receive input
    incomingByte = Serial0.read();
    //say what you got
    Serial0.print("I received: ");
    Serial0.println(incomingByte);
    } else digitalWrite(13, LOW); //Turn LED OFF when Serial not available
    }
     
  4. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,091
    Likes Received:
    529
    Try this and send a character to the Arduino side with the Arduino IDE serial monitor.
    Check the examples in the documentation: https://www.udoo.org/docs-neo/Serial_Libraries/index.html
    Also check my tutorials that discuss this communication between linux and Neo Arduino. Howto Neo IoT Sensors, Howto Neo Webcontrol


    Code:
    int incomingByte = 0;
    void setup() {
    Serial.begin();
    }
    
    void loop() {
    if (Serial.available() > 0) {
    digitalWrite(13, HIGH); //Turn LED ON when Serial Available
    //receive input
    incomingByte = Serial.read();
    //say what you got
    Serial.print("I received: ");
    Serial.println(incomingByte);
    } else digitalWrite(13, LOW); //Turn LED OFF when Serial not available
    } 
     

Share This Page