Simplepush Blog

ESP8266 encrypted notifications with Simplepush

The ESP8266 is a low-cost system-on-a-chip (SoC) which comes with integrated WiFi and a full TCP/IP stack. It is the perfect match for prototyping IoT projects or for just tinkering around.

With Simplepush you can send push notifications to your smartphone.

In this blog post you will learn how to combine these two components in a secure way in which nobody can intercept your data. Neither at your local network nor at nodes (e.g. Google) on the way from your ESP8266 to your smartphone.

The chip is programmable (among other languages) in LUA, Javascript and with the Arduino environment (C++). For our task of sending encrypted notifications from the ESP8266 to a smartphone, we choose the Arduino environment.

Demo with a NodeMcu development board.

With Arduino libraries it is easy to do HTTPS requests from your ESP8266. However at the time of writing, doing SSL on the ESP8266 still comes with certain problems attached. For example you have to hard code the SHA1 fingerprint of the SSL certificate of the domain you want to connect to. This is a problem since certificates change and thereby their fingerprints change too.

When it comes to sending push notifications from the ESP8266 to your smartphone, we can sidestep this problem by using Simplepush’s encryption feature. This means sending encrypted notifications (AES-CBC-128) via HTTP.

Just download our library and import the ZIP file in the Arduino IDE (as described here). Then sending notifications (both encrypted and unencrypted) is as easy as shown in the following code snippet.

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <Simplepush.h>

ESP8266WiFiMulti WiFiMulti;
Simplepush simple;

void setup() {
  // Connect ESP8266 to WiFi
  WiFiMulti.addAP("YourWifiSSID", "WifiPassword");

  if((WiFiMulti.run() == WL_CONNECTED)) {
    // Send unencrypted notification
    simple.send("YourSimplepushKey", "Wow", "This is so easy", "Event");

    // Send encrypted notification
    simple.sendEncrypted("YourSimplepushKey", "password", "salt", "Wow", "This is so secure.", "Event");
  }
}

For password and salt fill in the password you chose and the provided salt (can be found in the encryption section of the app).

Click here for a more complete example.

Share on:
Imprint