![]() |
VOOZH | about |
dotnet add package nanoFramework.System.Device.Wifi --version 1.5.144
NuGet\Install-Package nanoFramework.System.Device.Wifi -Version 1.5.144
<PackageReference Include="nanoFramework.System.Device.Wifi" Version="1.5.144" />
<PackageVersion Include="nanoFramework.System.Device.Wifi" Version="1.5.144" />Directory.Packages.props
<PackageReference Include="nanoFramework.System.Device.Wifi" />Project file
paket add nanoFramework.System.Device.Wifi --version 1.5.144
#r "nuget: nanoFramework.System.Device.Wifi, 1.5.144"
#:package nanoFramework.System.Device.Wifi@1.5.144
#addin nuget:?package=nanoFramework.System.Device.Wifi&version=1.5.144Install as a Cake Addin
#tool nuget:?package=nanoFramework.System.Device.Wifi&version=1.5.144Install as a Cake Tool
👁 Quality Gate Status
👁 Reliability Rating
👁 NuGet
👁 #yourfirstpr
👁 Discord
Document Language: |
This repository contains the nanoFramework System.Device.Wifi class library.
| Component | Build Status | NuGet Package |
|---|---|---|
| System.Device.Wifi | 👁 Build Status |
👁 NuGet |
The WifiNetworkHelper is mainly dedicated to help you connect automatically to Wifi networks. That said, it can be used as well to check if you have a valid IP address and a valid date on any interface including on ethernet.
The following code will allow you to connect automatically, wait for a valid IP address and a valid date with specific credentials:
const string Ssid = "YourSSID";
const string Password = "YourWifiPassword";
// Give 60 seconds to the wifi join to happen
CancellationTokenSource cs = new(60000);
var success = WifiNetworkHelper.ConnectDhcp(Ssid, Password, requiresDateTime: true, token: cs.Token);
if (!success)
{
// Something went wrong, you can get details with the ConnectionError property:
Debug.WriteLine($"Can't connect to the network, error: {WifiNetworkHelper.Status}");
if (WifiNetworkHelper.HelperException != null)
{
Debug.WriteLine($"ex: {WifiNetworkHelper.HelperException}");
}
}
// Otherwise, you are connected and have a valid IP and date
Note that this function will store the network credentials on the device.
You can as well connect to a network with pre stored credentials on the device depending on the type of device you have. Please check for proper support with your device.
// The wifi credentials are already stored on the device
// Give 60 seconds to the wifi join to happen
CancellationTokenSource cs = new(60000);
var success = WifiNetworkHelper.Reconnect(requiresDateTime: true, token: cs.Token);
if (!success)
{
// Something went wrong, you can get details with the ConnectionError property:
Debug.WriteLine($"Can't connect to the network, error: {WifiNetworkHelper.Status}");
if (WifiNetworkHelper.HelperException != null)
{
Debug.WriteLine($"ex: {WifiNetworkHelper.HelperException}");
}
}
// Otherwise, you are connected and have a valid IP and date
You can force to scan the network and then join the network. This case can be useful in specific conditions. Be aware, that you may have to use this method with one of the previous method depending the support of rescanning while you are already connected.
const string Ssid = "YourSSID";
const string Password = "YourWifiPassword";
// Give 60 seconds to the wifi join to happen
CancellationTokenSource cs = new(60000);
var success = WifiNetworkHelper.ScanAndConnectDhcp(Ssid, Password, requiresDateTime: true, token: cs.Token);
if (!success)
{
// Something went wrong, you can get details with the ConnectionError property:
Debug.WriteLine($"Can't connect to the network, error: {WifiNetworkHelper.Status}");
if (WifiNetworkHelper.HelperException != null)
{
Debug.WriteLine($"ex: {WifiNetworkHelper.HelperException}");
}
}
// Otherwise, you are connected and have a valid IP and date
Note that this function will store the network credentials on the device.
You join a Wifi network with a static IP address:
const string Ssid = "YourSSID";
const string Password = "YourWifiPassword";
// Give 60 seconds to the wifi join to happen
CancellationTokenSource cs = new(60000);
var success = WifiNetworkHelper.ConnectFixAddress(Ssid, Password, new IPConfiguration("192.168.1.7", "255.255.255.0", "192.168.1.1"), requiresDateTime: true, token: cs.Token);
The WifiNetworkHelper offers couple of functions to check validity of your IP address, the DateTime and helping setting them up:
var success = IsValidDateTime();
// if success is true, you have a valid DateTime
success = IsValidIpAddress(NetworkInterfaceType.Wireless80211);
// if success is true, you have a valid IP address on the Wireless adapter
// Be aware that a local address like 127.0.0.1 is considered as a valid address for ethernet
You can as well wait for a valid IP address and date time:
// Give 60 seconds to check if we have a valid IP and a valid DateTime
CancellationTokenSource cs = new(60000);
var success = WaitForValidIPAndDate(true, NetworkInterfaceType.Ethernet, cs.Token);
// if success is true then you are connected
Token-based methods (ConnectDhcp, ScanAndConnectDhcp, ConnectFixAddress) are retryable. If a connection attempt times out, call the method again:
bool connected = false;
while (!connected)
{
CancellationTokenSource cs = new(30000);
connected = WifiNetworkHelper.ConnectDhcp(Ssid, Password, requiresDateTime: true, token: cs.Token);
if (!connected)
{
Debug.WriteLine($"Not ready, status: {WifiNetworkHelper.Status}");
Thread.Sleep(5000);
}
}
To switch to a different SSID or restart the event-based helper, call Reset() first:
// Disconnect from current network if needed
WifiNetworkHelper.Disconnect();
// Reset the helper so it can be reconfigured
WifiNetworkHelper.Reset();
// Connect to a different SSID
CancellationTokenSource cs = new(30000);
WifiNetworkHelper.ConnectDhcp("NewSSID", "NewPassword", token: cs.Token);
The same applies to the event-based SetupNetworkHelper:
WifiNetworkHelper.Reset();
WifiNetworkHelper.SetupNetworkHelper("NewSSID", "NewPassword");
Reconnect() vs. ConnectDhcp()Reconnect() does not actively send join credentials. It only waits for the platform's automatic reconnection (configured via WifiReconnectionKind.Automatic) to produce a valid IP address. Use it only when credentials are already stored on the device and the platform is expected to reconnect automatically.
If you need an explicit reconnect with credentials, use ConnectDhcp() instead.
NetworkReady behaviourWhen using SetupNetworkHelper(), NetworkReady is reset when the connection is lost and re-signaled when it is restored, accurately reflecting live network state. Code that previously assumed NetworkReady would remain set permanently after first connect should be updated to handle transient disconnects.
For documentation, providing feedback, issues and finding out how to contribute please refer to the Home repo.
Join our Discord community here.
The list of contributors to this project can be found at CONTRIBUTORS.
The nanoFramework Class Libraries are licensed under the .
This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behaviour in our community. For more information see the .NET Foundation Code of Conduct.
This project is supported by the .NET Foundation.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET Framework | net net is compatible. |
Showing the top 5 NuGet packages that depend on nanoFramework.System.Device.Wifi:
| Package | Downloads |
|---|---|
|
MakoIoT.Device.Services.ConfigurationManager
Configuration mode manager for MAKO-IoT |
|
|
MakoIoT.Device.Services.ConfigurationApi
REST API for configuration with MAKO-IoT |
|
|
MakoIoT.Device.Services.WiFi.AP
WiFi Access Point library for MAKO-IoT |
|
|
MakoIoT.Device.Platform.LocalConfig
MAKO-IoT Platform local configuration library. On-device web server, WiFi AP |
|
|
MakoIoT.Device.Services.WiFi
WiFi connectivity library for MAKO-IoT |
Showing the top 3 popular GitHub repositories that depend on nanoFramework.System.Device.Wifi:
| Repository | Stars |
|---|---|
|
nanoframework/Samples
🍬 Code samples from the nanoFramework team used in testing, proof of concepts and other explorational endeavours
|
|
|
nanoframework/nanoFramework.IoT.Device
📦 This repo includes .NET nanoFramework implementations for various sensors, chips, displays, hats and drivers
|
|
|
nanoframework/nanoFramework.M5Stack
📦 Board support package for M5Stack, M5StickC and M5StickCPlus for .NET nanoFramework
|
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.0-preview.28 | 85 | 5/29/2026 |
| 2.0.0-preview.25 | 79 | 5/28/2026 |
| 2.0.0-preview.24 | 51 | 5/27/2026 |
| 2.0.0-preview.23 | 59 | 5/26/2026 |
| 2.0.0-preview.22 | 50 | 5/26/2026 |
| 2.0.0-preview.21 | 63 | 5/25/2026 |
| 2.0.0-preview.20 | 86 | 5/19/2026 |
| 2.0.0-preview.19 | 72 | 5/18/2026 |
| 2.0.0-preview.18 | 102 | 5/11/2026 |
| 2.0.0-preview.17 | 56 | 5/11/2026 |
| 2.0.0-preview.16 | 58 | 5/11/2026 |
| 2.0.0-preview.15 | 54 | 5/11/2026 |
| 2.0.0-preview.13 | 64 | 4/30/2026 |
| 2.0.0-preview.12 | 55 | 4/30/2026 |
| 2.0.0-preview.11 | 56 | 4/30/2026 |
| 2.0.0-preview.10 | 60 | 4/30/2026 |
| 2.0.0-preview.9 | 88 | 4/20/2026 |
| 2.0.0-preview.8 | 51 | 4/20/2026 |
| 2.0.0-preview.7 | 61 | 4/20/2026 |
| 1.5.144 | 342 | 5/29/2026 |