Salve a tutti!
Spero che qualcuno di voi mi sappia dare una mano.
Sto utilizzando la libreria WiFiManager_NINA_Lite (GitHub - khoih-prog/WiFiManager_NINA_Lite: Light-Weight WiFi/Credentials Manager for AVR Mega, Teensy, SAM DUE, SAMD, STM32, etc. boards running U-Blox WiFiNINA modules/shields. Powerful-yet-simple-to-use feature to enable adding dynamic custom parameters. Now using WiFiMulti_Generic library).
La libreria funziona perfettamente, riesco a collegarmi alla rete mediante configurazione del web portal e si collega alla nuova rete.
Quello che non riesco a capire è come integrare il codice che vedete sotto.
Cioè, non riesco a farlo agganciare alla rete che seleziono mediante la libreria.
Qualcuno mi sa dare una mano?
Ringrazio in anticipo.
#include <SPI.h>
#include <WiFiNINA.h>
#include <UniversalTelegramBot.h>
// Library for connecting to Telegram
#include <ArduinoJson.h>
#define BOT_TOKEN "MyToken"
#define chat_id "MyID"
char SSID[] = "Myssid"; // your network SSID (name)
char PASS[] = "Mypass"; // your network password
int status = WL_IDLE_STATUS;
WiFiSSLClient client;
UniversalTelegramBot bot(BOT_TOKEN, client);
void printWiFiStatus() {
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your board'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 setup()
{
//Initialize serial and wait for port to open:
Serial.begin(9600); {
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
// Defined in thingProperties.h
}
// check for the WiFi module:
if (WiFi.status() == WL_NO_MODULE) {
Serial.println("Communication with WiFi module failed!");
// don't continue
while (true);
}
String fv = WiFi.firmwareVersion();
if (fv < "1.0.0") {
Serial.println("Please upgrade the firmware");
}
// attempt to connect to WiFi network:
while (status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
Serial.println(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);
}
Serial.println("Connected to wifi");
printWiFiStatus();
pinMode (4, INPUT);
bot.sendMessage(chat_id, "Connesso!", "");
}
void loop() {
if (digitalRead(4)) {
bot.sendMessage(chat_id, "Aperto", "");
// Attesa tempo 8 ore per ripristino tasto
delay(28800000);
} else {
}
}