6 Replies Latest reply on Jul 9, 2015 11:32 AM by DiegoV_Intel

    How to communicate with arduino via wifi?

    Ramith

      I tried to communicate with arduino via serial communcation, but failed..

      I'm using a Processing program to send data through serial, and the arduino code reads that serial data. Firstly I used an Arduino Uno and it worked. But I couldn't make the same thing using Edison.

      As the Arduino Uno has only one cable to plug it was easy. but I think what I'm missing with Edison is not connecting the proper cable. (do I have to connect both cables ?)

      Btw as my Macbook Air has only 2 USB slots, I connected one to my sensor (LEAPMOTION) and the other to power edison.

      Is it possible to communicate through serial with edison using only one cable (which is used to power edison) ?

      And if I'm communicating through WIFI how can it be done? (if possible a sample arduino code)

       

      Thanks in advance,

      Ramith.

        • 1. Re: How to communicate with arduino via wifi?
          DiegoV_Intel

          Hi Ramith,

           

          I've tested the communication between Processing and Arduino successfully. I followed this Sparkfun Guide: Connecting Arduino to Processing - learn.sparkfun.com. I was able to send data from the Arduino side to Processing easily, but when I tried to send data backwards, from Processing to Arduino side, I faced some issues.

           

          When you send data with no line ending, you get the message "** B0100000063f694Š" and the sketch stops working. No more data can be sent or recognized. Each time I got that error message I had to reset the sketch (with the shield reset button SHLD RST). To make sure the data is being received correctly, you could run the test without processing but using the Arduino IDE’s serial monitor instead. That’s how I figured it out. If you use the Serial Monitor to send data you have to select an option different of "No line ending". Check the picture below. I chose "Carriage return".

          CarriageReturn.jpg

          Basically you have to do the same process from Processing. You have to send the data with a carriage return at the end in order for Edison to receive the data without problems. For example, to send the string "1" from Processing to Arduino side, you have to use the following line in your Processing sketch:

           

          myPort.write("1\r");

           

          This way you will receive the value "1" in your Arduino sketch. I hope you can solve the problem with this information.

           

          Regarding your other question, you can use the Edison Arduino board only with the USB cable used to power the board. That port is used to provide power and also to upload Arduino sketches just like on an Arduino UNO. Actually, I did the test only with that USB port connected and everything worked.

           

          About the WiFi question, there are some examples in the Arduino IDE under File>Examples>WiFi. I suggest you to check them. They might interest you.

           

          Regards,

          Diego.

          • 2. Re: How to communicate with arduino via wifi?
            Ramith

            Wow.. thanks! I think the problem was with line ending thing..

            I also viewed that serial messages and saw that strange text, but couldn't understand what was the problem, I'll try again and see :)

            Thanks!

            • 3. Re: How to communicate with arduino via wifi?
              Ramith

              Serial Communication between processing and arduino code worked!

              I'm currently stuck with the wifi thing. this is the code i used as my processing code

               

              import com.leapmotion.leap.*; //leap motion library
              import processing.serial.*; //serial communication library
              import processing.net.*;
              Controller leap; //define a controller
              
              //Serial port; //define a port
              
              Client arm;
              
              void setup(){
                size(250,250); //sketch size
                leap = new Controller(); // initialize the controller
              // port = new Serial(this, Serial.list()[2], 115200);//initialize the port in my case its [2]
                arm = new Client(this, "192.168.43.72"115200);
              }
              
              void draw(){
                FingerList fingers = leap.frame().fingers(); //finger list to get the fingers count
                int count = fingers.count(); // integer holds the count of fingers
                
                //int count=5;
                background(0);  // box background color
                fill(255); // text color
                textSize(height/2); // text size
                text(count, 90, 160); // text value and position on the box
               //port.write(count+"\r"); // port sends the integer to arduino*/  arm.write(count);
              }
              

               

              I have my pc and the edison on the same network and the IP address of edison is 192.168.43.72.

              Can you please tell me what I have missed.?

              • 4. Re: How to communicate with arduino via wifi?
                DiegoV_Intel

                Hi Ramith,

                 

                I'm not familiar with Processing. For serial communication I just followed the Sparkfun guide. Now, I'm not sure what are you trying to accomplish. If you could explain in detail what you are trying to do I might be able to help you, but if it is an issue related to Processing, then you might get a better response in the Processing forum: All Categories - Processing 2.x and 3.x Forum

                 

                Regards,

                Diego.

                • 5. Re: How to communicate with arduino via wifi?
                  Ramith

                  I want to do the same thing I did (sending data from processing to edison via serial) via wifi .

                  • 6. Re: How to communicate with arduino via wifi?
                    DiegoV_Intel

                    Hi Ramith,

                     

                    Can you post the code you are using in your Arduino sketch? I will take a look at it. I'm not familiar with Processing but I can try to reproduce what you are trying to do.

                     

                    Regards,

                    Diego.