esp8266 Pushbullet Android Notification

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
Posts: 1
Joined: Wed Apr 10, 2019 9:38 am

esp8266 Pushbullet Android Notification

Post by Roffey » Wed Apr 10, 2019 10:32 am

Been using micropython for a couple of weeks now and getting more impressed as I go, particularly with the guru's who seem to be more than helpful.
I'm using upyCraft V1.1, which I find the most useful IDE.
I find having a project is my best way of learning at my senior years!
Anyway, since I always find snippets of code very handy, and I have finally got Pushbullet (free for my limited notifications) to work, I thought I'd share my bit.
Of course it's not original, with bits pulled from various sources, but it works for me.

I do not pretend to know much at all about python etc, I just dig, try, try again until I get things to work.

One of my biggest problems was with HTTPS and required certificates etc … definitely not my forte.

So, this 'project' is simple … I wanted my doorbell to send me a notification, so I could be out of range of the ringers and still know.
The principle for me was to rectify the bell speaker output, (simple diode, cap and bleed resistor), shove that into the a/d port for a trigger.
The bell workings were encapsulated... so no digital trigger output.

First thing was Pushbullet and setting up an account …. ok .. sign up using google account .. done and retrieve a code to use.

Find out it uses an HTTPS Push … uh oh... going to need key certificates.. No knowledge here.
Ok... look around... can use Openssl to generate them apparently.

So find this site where I can download a lite version. Download it. Find the exe file in Openssl -Win32(64)\bin\ directory. Create a C:\certs2 directory for the 2 files generated Client .key and .crt files.
Open the openssl.exe file in run as administrator mode.
Now type in -newkey rsa:2048 -nodes -keyout C:\certs2\client.key -x509 -days 365 -out C:\certs2\client.crt and fill in country, county, initials for company, name and email only to discover discover the files have been generated.
To get these files into the esp using upyCraft required renaming these files as txt files, then renaming them.
ie client.key to clientkey.txt and client.crt to clientcrt.txt. Opened in upyCraft in txt format and downloaded to the esp.
Then on the repl line …. import os … os.rename('clientkey.txt','client.key') and same for the crt file.

The main file now …

# would like start up checking sending notification
# fill in ssid and pwd
# fill in api key from pushbullet
import json
import urequests
import machine
import network
import time
from machine import ADC

adc0=ADC(0) #create ADC object on ADC pin
bell = machine.Pin(0, machine.Pin.IN)
led = machine.Pin(2, machine.Pin.OUT)
led.value(1) #turn led off
flag = 0
startFlag = 1 #flag for sending notification at start up
def connect():
# import network

ssid = "**************"
password = "**********"
station = network.WLAN(network.STA_IF)
if station.isconnected() == True:
print("Already connected")
led.value(0) #led on
station.connect(ssid, password)

while station.isconnected() == False:

print("Connection successful")
led.value(0) #led on


body = "Front Door"
title = "Bell Push"
data_sent = {"type": "note", "title": title, "body": body}
API_KEY = 'o.--------------------- issued from pushbullet'

startbody= "Connection"
start_title ="Check ok"
start_data ={"type": "note", "title": start_title, "body":startbody}

pb_headers = {
'Authorization': 'Bearer ' + API_KEY,
'Content-Type': 'application/json',
'Host': ''

def bellnotify():
r =
global flag
flag = 0

def startcheck():
r =
global startFlag
startFlag = 0

while (True):

if > 500 and flag == 0 : #read value, 0-1024
flag = 1

if startFlag == 1:

station = network.WLAN(network.STA_IF)
if station.isconnected() == False:


So.…. I think that is it …… Works for me....
I hope this might be useful .


Post Reply