1 Reply Latest reply on Jul 23, 2015 2:08 PM by CMata_Intel

    Serial1 won't read data on Rx (Pin0)

    HADDAD

      I am trying to develop an Arduino sketch which might work on Galileo Gen 2, but for this i need to read an input Data on PIN 0 (Rx) of the board.

      For this i used Serial1.Read() after setting the baud rate, but the only result i could print out on the serial monitor is : FFFFFF

       

      to get a closer look on my work, here is the code compiled :

       

      char charIn = 0;

      char charead = 0;

       

      void setup()

      {

             Serial.begin(115200);

             Serial1.begin(1200);

             Serial.println(F("setup complete"));

             Serial.print("initializing ... \n");

             Serial.print("charIn : ");

             Serial.println(charIn, HEX);

             Serial.print("charead : ");

             Serial.println(charead, HEX);

      }

      void loop()

      {

           ...

          charead = Serial1.read();

          Serial.println(charead, HEX);

           ...

      }

       

      Thank you for helping me out.

        • 1. Re: Serial1 won't read data on Rx (Pin0)
          CMata_Intel

          Hi HADDAD,

           

          The reason of why you are receiving FFFFFFFF in the Serial Monitor could be a problem in the receiving line, how are you testing this? What do you have attached to your board?

           

          Just to test this, I added some lines to your code so I would able to test it by writing in Tx (Pin 1), check the code below. And I used a wire to connect Rx to Tx (Pin0 -> Pin1) and it worked fine, I was able to see the characters in the Serial Monitor of the IDE.

           

          I suggest you to check the functionality of the shield or device you are using to send information to the Rx pin. Is the device attached to Rx using 1200 as baud rate?

           

          char charIn = 0;
          char charead = 0;
          
          void setup()  
          {
                 delay(2000);                       //New Line : This line allowed me to see all the messages generated in the "void setup" in the Serial Monitor of the IDE
                 Serial.begin(115200);
                 Serial1.begin(1200);
                 Serial.println(F("setup complete"));
                 Serial.print("initializing ... \n");
                 Serial.print("charIn : ");
                 Serial.println(charIn, HEX);
                 Serial.print("charead : ");
                 Serial.println(charead, HEX);
          }
          void loop()
          {
              charead = Serial1.read();
              Serial.println(charead,HEX);
              Serial1.print("1234");              //New Line: Printing 1234 in Tx. In order to test the code you should wire Tx to Rx 
              delay(1000);                        //New Line: This delay is just to see the receive signal slowly
          }
          

           

          Regards,

          Charlie