Instant Pushsafer notification from ESP32

This Arduino example shows how to send a Pushsafer notification from an ESP32. Sometimes we need to know immediately when something changes at home, for example when the fridge temperature rises or we have left a window open.

Difficulty: Intermediate

Created: January 2021

Technically reviewed: October 2026

Reference platform: ESP32 development board

Sending an instant Pushsafer notification with an ESP32
Sending an instant Pushsafer notification with an ESP32

What is Pushsafer?

Pushsafer is a service for sending instant push notifications to a phone, tablet or desktop computer. Its email gateway and API make it possible to integrate notifications into many different applications.

In this example, the Pushsafer Arduino library connects over HTTP on port 80. The private key and message therefore travel across the network without encryption. Only use this example on a trusted network.

Diagram showing how a Pushsafer notification is delivered
How a Pushsafer notification reaches your device.

First, register a free account at pushsafer.com. After registering, we received a test allowance of 1,000 API calls, which was plenty for experimenting. At the time of writing, another 1,000 API calls cost €0.99.

Pushsafer registration and login page
Pushsafer registration and login page

Download the Pushsafer app from the store for your device.

Sign in with your Pushsafer account and follow the instructions in the app to register your device.

The Arduino sketch

Download the Pushsafer library, extract it into your Arduino/libraries/ folder, and restart the Arduino IDE.

Copy the following sketch into the editor and enter your Wi-Fi credentials.

#include <WiFi.h>
#include <WiFiClient.h>
#include <Pushsafer.h>

#define PushsaferKey "Your_Private_Key"  // Private key from https://www.pushsafer.com/

const char ssid[] = "Your_WiFi_SSID";
const char password[] = "Your_WiFi_Password";

WiFiClient client;
Pushsafer pushsafer(PushsaferKey, client);

void setup()
{
  WiFi.mode(WIFI_STA);
  delay(100);
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
  }

  // This part can also go into loop(), triggered by a condition.
  struct PushSaferInput input;
  input.message = "Test message from ESP32";
  input.title = "Hi!";
  input.sound = "6";
  input.vibration = "1";
  input.icon = "1";
  input.iconcolor = "#00FF00";
  input.priority = "1";
  input.device = "xxxxx";  // Device ID from https://www.pushsafer.com/
  pushsafer.sendEvent(input);
}

void loop() {}

Sign in at pushsafer.com, then copy your Pushsafer private key and the Device ID of the device you want to notify into the sketch.

Once these values are in place, upload the sketch to your ESP32.

How does the Arduino sketch work?

At the beginning of the sketch, we include the libraries we need.

#include <WiFi.h>
#include <WiFiClient.h>
#include <Pushsafer.h>

We have also used this example in ESP8266 projects. For an ESP8266, replace the first include with this line.

#include <ESP8266WiFi.h>

Set PushsaferKey to the private key shown in your Pushsafer account.

#define PushsaferKey "Your_Private_Key"

Enter the SSID and password of the Wi-Fi network you want to use.

const char ssid[] = "Your_WiFi_SSID";
const char password[] = "Your_WiFi_Password";

Next, we create a WiFiClient instance and a Pushsafer instance.

WiFiClient client;
Pushsafer pushsafer(PushsaferKey, client);

Then the ESP32 connects to the Wi-Fi network.

WiFi.mode(WIFI_STA);
delay(100);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
  delay(500);
}

Finally, we create a structure, fill in the notification details and send the message to the chosen device. Be sure to enter the correct Device ID from your Pushsafer account.

struct PushSaferInput input;

input.message = "Test message from ESP32";
input.title = "Hi!";
input.sound = "6";
input.vibration = "1";
input.icon = "1";
input.iconcolor = "#00FF00";
input.priority = "1";
input.device = "xxxxx";  // Device ID from https://www.pushsafer.com/

pushsafer.sendEvent(input);
Pushsafer notification in the app
Pushsafer notification in the app

This is a simple example, but you can easily incorporate it into your own project. It shows how to send an instant notification from an ESP32 using Pushsafer.


← Further Arduino Tutorials

← More Arduino / ESP Examples and Projects