An ESP32 can expose its web server through an outbound connection, without opening ports on the router. In this tutorial, we add Pinscope to an Arduino project with PlatformIO: the device connects to the service, and its local server becomes accessible at the HTTPS address shown in the dashboard.
The difference compared with adding TLS directly is the memory cost. Pinscope measured 9.4 KB of connected RAM with its Noise protocol, compared with 23.6 KB with TLS in the same application on an ESP32-S2. We won't implement our own cryptography: we'll integrate the component and let it manage the tunnel.
What we'll connect
The example uses a Wi-Fi board, a simple HTTP server, and a PlatformIO project with the Arduino framework. The ESP32 starts an outbound TCP connection to Pinscope on port 443; the dashboard provides the HTTPS address for the server listening on port 80 on the device.
flowchart LR
A["Browser"] --> B["HTTPS address"]
B --> C["Pinscope service"]
C --> D["Encrypted tunnel"]
D --> E["ESP32"]
E --> F["Local HTTP server"]The exchange between the ESP32 and the service uses Noise_NK_25519_ChaChaPoly_SHA256: the device knows the server's static public key in advance. Pinscope encrypts traffic with ChaCha20-Poly1305. This does not make the connection from the ESP32 to the service TLS; the public web address is served over HTTPS.
Set up the project and key
In PlatformIO, add the library to the platformio.ini file. The specified version range is the one listed in the component documentation.
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps = pinscope/pinscope@^0.2.15
Also install the library from the PlatformIO registry if your project uses a different platform or board configuration. Copy the project key from the Connect a device tab in the Pinscope dashboard; don't make one up or upload it to the repository.
Save it in a local file named secrets.h and exclude that file from version control. The example value is a placeholder: replace it with the actual key from the dashboard.
#define PINSCOPE_KEY "psk_REEMPLAZAR_POR_LA_CLAVE_REAL"
Add secrets.h to the .gitignore file. The Pinscope guide describes the key as 28 characters with the psk_ prefix; if the copied value doesn't match that format, check it before compiling. Don't put the secret in a configuration file that will be published.

Create the server and start the tunnel
Save the following program in src/main.cpp. The server responds on port 80 and, after starting Wi-Fi, configures Pinscope with the key and a firmware version displayed in the dashboard.
#include <Arduino.h>
#include <WiFi.h>
#include <WebServer.h>
#include <pinscope.h>
#include "secrets.h"
const char *ssid = "TU_RED_WIFI";
const char *password = "TU_CLAVE_WIFI";
WebServer server(80);
void handleRoot() {
server.send(200, "text/plain", "ESP32 accesible por Pinscope");
}
void setup() {
Serial.begin(115200);
server.on("/", handleRoot);
server.begin();
WiFi.begin(ssid, password);
pinscope_config_t config = {};
config.project_key = PINSCOPE_KEY;
config.firmware_version = "1.0.0";
pinscope_start(&config);
}
void loop() {
server.handleClient();
delay(2);
}
Replace the Wi-Fi credentials and Pinscope key before compiling. pinscope_start() is called after WiFi.begin(); there's no need to wait for the connection to become active, because the component reconnects on its own. The example registers a minimal route to verify that the tunnel reaches the server.
Compile and upload the firmware from the project folder:
pio run
pio run --target upload
pio device monitor
After uploading, check that the device appears under Devices in the dashboard, then open its address. If the server responds on a different port, configure that port in Pinscope before starting it; the configuration supports specifying up to four ports.
Send a custom metric
In addition to built-in data, the library lets you send metrics from any task. For example, if the project already calculates a reading, it can publish it like this:
pinscope_metric("water_level_cm", 42.5);
The number is just an illustrative value: replace it with the actual reading and call the function when you have data to send. Custom metrics don't require adding a server or changing the connection flow.
Common issues and limitations
Don't leave the key in Git. If the device doesn't appear in the dashboard, check that you copied the key from the correct project, that it's included in the build, and that the network allows outbound connections on port 443. Networks that inspect traffic and accept only genuine TLS on that port may block the tunnel.
The server address is based on a public key compiled into the firmware. Changing the server key means updating the devices' firmware. The tunnel's capabilities shouldn't be treated as unlimited, either: Pinscope sets the size of its buffers and describes its performance as suitable for pages, logs, and updates, not streaming video.
Remote access exposes whatever your application already serves. If the page includes buttons or actions, protect them on the server itself if they shouldn't be available to everyone with access. OTA updates require two application partitions; Pinscope also documents the rollback option for reverting an image that fails to connect.
Once the server is responding locally, the next check is to open its HTTPS address from the dashboard and confirm that it returns the example text. After that, you can replace the route with the interface your device already provides.