13 Replies Latest reply on Mar 13, 2016 3:22 PM by biol75

    Can the Arduino code start Edison Wifi in access point mode?

    biol75

      Hi, and I'm using the Arduino IDE with and Arduino-compatible board.

       

      I can start the Edison wifi and log it into a WPA network like this:

       

          // Connect to WPA/WPA2 network. Change this line if using open or WEP network:

          status = WiFi.begin(ssid, pass);

       

      But what i really wanted to do was to start it as a hotspot or access point; i was looking for something like the ESP8266 code:

      WiFi.mode(WIFI_AP);

      WiFi.softAP(AP_NameChar, WiFiAPPSK);

       

      chris

        • 1. Re: Can the Arduino code start Edison Wifi in access point mode?
          Intel_Peter

          Hello bio75,

           

          You can use the command system to do so, it'll look like this:

           

          system("configure_edison --toggleOneTimeSetup");
          

           

          The Edison should enter AP mode in around 10 seconds after that. Let me know if it helps.

           

          Peter.

          • 2. Re: Can the Arduino code start Edison Wifi in access point mode?
            biol75

            Hi, and thanks for getting back to me. But implementing your suggestion resulted in no sign of a wireless network. Heres my setup procedure

             

            void setup() {

              Serial.begin(115200);      // initialize serial communication

             

              // check for the presence of the shield:

              if (WiFi.status() == WL_NO_SHIELD) {

                Serial.println("WiFi shield not present");

                while(true);        // don't continue

              }

             

              // attempt to connect to Wifi network:

              Serial.println(system("configure_edison --toggleOneTimeSetup"));

              while ( status != WL_CONNECTED) {

                Serial.print("Attempting to connect to Network named: ");

                Serial.println(ssid);                   // print the network name (SSID);

             

             

                // Connect to WPA/WPA2 network. Change this line if using open or WEP network:   

                status = WiFi.begin(ssid, pass);

                // wait 10 seconds for connection:

                delay(10000);

              }

              server.begin();                           // start the web server on port 80

             

            I got a zero returned from the system call, so presume the command executed ok. But I found no sign of a wifi network, and the status loop just went round and round, never connecting.

            chris

            • 3. Re: Can the Arduino code start Edison Wifi in access point mode?
              Intel_Peter

              The reason why it didn't work is because you clustered the system("configure_edison --toggleOneTimeSetup") command within a Serial.println(). This is the sketch I used to enable AP mode on my Edison. Note that I changed --toggleOneTimeSetup for --enableOneTimeSetup, this is because this command works better for your project:

               

              void setup() {
                delay(5000);
                system("configure_edison --enableOneTimeSetup");
                Serial.begin(9600);
                Serial.println("AP mode should be on now");
                delay(10000);
              }
              
              void loop() {
                Serial.println("check ap mode");
                system("ifconfig wlan0 > /dev/ttyGS0");
                delay(1000);
              }
              

               

              This effectively activated Edison's AP mode. Let me know if it helps.

               

              Peter.

              • 4. Re: Can the Arduino code start Edison Wifi in access point mode?
                biol75

                Hi, I have modified the Arduino/Edison/SimpleWebServer.ino code,

                 

                void setup() {

                  delay(5000);

                  system("configure_edison --enableOneTimeSetup");

                  delay (10000);

                  Serial.begin(115200);      // initialize serial communication

                 

                 

                  // attempt to connect to Wifi network:

                 

                 

                  while ( status != WL_CONNECTED) {

                    Serial.print("Attempting to connect to Network named: ");

                    Serial.println(ssid);                   // print the network name (SSID);

                 

                 

                    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:

                    status = WiFi.begin(ssid, pass);

                    // wait 10 seconds for connection:

                    delay(10000);

                    system("ifconfig wlan0 > /dev/ttyGS0");

                  }

                 

                  server.begin();                           // start the web server on port 80

                  printWifiStatus();                        // you're connected now, so print out the status

                }

                 

                but don't see a network with my phone or computer, and get this output:

                 

                Attempting to connect to Network named: yourNetwork

                wlan0     Link encap:Ethernet  HWaddr 78:4b:87:a9:22:70 

                          BROADCAST MULTICAST  MTU:1500  Metric:1

                          RX packets:15557 errors:0 dropped:0 overruns:0 frame:0

                          TX packets:1485 errors:0 dropped:0 overruns:0 carrier:0

                          collisions:0 txqueuelen:1000

                          RX bytes:2875991 (2.7 MiB)  TX bytes:209760 (204.8 KiB)

                 

                Not sure the AP is running

                chris

                • 5. Re: Can the Arduino code start Edison Wifi in access point mode?
                  Intel_Peter

                  I believe what's happening is that you are setting up the AP mode on the command: system("configure_edison --enableOneTimeSetup"); but then you try to connect to a regular network (let's say your router) with the command: status = WiFi.begin(ssid, pass);.

                  Why don't you try the sketch I posted above just to check if your Edison is able to set AP mode and if it does, let me know more about what you are trying to achieve, so I can provide you a more accurate response.

                   

                  Peter.

                  • 6. Re: Can the Arduino code start Edison Wifi in access point mode?
                    biol75

                    Thanks, I will try this when i get home tonight.

                     

                    We are building apparatus to measure the way flies engineered to have Parkinson's "disease" can see, so we have hooked up Arduinos to LEDs and an amplifier to collect data from flies, and it works fine, except quite slowly (https://github.com/wadelab/flyCode/tree/master/collectData/fly_arduino/WebServer). At present we use Arduinos with an Ethernet shield, and have to obtain permission from the University Admins to have them on the Ethernet. The data acquisition parameters for stimulation and recording are set up on a PC on the Ethernet using a web browser.

                     

                    We would really like to be able to take the equipment wherever we want, and use it in a range of different labs, and not depend on their Ethernet. I am also visualising running a lab of 30 such devices, without having to run Ethernet cable everywhere. Doing this over wifi seems a good start.

                     

                    Our Wifi is even more tightly controlled, so we can't log in to an existing Wifi network. At home, I can run the code with my own wifi network, with the Edison as a client - but not at work. So what I wanted to explore was to start the Edison in Access Point Wifi, and then use this Wifi to serve web pages,  reusing the existing Arduino data acquisition I/O. I think my goal is to start the Access point  with a SSID and password in  the 'setup' procedure and that it would host the web server.

                     

                    Hope this explanation helps

                    chris

                    PS I didn't really want to rewrite the code for Linux on the Edison

                    • 7. Re: Can the Arduino code start Edison Wifi in access point mode?
                      biol75

                      I copied this into a new sketch and got this:

                       

                       

                      check ap mode

                      wlan0     Link encap:Ethernet  HWaddr 78:4b:87:a9:22:70 

                                inet6 addr: fe80::7a4b:87ff:fea9:2270/64 Scope:Link

                                UP BROADCAST MULTICAST  MTU:1500  Metric:1

                                RX packets:15557 errors:0 dropped:0 overruns:0 frame:0

                                TX packets:4691 errors:0 dropped:0 overruns:0 carrier:0

                                collisions:0 txqueuelen:1000

                                RX bytes:2875991 (2.7 MiB)  TX bytes:810887 (791.8 KiB)

                       

                      But no sign of a network on my phone/pc

                      chris

                      • 8. Re: Can the Arduino code start Edison Wifi in access point mode?
                        biol75

                        Well actually, I find it disappointing that an Edison bought in the last month is not up to date. Flashing it made Peter's sketch work. Thanks,

                         

                        Now I need to make the web server on the access point work for its living. First it asks for a password :-( How is this supplied in Peter's sketch ?

                         

                        chris

                        • 9. Re: Can the Arduino code start Edison Wifi in access point mode?
                          Intel_Peter

                          I'm glad to hear that you are now able to see the AP mode working. If you haven't set a password on Edison, then the AP mode's password by default is the board's serial number. If you have changed the Edison’s password, then in that case that's the AP mode's password.

                          Could you please explain to me what you mean by: "...Now I need to make the web server on the access point work for its living..."? I don't understand what you are trying to achieve.

                           

                          Peter.

                          • 10. Re: Can the Arduino code start Edison Wifi in access point mode?
                            biol75

                            Hi, and having updated the firmware by flashing, i seem to have run into a further problem.

                             

                            When i run the simplewebserver sketch, on my home network, only changing it to include my network name and password, it now shows me an Edison device information page, instead of the previous output derived from the following code:

                             

                                      // the content of the HTTP response follows the header:

                                        client.print("Click <a href=\"/H\">here</a> turn the LED on pin 9 on<br>");

                                        client.print("Click <a href=\"/L\">here</a> turn the LED on pin 9 off<br>");

                             

                            chris

                            • 11. Re: Can the Arduino code start Edison Wifi in access point mode?
                              Intel_Peter

                              That's the Edison's "web interface" that's used to set it up from AP mode. You can disable it by editing the file called edison-config-server.js that can be found in /usr/lib/edison_config_tools/. Just comment out the last line, that should disable it. Let me know if after doing this you are able to see the output you expected.

                               

                              Peter.

                              • 12. Re: Can the Arduino code start Edison Wifi in access point mode?
                                CMata_Intel

                                Hi Chris,

                                 

                                Regarding your last question, did you try by disabling the web interface of the Edison as Peter suggested?

                                 

                                Regards,

                                Charlie

                                • 13. Re: Can the Arduino code start Edison Wifi in access point mode?
                                  biol75

                                  Thanks - that worked, but I had to learn a bit of vi to edit the file (no emacs by default?) and to learn how to get out of a boot> prompt.

                                   

                                  will do some more testing...

                                  chris