Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WiFiCLient example does not work - Pico EVB #8

Open
mhanuel26 opened this issue Oct 25, 2022 · 1 comment
Open

WiFiCLient example does not work - Pico EVB #8

mhanuel26 opened this issue Oct 25, 2022 · 1 comment

Comments

@mhanuel26
Copy link

Hi @GiungKim ,

It looks the WizFI360-Pico-EVB has problems to run the WiFiCLient basic example.

Basically the code is hanging when the client is defined , if I comment the client code like this

/*
 WizFi360 example: WebClient

 This sketch connects to google website using a WizFi360 module to
 perform a simple web search.
*/

#include "WizFi360.h"

// setup according to the device you use
#define WIZFI360_EVB_PICO

// Emulate Serial1 on pins 6/7 if not present
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
#if defined(ARDUINO_MEGA_2560)
SoftwareSerial Serial1(6, 7); // RX, TX
#elif defined(WIZFI360_EVB_PICO)
SoftwareSerial Serial2(6, 7); // RX, TX
#endif
#endif

/* Baudrate */
#define SERIAL_BAUDRATE   115200
#if defined(ARDUINO_MEGA_2560)
#define SERIAL1_BAUDRATE  115200
#elif defined(WIZFI360_EVB_PICO)
#define SERIAL2_BAUDRATE  115200
#endif

/* Wi-Fi info */
char ssid[] = "TraceAP";       // your network SSID (name)
char pass[] = "Liberty123";   // your network password

int status = WL_IDLE_STATUS;  // the Wifi radio's status

// char server[] = "arduino.tips";

// Initialize the Ethernet client object
// WiFiClient client;

void setup() {
  // initialize serial for debugging
  Serial.begin(SERIAL_BAUDRATE);
  // initialize serial for WizFi360 module
#if defined(ARDUINO_MEGA_2560)
  Serial1.begin(SERIAL1_BAUDRATE);
#elif defined(WIZFI360_EVB_PICO)
  Serial2.begin(SERIAL2_BAUDRATE);
#endif
  // initialize WizFi360 module
#if defined(ARDUINO_MEGA_2560)
  WiFi.init(&Serial1);
#elif defined(WIZFI360_EVB_PICO)
  WiFi.init(&Serial2);
#endif

  // check for the presence of the shield
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue
    while (true);
  }

  // attempt to connect to WiFi network
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to WPA SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network
    status = WiFi.begin(ssid, pass);
  }

  // you're connected now, so print out the data
  Serial.println("You're connected to the network");
  
  // printWifiStatus();
  printWifiData();

  // Serial.println();
  // Serial.println("Starting connection to server...");
  // // if you get a connection, report back via serial
  // if (client.connect(server, 80)) {
  //   Serial.println("Connected to server");
  //   // Make a HTTP request
  //   client.println("GET /asciilogo.txt HTTP/1.1");
  //   client.println("Host: arduino.tips");
  //   client.println("Connection: close");
  //   client.println();
  // }
}

void loop() {
  printWifiData();
  delay(10000);
  // if there are incoming bytes available
  // from the server, read them and print them
  // while (client.available()) {
  //   char c = client.read();
  //   Serial.write(c);
  // }

  // // wait to let all the input command in the serial buffer
  // delay(5);

  // // if the server's disconnected, stop the client
  // if (!client.connected()) {
  //   Serial.println();
  //   Serial.println("Disconnecting from server...");
  //   client.stop();

  //   // do nothing forevermore
  //   while (true);
  // }
}

void printWifiData() {
  // print your WiFi shield's IP address
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print your MAC address
  byte mac[6];
  WiFi.macAddress(mac);
  char buf[20];
  sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X", mac[5], mac[4], mac[3], mac[2], mac[1], mac[0]);
  Serial.print("MAC address: ");
  Serial.println(buf);
}

void printWifiStatus() {
  // print the SSID of the network you're attached to
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address
  Serial.print("IP Address: ");
  IPAddress ip = WiFi.localIP();
  Serial.println(ip);

  // print the received signal strength
  long rssi = WiFi.RSSI();
  Serial.print("Signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

I am able to get the loop print the WiFIData evry 10 seconds, if I uncomment the line

WiFiClient client;

Then the code hangs and loop does not execute further.

How can I debug this?

I have tried to add a try catch thing around the client without any success

void loop() {
  try
  {
    WiFiClient client;
  }
  catch(const char* e)
  {
    Serial.println("cannot create WiFiCLient class");
  }
  while(true)
  {
    printWifiData();
    delay(10000);
  }
}

Now the output console for the above program is the same in both cases, it does not complete the call to printWifiData(); in setup and the board get into an error state so I have to manually boot it and add .uf2 file to recover it.


----------------------------------------------
>> ATE0
ATE0

OK
---------------------------------------------- > 0

----------------------------------------------
>> AT+CWMODE=1

OK
---------------------------------------------- > 0

----------------------------------------------
>> AT+CIPMUX=1

OK
---------------------------------------------- > 0

----------------------------------------------
>> AT+CIPDINFO=1

OK
---------------------------------------------- > 0

----------------------------------------------
>> AT+CWAUTOCONN=0

OK
---------------------------------------------- > 0

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

>> AT+CWDHCP=1,1

OK
---------------------------------------------- > 0

> getFwVersion
----------------------------------------------
>> AT+GMR
AT version:1.1.1.7(May  4 2021 15:14:59)
SDK version:3.2.0(a0ffff9f)
compile time:May  4 2021 15:14:59

OK
---------------------------------------------- > 1.1.1.7

[WizFi360] Initialization successful - 1.1.1.7
> getConnectionStatus
----------------------------------------------
>> AT+CIPSTATUS
STATUS:5

OK
---------------------------------------------- > 5

Attempting to connect to WPA SSID: TraceAP
> wifiConnect
----------------------------------------------
>> AT+CWJAP_CUR="TraceAP","Liberty123"
WIFI CONNECTED
WIFI GOT IP

OK
---------------------------------------------- > 0

[WizFi360] Connected to TraceAP
You're connected to the network
> getIpAddress
----------------------------------------------
>> AT+CIFSR
+CIFSR:STAIP,"192.168.10.13"
+CIFSR:STAMAC,"00:08:dc:6b:c0:9d"

OK
---------------------------------------------- > 192.168.10.13

I am using Arduino IDE 2.0 and earlephilhower version 2.6.1 , selecting Wiznet WizFi360-EVB-Pico from Boards.

@Giung951
Copy link
Contributor

Giung951 commented Nov 3, 2022

Hello @mhanuel26

Let me check about this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants