---
title: "Ping CronMissed from an ESP32 or Arduino"
url: "https://cronmissed.com/snippets/arduino.md"
canonical_url: "https://cronmissed.com/snippets/arduino"
last_updated: "2026-10-22"
type: "how-to"
summary: "An ESP32 sketch that sends a CronMissed ping over HTTPS. Plain HTTP is redirected and fails, so the sketch needs TLS and a root certificate."
related: ["https://cronmissed.com/snippets.md", "https://cronmissed.com/snippets/shell.md", "https://cronmissed.com/learn/heartbeat-monitoring.md", "https://cronmissed.com/learn/choosing-grace-time.md", "https://cronmissed.com/docs/pinging-api.md"]
---

# Ping CronMissed from an ESP32 or Arduino

> **For AI agents:** the complete index of CronMissed pages is [llms.txt](https://cronmissed.com/llms.txt). Every page is also served as markdown at its URL plus .md.

An ESP32 sketch that sends a CronMissed ping over HTTPS. Plain HTTP is redirected and fails, so the sketch needs TLS and a root certificate.

A sensor, a gateway or a greenhouse controller can ping CronMissed from the board itself, and the check alerts when the board goes quiet. The ping must use HTTPS: a plain HTTP request is answered with a redirect, and most board libraries do not follow one.

## What should a board job send?

- A request to `/start` before the work, so CronMissed can time the run and notice a job that never finishes.
- A request to the plain URL when the work succeeded, or to `/fail` when it did not. `/<exit status>` works too: 0 is a success and any other number is a failure.
- The end of the output in the request body, up to 100,000 bytes, so the alert shows the error without a trip to the server.

## What does the sketch look like?

```
#include <WiFi.h>
#include <WiFiClientSecure.h>
#include <HTTPClient.h>

const char* WIFI_SSID = "your-network";
const char* WIFI_PASS = "your-password";
const char* PING_URL = "https://ping.cronmissed.com/5f0c1b2e-7a3d-4c8e-9b61-2d4f8a7e3c10";

// The root certificate of the ping host, as PEM. Paste the one your browser shows for the ping address.
const char* ROOT_CA = "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----\n";

void ping(const String& suffix) {
  WiFiClientSecure client;
  client.setCACert(ROOT_CA);        // use client.setInsecure() only for a quick test: it skips certificate checks
  HTTPClient http;
  http.setTimeout(10000);
  if (http.begin(client, String(PING_URL) + suffix)) {
    http.GET();                      // the result is ignored: a lost ping must not stop the board
    http.end();
  }
}

void setup() {
  WiFi.begin(WIFI_SSID, WIFI_PASS);
  while (WiFi.status() != WL_CONNECTED) delay(500);
}

void loop() {
  ping("/start");
  readSensorsAndStore();            // your work
  ping("");
  delay(10UL * 60UL * 1000UL);      // ping every 10 minutes
}
```

Keep the ping URL in an environment variable or a secret store, never in a public repository: the URL is the check's only credential.

## How should the check be set?

Create a simple check whose period is the loop interval plus a little, here 10 minutes, and a grace of two or three loop times so a slow Wi-Fi reconnect is not an alert. For a board that sleeps between readings, ping on each wake-up and set the period to the sleep time.

## What are the common problems?

- The request fails with a TLS error: the root certificate is wrong or the board clock is not set. Set the time with NTP before pinging.
- The ping works from a laptop and not from the board: check that the sketch uses https:// and not http://.
- Memory: TLS needs a few tens of kilobytes of free heap on an ESP8266; ping once per loop and reuse nothing between pings.

## Questions

### Does it work on an ESP8266?

Yes, with the ESP8266 libraries (ESP8266WiFi, ESP8266HTTPClient and a BearSSL secure client). The structure of the sketch stays the same.

### Can a board behind a mobile network ping?

If it can make an outbound HTTPS request over IPv4, yes. The ping host is reached over IPv4 or dual stack only.

## Related pages

- [Shell and curl](https://cronmissed.com/snippets/shell.md)
- [Heartbeat monitoring](https://cronmissed.com/learn/heartbeat-monitoring.md)
- [Choosing a grace time](https://cronmissed.com/learn/choosing-grace-time.md)
- [Pinging API](https://cronmissed.com/docs/pinging-api.md)

## Related

- [Ping snippets for 12 languages and tools](https://cronmissed.com/snippets.md)
- [Ping CronMissed from a shell script with curl](https://cronmissed.com/snippets/shell.md)
- [Heartbeat monitoring for scheduled jobs](https://cronmissed.com/learn/heartbeat-monitoring.md)
- [How to choose a grace time for a cron check](https://cronmissed.com/learn/choosing-grace-time.md)
- [Pinging API reference](https://cronmissed.com/docs/pinging-api.md)
