Announcement

Collapse
No announcement yet.

4Duino WiFi Issues - Using "Getting Started with WiFi" Sketch

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 4Duino WiFi Issues - Using "Getting Started with WiFi" Sketch

    I've followed all of the directions on the http://www.4duino.com/getting-started-with-wi-fi/ example.

    The sketch compiles and uploads onto the 4duino. However, the readout I get on the screen is:

    Setup Begin...
    FW Version :
    to station error
    Join AP failure
    setup end
    What I am deriving from this is that clearly, this thing is failing out early. At least at about line 107:

    Code:
    Display.print("FW Version: ");
    Display.println(wifi.getVersion().c_str());
    getVersion() isn't even returning anything.

    I'm wondering if the wifi object is even instantiating here:

    Code:
    // Uncomment next 2 lines to use ESP8266 with ESP8266 library from https://github.com/itead/ITEADLIB_Arduino_WeeESP8266
    #include "ESP8266.h"
    ESP8266 wifi(SerialS,19200);
    Has anyone had similar issues or have any suggestions about how I might be sure that object is even there?


  • #2
    OK, so I used one of the example sketches from the library itself. Set it down to 9600 baud. Still same response out of serial. I uncommented out the necessary line in ESP8266.h to use SoftwareSerial. Here is my code:

    Code:
    #include "ESP8266.h"
    
    #define SSID        "(my SSID)"
    #define PASSWORD    "(my PASSWORD)"
    
    // Uncomment to use ESP8266
    #define ESPRESET 17
    #include <SoftwareSerial.h>
    #define ESPserial SerialS
    SoftwareSerial SerialS(8, 9) ;
    
    ESP8266 wifi(SerialS,9600);
    
    void setup(void)
    {
        delay(5000);
        Serial.begin(9600);
        Serial.print("setup begin\r\n");
    
        Serial.print("FW Version: ");
        Serial.println(wifi.getVersion().c_str());
    
    
        if (wifi.setOprToStation()) {
            Serial.print("to station ok\r\n");
        } else {
            Serial.print("to station err\r\n");
        }
    
        if (wifi.joinAP(SSID, PASSWORD)) {
            Serial.print("Join AP success\r\n");
            Serial.print("IP: ");       
            Serial.println(wifi.getLocalIP().c_str());
        } else {
            Serial.print("Join AP failure\r\n");
        }
    
        Serial.print("setup end\r\n");
    }
    
    void loop(void)
    {
    }
    In my serial monitor, I still get:

    setup begin
    FW Version:
    to station err
    Join AP failure
    setup end

    Comment


    • #3
      OK, some movement. SerialS has to be started in setup(). Here is my new code:

      Code:
      #include "ESP8266.h"
      
      #define SSID        "(my SSID)"
      #define PASSWORD    "(my PASSWORD)"
      
      // Uncomment to use ESP8266
      //#define ESPRESET 17
      #include <SoftwareSerial.h>
      //#define ESPserial SerialS
      SoftwareSerial SerialS(8, 9) ;
      
      ESP8266 wifi(SerialS,115200);
      
      void setup(void)
      {
          delay(5000);
          Serial.begin(9600);
          SerialS.begin(115200);
          Serial.print("setup begin\r\n");
      
          Serial.print("FW Version: ");
          Serial.println(wifi.getVersion().c_str());
      
      
          if (wifi.setOprToStation()) {
              Serial.print("to station ok\r\n");
          } else {
              Serial.print("to station err\r\n");
          }
      
          if (wifi.joinAP(SSID, PASSWORD)) {
              Serial.print("Join AP success\r\n");
              Serial.print("IP: ");      
              Serial.println(wifi.getLocalIP().c_str());
          } else {
              Serial.print("Join AP failure\r\n");
          }
      
          Serial.print("setup end\r\n");
      }
      
      void loop(void)
      {
      }
      This returns:

      setup begin
      FW Version:
      to station err
      Join AP success
      IP:
      setup end
      Which is super confusing. It can't give the version. It can't change its mode. supposedly it CAN connect to the access point. But, it can't get its local ip address

      Anyone have any thoughts?

      Comment


      • #4
        Please try this:

        Code:
        #define SSID        "WifiSSID"       // add your SSID here
        #define PASSWORD    "WifiPassword"       // add your router password here
        
        %%Display%%.DefineResetLine ;      // *Replaced* at compile time with define for reset line connected to the display
        %%Display%%.DefineDisplaySerialx ; // *Replaced* at compile time with define the Serial Port connected to the display
        %%Display%%.IncludeSerial_4DLib ;          // *Replaced* at compile time with an Include the Serial Library relevant to the display
        %%Display%%.IncludeSerial_Const4D ;        // *Replaced* at compile time with an Include the Constants file relevant to the display
        %%Display%%.AssignDisplaySerialtoLibrary ; // *Replaced* at compile time with an Assign of the correct Serial port to the correct library
        
        #define ESPRESET 17
        #include <SoftwareSerial.h>
        #define ESPserial SerialS
        SoftwareSerial SerialS(8, 9) ;
        #include "ESP8266.h"
        ESP8266 wifi(SerialS,19200);
        
        
        void setup() {
          Serial.begin(115200);        // serial to USB port
          //while (!Serial && millis() < 2000); // wait for serial to be established
          pinMode(RESETLINE, OUTPUT);       // Display reset pin
          %%Display%%.Toggle_Reset_On ;
          delay(100);
          %%Display%%.Toggle_Reset_Off ; // Display reset pin
          pinMode(ESPRESET, OUTPUT); digitalWrite(ESPRESET, 1); delay(100); digitalWrite(ESPRESET, 0); // ESP reset pin
          delay(3000); // wait to stabilize
        
          %%Display%%.DisplaySerial.Begin_Speed ; // *Replaced* at compile time with command to start the serial port at the correct speed
          Display.TimeLimit4D = 5000 ;      // 5 second timeout on all commands
          Display.Callback4D = mycallback ;
        
          ESPserial.begin(115200) ;
          ESPserial.println("AT+UART_CUR=19200,8,1,0,0\r\n") ;     // request to change the current baud to 19200
          ESPserial.end() ;
          delay(10) ;                         // Necessary to allow for baud rate changes
          ESPserial.begin(19200) ;            // start again at a resonable baud rate
          Display.gfx_ScreenMode(LANDSCAPE) ; // change manually if orientation change
          if (wifi.setOprToStationSoftAP()) Display.print("to station + softap ok\r\n");
          else Display.print("to station + softap err\r\n");
          Display.println("");
        
          if (wifi.joinAP(SSID, PASSWORD)) {
            Display.print("Connected to "); Display.print(SSID); Display.print(" success\r\n"); Display.println(""); Display.print("IP: "); Display.println(wifi.getLocalIP().c_str());
          }
          else Display.print("Join AP failure\r\n");
          Display.print("setup end\r\n");
        
          if (wifi.disableMUX()) Display.print("single ok\r\n");
          else Display.print("single err\r\n");
        }
        
        int value = 0;
        const char* host = "wifitest.adafruit.com";
        
        void loop() {
        
        }
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        // routine to handle Serial errors
        void mycallback(int ErrCode, unsigned char Errorbyte)
        {
        #ifdef LOG_MESSAGES
          const char *Error4DText[] = {"OK\0", "Timeout\0", "NAK\0", "Length\0", "Invalid\0"} ;
          LOG_MESSAGES.print(F("Serial 4D Library reports error ")) ;
          LOG_MESSAGES.print(Error4DText[ErrCode]) ;
          if (ErrCode == Err4D_NAK)
          {
            LOG_MESSAGES.print(F(" returned data= ")) ;
            LOG_MESSAGES.println(Errorbyte) ;
          }
          else
            LOG_MESSAGES.println(F("")) ;
          while (1) ; // you can return here, or you can loop
        #else
          // Pin 13 has an LED connected on most Arduino boards. Just give it a name
        #define led 13
          while (1)
          {
            digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
            delay(200);                // wait for a second
            digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
            delay(200);                // wait for a second
          }
        #endif
        }
        // end of routine to handle Serial errors
        Tony

        Comment


        • #5
          Hi Tony.

          That wouldn't even compile

          Arduino: 1.8.1 (Windows 7), Board: "4Duino - 2.4""

          Time_stamp:4: error: expected unqualified-id before '%' token

          %%Display%%.DefineResetLine ; // *Replaced* at compile time with define for reset line connected to the display

          ^

          Time_stamp:5: error: expected unqualified-id before '%' token

          %%Display%%.DefineDisplaySerialx ; // *Replaced* at compile time with define the Serial Port connected to the display

          ^

          Time_stamp:6: error: expected unqualified-id before '%' token

          %%Display%%.IncludeSerial_4DLib ; // *Replaced* at compile time with an Include the Serial Library relevant to the display

          ^

          Time_stamp:7: error: expected unqualified-id before '%' token

          %%Display%%.IncludeSerial_Const4D ; // *Replaced* at compile time with an Include the Constants file relevant to the display

          ^

          Time_stamp:8: error: expected unqualified-id before '%' token

          %%Display%%.AssignDisplaySerialtoLibrary ; // *Replaced* at compile time with an Assign of the correct Serial port to the correct library

          ^

          C:\Users\Ameno\Documents\Arduino\Time_stamp\Time_stamp.ino: In function 'void setup()':

          Time_stamp:21: error: 'RESETLINE' was not declared in this scope

          pinMode(RESETLINE, OUTPUT); // Display reset pin

          ^

          Time_stamp:22: error: expected primary-expression before '%' token

          %%Display%%.Toggle_Reset_On ;

          ^

          Time_stamp:22: error: expected primary-expression before '%' token

          %%Display%%.Toggle_Reset_On ;

          ^

          Time_stamp:22: error: 'Display' was not declared in this scope

          %%Display%%.Toggle_Reset_On ;

          ^

          Time_stamp:22: error: expected primary-expression before '%' token

          %%Display%%.Toggle_Reset_On ;

          ^

          Time_stamp:22: error: expected primary-expression before '.' token

          %%Display%%.Toggle_Reset_On ;

          ^

          Time_stamp:24: error: expected primary-expression before '%' token

          %%Display%%.Toggle_Reset_Off ; // Display reset pin

          ^

          Time_stamp:24: error: expected primary-expression before '%' token

          %%Display%%.Toggle_Reset_Off ; // Display reset pin

          ^

          Time_stamp:24: error: expected primary-expression before '%' token

          %%Display%%.Toggle_Reset_Off ; // Display reset pin

          ^

          Time_stamp:24: error: expected primary-expression before '.' token

          %%Display%%.Toggle_Reset_Off ; // Display reset pin

          ^

          Time_stamp:28: error: expected primary-expression before '%' token

          %%Display%%.DisplaySerial.Begin_Speed ; // *Replaced* at compile time with command to start the serial port at the correct speed

          ^

          Time_stamp:28: error: expected primary-expression before '%' token

          %%Display%%.DisplaySerial.Begin_Speed ; // *Replaced* at compile time with command to start the serial port at the correct speed

          ^

          Time_stamp:28: error: expected primary-expression before '%' token

          %%Display%%.DisplaySerial.Begin_Speed ; // *Replaced* at compile time with command to start the serial port at the correct speed

          ^

          Time_stamp:28: error: expected primary-expression before '.' token

          %%Display%%.DisplaySerial.Begin_Speed ; // *Replaced* at compile time with command to start the serial port at the correct speed

          ^

          Time_stamp:30: error: 'mycallback' was not declared in this scope

          Display.Callback4D = mycallback ;

          ^

          Time_stamp:37: error: 'LANDSCAPE' was not declared in this scope

          Display.gfx_ScreenMode(LANDSCAPE) ; // change manually if orientation change

          ^

          exit status 1
          expected unqualified-id before '%' token

          Weirdly enough, while the Getting Started sketch at http://www.4duino.com/getting-started-with-wi-fi/ didn't work, the Time Stamp project at http://www.4duino.com/time-stamp-from-web-server/ works perfectly. I probably won't go back through to try to find the difference. At first glance they appear nearly identical. Very weird.

          Comment


          • #6
            This is for the workshop IDE, if you want the arduino ino you should compile it first in workshop IDE for 4duino, then in the directory you saved your project in you will have the ino file for your arduino.

            it compiles and works fine for me. I use the workshop ide to upload it to arduino. workshop creates a standard arduino ino after compile with the %% variables replaced with proper data.
            Tony

            Comment


            • #7
              here is the arduino ino file:
              Attached Files

              Comment


              • #8
                Hi ameno,

                In Getting_Started_WIFI example, try uncommenting the lines from 92 to 95 if they are still commented.
                Code:
                //ESPserial.println("AT+UART_CUR=19200,8,1,0,0\r\n") ;     // request to change the current baud to 19200
                 ESPserial.end() ;
                 delay(10) ;                         // Necessary to allow for baud rate changes
                 ESPserial.begin(19200) ;            // start again at a resonable baud rate
                You can also try the same project w/ the examples included in the WS4 IDE. (Arduino code can also be found on the same folder)

                'File' - 'Samples' - '4Duino' - 'Basic Graphics' - ConnectWIFI

                Hope this helps,

                Comment

                Working...
                X