Hello,
I tried to implement on a SAMD51 microcontroller, and using a (WiFi ESP Click) from MikroE the following code:
#include <ESP8266_Lib.h>
#undef max
#undef min
#include "FTTech_SAMD51Clicks.h"
#include "WiFiEsp.h"
// Your ESP8266 baud rate:
#define ESP8266_BAUD 115200
// Hardware Serial on Mega, Leonardo, Micro...
#define EspSerial SERIALCLICK // the serial relative to the socket where your WiFi click is locates
ESP8266 wifi(&EspSerial);
char ssid[] = "Twim"; // your network SSID (name)
char pass[] = "12345678"; // your network password
int status = WL_IDLE_STATUS; // the Wifi radio's status
// Initialize the Ethernet client object
WiFiEspClient client;
/******************************************************************************
* Function Prototypes
*******************************************************************************/
void WiFiESPClick_Init(void);
void printWifiStatus(void);
/******************************************************************************
* Function Definitions
*******************************************************************************/
// Define EN and RST pins
#define EN ENSOCKET
#define RST RSTSOCKET
void setup()
{
// This will initiate the board
FTClicks.begin();
// Enable 5V
FTClicks.turnON_5V();
// Enable the power output of Click 2
FTClicks.turnON(2);
// Define Enable and Reset Pins of Click 2 as outputs
pinMode(EN, OUTPUT);
pinMode(RST, OUTPUT);
// Initialize serial for debugging and waits for console
Serial.begin(9600);
while(!Serial);
// Puts a space in debug window and hard resets WiFi module
Serial.print("\n\n\n\n\n\n\n\n\nInitiating...\n");
WiFiESPClick_Init();
// initialize serial for ESP module and waits
EspSerial.begin(ESP8266_BAUD);
while(!EspSerial);
// initialize ESP module
WiFi.init(&EspSerial);
// 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);
}
Serial.println("You're connected to the network");
printWifiStatus();
}
void loop()
{
\\Process
}
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
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
// print the received signal strength
long rssi = WiFi.RSSI();
Serial.print("Signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
}
void WiFiESPClick_Init(){
Serial.print("Reseting module");
digitalWrite(EN, HIGH);
Serial.print(".");
delay(500);
digitalWrite(RST, LOW);
Serial.print(".");
delay(500);
digitalWrite(RST, HIGH);
Serial.print(".");
delay(2000);
Serial.println(" Reseted!\n");
}
The issue I'm facing is about the connection with the Wifi.begin, it doesn't succeed and keep trying a connection indefinitely (as supposed to do, actually). Keep in mind that:
*The code used to work fine just a while ago (maybe I'm missing something that went wrong between updates).
*The connection with a cellphone hotspot works (and this is the strangest fact about this).
Thank you for your help.