1 2 Previous Next 23 Replies Latest reply on Feb 15, 2016 6:08 AM by runlei

    Galileo: connect galileo with router

    runlei

      Hi all,

       

      I am doing my project : remote control of home heating using Galileo. So I need to  create a web server for galileo.

       

      I am trying to connect galileo with router and give it a static Ip address. ( my router doesn't acess internet, it just broadcasts it's SSID). In this case, is it possible for galileo to connect this router and successfully get an IP address?

       

      One more question, in order to create a web server for galileo ( remote control home heating through smart phone with wifi  ), which IDE is good to implement ?  what's the difference between XDK and Arduino IDE?

       

      is there someone give me some suggestions? thanks very much.

       

       

      Regards,

      Runlei

        • 1. Re: Galileo: connect galileo with router
          DiegoV_Intel

          Hello runlei,

           

          It should be possible to connect to the network although the router doesn't have Internet access. You could try it to be sure about it.

           

          On the other hand, I would recommend you to use the Arduino IDE. There are some examples that you might find interesting for your project. Those examples are in the examples section in the Arduino IDE (File>Examples). The difference between XDK and the Arduino IDE is basically the programming language you use. With the XDK you can write your scripts using JavaScript, so if you feel comfortable using JavaScript, the XDK might be a good option. The Arduino IDE is a good option as well because there are many examples that you could use and adapt for your Galileo projects. If you choose the Arduino IDE, I recommend you to use the version 1.6.0 which can be downloaded from the following link: http://downloadmirror.intel.com/24783/eng/IntelArduino-1.6.0-Windows.7z

           

          Regards,

          Diego.

          • 2. Re: Galileo: connect galileo with router
            runlei

            Hi Diego,

             

            Thanks for your reply. For the first part, I have figures it out, connecting successfully galileo with router without network. Now, I want to assign a static Ip address for my galileo. it didn't work,  I am using connman command as follows:

            connmanctl>config <service> -ipv4 manual <ip address> <netmask><gateway>

            and the serial return : error " wifi_0cd292d2c3c_61703334_managed_psk" : invalied argument.

            except this,everything is fine. when I check the connection using 'ifconfig', I can get an ip address...

             

            do you know what's the problem? Thanks very much.

             

            about the IDE, thanks for you suggestion, I will focus on it next part.

             

            Regards,

            Runlei.

            • 3. Re: Galileo: connect galileo with router
              DiegoV_Intel

              Hello runlei,

               

              I've just configured a static IP address using connman. I followed this guide: Configuring a static IP address. It's for Edison, but it works on Galileo too. Try with it to see if you are able to set the static IP address.

               

              Regards,

              Diego.

              • 4. Re: Galileo: connect galileo with router
                runlei

                Hi Diego,

                 

                I figure it out. thanks you.

                 

                now i am using arduino IDE to create a web server to monitor temperature using Grove temperature sensor and control relay. The final purpose of this project is to control galileo through wifi with IOS interface. (IOS app). do I need to learn about how to prgramm IOS? I did research and foud that there are so  many arduino project rather than galileo. do you have any guide for my project ? I don't have any idea for this part. Thanks again.

                 

                Regards,

                Runlei

                • 5. Re: Galileo: connect galileo with router
                  DiegoV_Intel

                  Hi runlei,

                   

                  There aren't guides for Galileo specifically; however the Arduino projects you found are useful. You can use them as a guide and try to port them to be used with Galileo. The Arduino IDE has some examples for webserver applications; I believe you will find them useful. The WebServer example might help you with the sensor part. You can check this example in File>Examples>WiFi>WiFiWebServer.

                   

                  Regarding the app side, you will have to learn how to program IOS apps. I haven't done IOS apps before so I can't suggest anything about it, but I believe there are several projects like this one in the web.

                   

                  On the other hand, in case you want to make an Android app instead, I recommend you to check the following site: Android Developers. Android offers guides and tutorials for those who want to learn about programming Android apps. Another tool you find interesting is App Inventor (for Android apps): MIT App Inventor | Explore MIT App Inventor. This tool allows you to create apps in an easier way.

                   

                  I hope this information helps you.

                   

                  Regards,

                  Diego

                  • 6. Re: Galileo: connect galileo with router
                    runlei

                    Hi Diego,

                     

                    I am using the example with Arduino, when I type IP adrdress URL, it just display "it works" I though it is ok.

                    but when I changed my code to run my own project, it still display "it works" ,which should be my a relay control. and when I open the serial using PuTTY, it diaplays as follows:

                     

                    [22712.665157]ttyGS0: RX not sceduled?

                    .....

                    ....

                    ....

                     

                     

                    do you konw what's the problem?

                     

                    Thanks,

                    Runlei

                    • 7. Re: Galileo: connect galileo with router
                      DiegoV_Intel

                      Hi runlei,

                       

                      What example did you use? Could you attach the sketch of your project to check if I get the same result?

                       

                      Regards,

                      Diego.

                      • 8. Re: Galileo: connect galileo with router
                        runlei

                        Hi Diego,

                        my code is as follows:(I changed the example from File->Example->Ethernet->webserver)

                        what's more,I am using the iot-dev image with SD card. and firmware is the newest version.

                         

                         

                         

                         

                        /*

                          Web Server

                         

                        A simple web server that shows the value of the analog input pins.

                        using an Arduino Wiznet Ethernet shield.

                         

                        Circuit:

                        * Ethernet shield attached to pins 10, 11, 12, 13

                        * Analog inputs attached to pins A0 through A5 (optional)

                         

                        created 18 Dec 2009

                        by David A. Mellis

                        modified 9 Apr 2012

                        by Tom Igoe

                         

                        */

                         

                        #include <SPI.h>

                        #include <Ethernet.h>

                         

                        // Enter a MAC address and IP address for your controller below.

                        // The IP address will be dependent on your local network:

                        byte mac[] = {

                          0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

                        IPAddress ip(192,168,1,10);

                         

                        // Initialize the Ethernet server library

                        // with the IP address and port you want to use

                        // (port 80 is default for HTTP):

                        EthernetServer server(80);

                         

                        //const int pinTemp = A0;

                         

                        void setup() {

                          // Open serial communications and wait for port to open:

                          Serial.begin(9600);

                           while (!Serial) {

                            ; // wait for serial port to connect. Needed for Leonardo only

                          }

                         

                         

                          // start the Ethernet connection and the server:

                          Ethernet.begin(mac, ip);

                          server.begin();

                          Serial.print("server is at ");

                          Serial.println(Ethernet.localIP());

                        } // end setup

                         

                         

                        void loop() {

                          // listen for incoming clients

                          EthernetClient client = server.available();

                          if (client) {

                            Serial.println("new client");

                            // an http request ends with a blank line

                            boolean currentLineIsBlank = true;

                            while (client.connected()) {

                              if (client.available()) {

                                char c = client.read();

                                Serial.write(c);

                                // if you've gotten to the end of the line (received a newline

                                // character) and the line is blank, the http request has ended,

                                // so you can send a reply

                                if (c == '\n' && currentLineIsBlank) {

                                  // send a standard http response header

                                  client.println("HTTP/1.1 200 OK");

                                  client.println("Content-Type: text/html");

                                  client.println("Connection: close");

                                  client.println();

                                  client.println("<!DOCTYPE HTML>");

                                  client.println("<html>");

                                  // add a meta refresh tag, so the browser pulls again every 5 seconds:

                                  client.println("<meta http-equiv=\"refresh\" content=\"5\">");

                                  // output the value of each analog input pin

                                  for (int analogChannel = 0; analogChannel < 6; analogChannel++) {

                                    int sensorReading = analogRead(analogChannel);

                                    client.print("analog input ");

                                    client.print(analogChannel);

                                    client.print(" is ");

                                    client.print(sensorReading);

                                    client.println("<br />");

                             

                             

                             

                             

                              //get sensors reading,cauculate and print results.

                                  int val = analogRead(pinTemp);

                                  serial.print("read sensor: ");

                                  swithch (val)

                                  {

                                    case 0:

                                       serial.println("OK");

                                       break;

                                    case -1:

                                       serial.println("Checksum error");

                                       break;

                                    case -2;

                                       serial.println("Time out error");

                                        break;

                                    default:

                                         serial.println("unknown error");

                                         break;

                                  }

                                 

                                  client.print("Temperature (C): ");

                                  client.println((float) Grove.tempeture, 1);

                                  client.println("<br />");

                                 

                                  // end sensor read.

                                  

                                  }

                                  client.println("</html>");

                                  break;

                                }

                                if (c == '\n') {

                                  // you're starting a new line

                                  currentLineIsBlank = true;

                                }

                                else if (c != '\r') {

                                  // you've gotten a character on the current line

                                  currentLineIsBlank = false;

                                }

                              }

                            }

                            // give the web browser time to receive the data

                            delay(1);

                            // close the connection:

                            client.stop();

                            Serial.println("client disonnected");

                          }

                        }

                         

                         

                        Thanks

                        Runlei

                        • 9. Re: Galileo: connect galileo with router
                          DiegoV_Intel

                          Hello runlei,

                           

                          I recommend you to use the standard Yocto image instead of the IoT image. You can download it from the following link: http://downloadmirror.intel.com/24355/eng/SDCard.1.0.4.tar.bz2

                           

                          I'll check your code and run it to see what the output is.

                           

                          Regards,

                          Diego.

                          • 10. Re: Galileo: connect galileo with router
                            runlei

                            Hi Diego,

                            Sorry, I copied a wrong code. it should be :

                             

                            /*

                              Web Server

                             

                            A simple web server that shows the value of the analog input pins.

                            using an Arduino Wiznet Ethernet shield.

                             

                            Circuit:

                            * Ethernet shield attached to pins 10, 11, 12, 13

                            * Analog inputs attached to pins A0 through A5 (optional)

                             

                            created 18 Dec 2009

                            by David A. Mellis

                            modified 9 Apr 2012

                            by Tom Igoe

                             

                            */

                             

                            #include <SPI.h>

                            #include <Ethernet.h>

                            #include  <Servo.h>

                            // Enter a MAC address and IP address for your controller below.

                            // The IP address will be dependent on your local network:

                             

                            const int relayPin = 8;

                            //Servo microservo;

                            //int pos = 0;

                            byte mac[] = {

                              0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

                            IPAddress ip(192,168,1,10);

                             

                            // Initialize the Ethernet server library

                            // with the IP address and port you want to use

                            // (port 80 is default for HTTP):

                            EthernetServer server(80);

                            String readString;

                            void setup() {

                              // Open serial communications and wait for port to open:

                              Serial.begin(9600);

                               while (!Serial) {

                                ; // wait for serial port to connect. Needed for Leonardo only

                              }

                             

                             

                              // start the Ethernet connection and the server:

                              Ethernet.begin(mac, ip);

                              server.begin();

                              Serial.print("server is at ");

                              Serial.println(Ethernet.localIP());

                            }

                             

                             

                            void loop() {

                              // listen for incoming clients

                              EthernetClient client = server.available();

                              if (client) {

                                Serial.println("new client");

                                // an http request ends with a blank line

                                boolean currentLineIsBlank = true;

                                while (client.connected()) {

                                  if (client.available()) {

                                    char c = client.read();

                                   if(readString.length()<100){

                                     readString += c;

                                    Serial.write(c);

                                    // if you've gotten to the end of the line (received a newline

                                    // character) and the line is blank, the http request has ended,

                                    // so you can send a reply

                                    if (c == '\n' && currentLineIsBlank) {

                                      // send a standard http response header

                                      client.println(readString);

                                      client.println("HTTP/1.1 200 OK");

                                      client.println("Content-Type: text/html");

                                      client.println();

                                      //client.println("Connection: close");

                                      //client.println();

                                      //client.println("<!DOCTYPE HTML>");

                                      client.println("<HTML>");

                                      client.println("<HEAD>");

                                      // add a meta refresh tag, so the browser pulls again every 5 seconds:

                                      //client.println("<meta http-equiv=\"refresh\" content=\"5\">");

                                     

                                      client.println("<meta name='apple-mobile-web-app-capable' content='yes' />");

                                      client.println("<meta name='apple-mobile-web-app-status-bar-style' content='black-transluent.css' />");

                                      client.println("<link rel='stysheet' type='text/css' href='http://Galileoproject.com/wificss.css' /'>");

                                      client.println("<TITLE>Galileo Automation homeheating webserver</TITLE>");

                                      client.println("</HEAD>");

                                      client.println("</BODY>");

                                      client.println("<H1>Galileo Automation homeheating webserver</H1>");

                                      client.println("<hr />");

                                      client.println("<hr />");

                                      client.println("<H2>Galileo with Grove_relay</H2>");

                                      client.println("<br />");

                                      client.println("<a href=\"/?buttonlon\"\">Turn On Relay</a>");

                                      client.println("a href=\"/?buttonloff\"\">Turn Off Relay</a><br />");

                                      client.println("<br />");

                                      client.println("<BODY>");

                                      client.println("<HTML>");

                                     

                                      delay(1);

                                      client.stop();

                                     

                                      if (readString.indexOf("?buttonon") >0)

                                      {

                                        digitalWrite(relayPin,HIGH);

                                      }

                                      if(readString.indexOf("?buttonoff")>0)

                                      {

                                        digitalWrite(relayPin,LOW);

                                      }

                                     

                                      readString="";

                                     

                                      // output the value of each analog input pin

                                     // for (int analogChannel = 0; analogChannel < 6; analogChannel++) {

                                     //   int sensorReading = analogRead(analogChannel);

                                     //   client.print("analog input ");

                                     //   client.print(analogChannel);

                                    //    client.print(" is ");

                                      //  client.print(sensorReading);

                                     //   client.println("<br />");      

                                      }

                                    //  client.println("</html>");

                                     // break;

                                    }

                                   // if (c == '\n') {

                                      // you're starting a new line

                                    //  currentLineIsBlank = true;

                                   // }

                                    //else if (c != '\r') {

                                      // you've gotten a character on the current line

                                      //currentLineIsBlank = false;

                                   // }

                                  }

                                }

                                // give the web browser time to receive the data

                                //delay(1);

                                // close the connection:

                               // client.stop();

                                //Serial.println("client disonnected");

                              }

                            }

                             

                             

                            Thanks,

                            Rnlei

                            • 11. Re: Galileo: connect galileo with router
                              DiegoV_Intel

                              Hi runlei,

                               

                              I've uploaded the WebServer example and it worked fine. Below is the output you should get in your browser:

                              test1.JPG

                              Then I uploaded your code (the second one you posted) and I got the following output when I accessed the IP address in the browser:

                              test2customSketch.JPG

                              The connection is ok because there is response when we access the IP address; however there are some details that you should check in your sketch. For example the HTML part. The connection is made but the web page doesn't load because the HTML lines are not correct. I recommend you to double check the modifications you did from the original WebServer example.

                               

                              Also, I recommend you to use the standard Yocto image instead of the IoT image: http://downloadmirror.intel.com/24355/eng/SDCard.1.0.4.tar.bz2

                               

                              Regards,

                              Diego.

                              • 12. Re: Galileo: connect galileo with router
                                runlei

                                Hi Diego,

                                 

                                with the right standard SD card image and the newest firmware and Arduino 1.6.0.version. now the webpage can show something like yours. but I still get the wrong message in serial :

                                             [4404.245515] ttyGS0: RX not scheduled?

                                              ........

                                             .........

                                 

                                I am so confused... Did  I lost something important?

                                 

                                Thanks

                                Runlei

                                • 13. Re: Galileo: connect galileo with router
                                  DiegoV_Intel

                                  Hi runlei,

                                   

                                  Could you post the entire log of the Galileo's terminal (or a screenshot)?

                                   

                                  Also, did you try the WebServer example or the code of your project? Please take a screenshot of the output you got.

                                   

                                  Regards,

                                  Diego.

                                  • 14. Re: Galileo: connect galileo with router
                                    runlei

                                    Hi Diego,

                                    Sorry for replying later.

                                    QQ图片20160114212724.jpg

                                       

                                    Thanks,

                                    Runlei

                                    1 2 Previous Next