LAN network for microcontrollers. Over the internet.

Dominik Nowak
Jan 11 · 4 min read

More and more devices around us are connected. Not only computers, but also small, low power and cheap microcontroller based devices. There are numerous IoT platforms for embedded hardware, allowing you to access your things through the internet. But they are generally “cloud based” — that means you do not access your embedded board directly, but through an API of the IoT cloud.

In most cases it’s not hard to reach the free data credit limit provided by the IoT platform and you need to pay for more. Latency may also be an issue as all of the traffic goes through the cloud - due to that, usually you can forget about the real time control over the internet.

But you don’t need to connect your microcontroller to a third party cloud to access it through the internet. Now you can use Husarnet, and securely access it directly, just like it was in the same LAN network.

Connect your ESP32 Wi-Fi microcontroller over the internet — step by step.

Husarnet, a P2P VPN network has low footprint, is highly optimized and written in pure C++. Thanks to that it could be ported on numerous hardware platforms — even microcontrollers.


The first, currently supported microcontroller is ESP32 — extremely popular among makers. For those familiar with ESP32 SDK, we’ve created a dedicated “ESP-IDF” package. To start development all you need to do is follow these instruction steps:

1. Download the ESP32 toolchain

2. Get the ESP32 SDK with Husarnet:

git clone — recursive ~/apps/husarnet-esp-idf

3. Export the environment variable ESP_IDF:

export ESP_IDF=$HOME/apps/husarnet-esp-idf

Interested how to use Husarnet with ESP32? Take a look at an example projects available on

$10 Secure ESP32-Based Internet Camera .

Arduino Setup

Sounds good? There’s more, and you can start developing even easier - it also works with Arduino framework. Arduino is an extremely popular framework used not only by makers but also by professional developers. With libraries to almost all market available sensors and modules it allows you to create advanced projects very quickly.

Probably the easiest way to start developing projects on ESP32 is by using popular Arduino IDE. Let’s try to do that:

1. Add Husarnet IDF for ESP32

  • In Arduino IDE open:
File -> Preferences

2. Install ESP32 dev boards

  • In Arduino IDE open:
Tools -> Board: "..." -> Boards Manager ...
  • Search for “esp32-husarnet by Husarion”
  • Click Install button

3. Select ESP32 dev board

  • In Arduino IDE open:
Tools -> Board
  • Select “ESP32 Dev Module” under “ESP32 Arduino (Husarnet)” section

And… that’s it! You can start developing just like that. Husarnet provides the same API as popular “WiFiServer” and “WiFiClient” Arduino classes. If you have your project working in your local network you can make it work through the internet by simply replacing “WiFiServer” with “HusarnetServer” and “WiFiClient” with “HusarnetClient”. It couldn’t be easier.

To connect you ESP32 do Husarnet network open the Serial terminal, wait for a message such as the one below:

[10009675] Visit 
to configure the device .

And copy the link into your web browser. Then name your device, select the network, and your done.

We’ve created an example showing you in details how to use Arduino SDK for Husarnet:

Internet Controlled LED Strip Using ESP32 + Arduino at

Hope you liked those two examples. Let us know what you think!.

Husarion Blog

Husarion provides hardware, software and cloud platform for fast robot prototyping & development

Dominik Nowak

Written by

CEO of Husarion, robotics & embedded software enthusiast.

Husarion Blog

Husarion provides hardware, software and cloud platform for fast robot prototyping & development