This arduino sample code shows how to use ESP32 and Pushsafer. It is often necessary to be immediately aware of the condition of our appliances, eg when the temperature of the refrigerator rises, etc.
The original post can be read here: Instant Pushsafer notification from ESP32
Open the arduino application. if not already installed, the Pushsafer directory must be installed! Then copy this code and upload it to ESP32.
/**************************************/
// https://myhomethings.eu //
// ESP32 Module //
// Pushsafer Test //
/**************************************/
#include <WiFi.h>
#include <WiFiClient.h>
#include <Pushsafer.h>
#define PushsaferKey "Private Key" // Private Key: http://pushsafer.com
char ssid[] = "Wifi_SSID";
char password[] = "SuperSecretWifiPassword";
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 can also go into the loop subject to some 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: http://pushsafer.com
pushsafer.sendEvent(input);
}
void loop()
{
}
This example is also good for ESP8266, you just need to replace line 1 with this:
"#include <ESP8266WiFi.h>"
Enter the Wifi connection details, Pushsafer private key and Device ID to which you want to send the messages in the code.
If you don't have an account yet, register at https://pushsafer.com
Download the app to your phone and wait for the messages.
This is just an example, but can be easily integrated into your own application. It is so easy to send an instant notification about ESP32 using Pushsafer.
See more ESP32, ESP8266, and Arduino examples.
I hope you enjoyed this example and it will be useful to you.
Have a nice day!
Comments