1 Reply Latest reply on Aug 3, 2015 3:27 PM by Intel_Alvarado

    Cannot communicate two Edisons over rx tx. Why?

    spartanBoss

      Hi. Im doing a HNC project with the edison boards however Im struggling to make them communicate. I have two edison boards, and have joined them together by jumper wires (rx to tx, tx to rx and a common ground).

       

       

      I upload the following code from one pc to the 1st arduino board using arduino and usb connection. (The code is taken from this website Counting_to_Ten)

       

      -------------------------------------------------------------------------

      int val = 0;

      const int led = 3;

      int incoming = 0;

       

      void setup()

      {

        Serial.begin(115200);

        pinMode(led, OUTPUT);    

      }

       

      void loop()

      {

        incoming = Serial.available();

        while (incoming == 0)                 //Keep checking until there is something available

        {

          incoming = Serial.available();

        }

        val = Serial.parseInt();             //Reads integers as integer rather than ASCI. Anything else returns 0

        for (int i = 0; i < val ; i++)      //Flash the LED the appropriate number of times

        {

          digitalWrite(led, HIGH);  

          delay(500);              

          digitalWrite(led, LOW);  

          delay(500);  

        }

        val = 0;

      }

      -----------------------------------------------------------

       

      The second edison board has this code uploaded to it (exactly the same way as mentioed above however from a different pc):

      -----------------------------------------------------------

      const int led = 3;

      void setup()

      {

        Serial.begin(115200);

        pinMode(led, OUTPUT);

      }

      void loop()

      {

      for (int i = 0; i <= 10; i++)

      {

         Serial.println (i); //Send i to Rx Arduino

         digitalWrite(led, HIGH);

         delay(100);

         digitalWrite(led, LOW);

         delay(900);  

      }

      }

      ------------------------------------------------------

       

       

      Why doesnt this work for my edison boards? I get the numbers 1,2,3,4,5,6,7,8,9,10 appear on the 2nd edison serial monitor, when it should appear on the first edison board. The led flashes fine, however it all happens on one edison board which is what I am having a problem with.

       

      Please help me by telling me whats wrong with my code or suggesting how to fix it. Many thanks!

        • 1. Re: Cannot communicate two Edisons over rx tx. Why?
          Intel_Alvarado

          Hi,

           

          What version of the Arduino IDE are you using? If you need to communicate with two Edison’s using Tx and Rx you must use Serial and Serial1. I can see in your code you are only using Serial. The Serial object is used for the Serial monitor. So you can use this in your receiver board sketch. Serial1 is used to communicate with serial devices; you can communicate and send data with Serial1.write function. You’d have to edit the serial object in your second code, the sender, to use Serial1 instead of Serial.

           

          Sergio