Add Push Notifications To Your Hardware

About the project

Use Pushbullet to notify you of whatever your hardware is doing

Project info

Difficulty: Easy

Platforms: ArduinoIFTTTMicrosoftParticleRaspberry Pi

Estimated time: 1 hour

License: GNU General Public License, version 3 or later (GPL3+)

Items used in this project

Hardware components

ARDUINO MICRO ARDUINO MICRO x 1
Breakout Kit for Raspberry Pi Model A+&B+&2 Breakout Kit for Raspberry Pi Model A+&B+&2 x 1
PushBullet PushBullet x 1
Particle Photon Particle Photon x 1
Particle Photon Particle Photon x 1
Particle Photon Particle Photon x 1

Software apps and online services

IFTTT Maker service IFTTT Maker service
Microsoft Windows 10 IoT Core Microsoft Windows 10 IoT Core

Story

If you are like me, you want instant alerts of the many things your hardware might be doing. Your dryer being done with the clothes, your pool or spa being at a certain temperature, your basement being filled up with water (ouch!), your garage door being opened for a long time, any other event you might think of can be sent to your phone.

One way of achieving this is via the use of push notifications. This is made very simple with the use of the Particle Cloud and a great app called Pushbullet.

Note: This article describes how to do this with a particle dev kit, but I believe other hardware, like a raspberry pi, could also use this mechanism by sending a rest call to the pushbullet API. Find the details below.

How it works

  • the Particle dev kit will read some information, something important to you and your project (example: the temperature of your house)
  • This webhook will push a notification to Pushbullet
  • Pushbullet will, in turn, push this notification to our devices

The software

There are four steps that we need to accomplish:

  • install the pushbullet app
  • update the particle firmware - make your project publish some information
  • configure the particle webhook
  • upload the webhook to the particle cloud

Install the pushbullet app

Pay a visit to the pushbullet site, sign up for an account if you don't have one already and get your Pushbullet Access Token from the settings page.

Note: do not share this Pushbullet Access Token, since it grants access to your account!

Update the particle firmware

We need to add the following line of code in the particle's firmware:

        Particle.publish("pushbullet", "Your clothes are dry", 60, PRIVATE);

Of course, you can add there a variable for getting the temperature of your pool like this:

        Particle.publish("pushbullet", "Your pool is at " + String(pool_temperature) + " degrees", 60, PRIVATE);

or even knowing the status of your garage door:

        Particle.publish("pushbullet", "Your garage door is " + garage_status_string, 60, PRIVATE);

You can add there what is relevant to you and your project.

I can't help to notice that what we insist on calling firmware (a permanent software programmed into a read-only memory, according to Google, or the program that runs your particle) is today so easy to change that in reality is another piece of software.

Configure the particle webhook

We need to create a piece of software called a webhook and configure it to connect to pushbullet. 

What is a webhook, after all? From particle's site:

Webhooks are a simple and flexible way for your devices to make requests to almost anything on the Internet. Webhooks listen for events from your devices. When you send a matching event, the hook will send a request to your web application with all the details!

If you are not familiar with webhooks or how they work, please head over particle's docs for a more in depth description.

Now back to our business. Download to your computer the webhook code (find it in the software section below) in a file named webhook.json.

Edit the webhook.json file just created and replace the Access Token in the Bearer field (you have to replace 123456789012345678901234567890 with your Pushbullet Access Token). Save and close the file.

Once the file is edited with the token, you are ready to upload this webhook to the Particle cloud.

Upload the webhook to the Particle cloud

Webhooks are configured via the particle CLI. If you don't have it installed already, please do so following the instructions here.

Once installed, open a console and type:

particle webhook create webhook.json

The output of that command would look like this:

Using settings from the file webhook.jsonSending webhook request { uri: 'https://api.particle.io/v1/webhooks',method: 'POST',json:{ eventName: 'pushbullet',url: 'https://api.pushbullet.com/v2/pushes',requestType: 'POST',headers:{ Authorization: 'Bearer 123456789012345678901234567890','Content-Type': 'application/json' },json: { type: 'note', title: '{{SPARK_EVENT_VALUE}}', body: '' },mydevices: true,event: 'pushbullet',deviceid: undefined },headers: { Authorization: 'Bearer skljhklasjhdfjklhasdkljfhklasjhdf' } }Successfully created webhook with ID 1234kljhl123h41234jklh

That means the webhook got configured correctly.

Note: once we are done with the webhook, there is no need anymore to keep the computer you are using on or connected to the internet, since the webhook does not execute in it nor it needs it to run. We just uploaded the webhook to the particles cloud, and it is this cloud that will take it from here.

why Pushbullet?

There are a number of apps that can help you bring notifications from your hardware into your phone. One big name, probably with a much larger set of features, is IFTTT.

However, I find Pushbullet to be easy to use and most importantly, it's very fast.

When compared side by side, my phone received the pushbullet notifications around 5 to 10 seconds FASTER than IFTTT, most of the time.

You could argue that 10 seconds is nothing, but when you are showing off your projects to friends and family, it SUCKS to have to wait for 15 seconds ;)

In my experience with pushbullet, I get the notifications in three seconds or less, and again, most of the time. At other times, it can take up to 15 seconds, which brings me close to the IFTTT delays.

I have not scientifically measured where those delays of 15 seconds happen, so I cannot entirely blame pushbullet for them, or IFTTT for that matter. Remember that between my internet connected development kit (the particle) and my phone there are different factors that can delay the communication, in the form of my router, my ISP, the Particle cloud, and finally the pushbullet servers.

Not only your phone

Since Pushbullet supports a number of devices (more on that here), you can also receive your notifications in your laptop, to name one. This comes pretty handy for those times when your phone is in your pocket and you happen to be in front of your laptop.

And not only notifications

You can use pushbullet for many other things, like sharing links between your laptop and your phone. Got a map in your browser? send it to your phone and off you go. Got a nice page in your phone that deserves full screen reading? send it in a blink to your browser. You can also share very big files locally in your network between your phone and laptop or even write SMS from your browser.

All this is pretty interesting stuff, I encourage everybody to try the pushbullet app.

now, where were we? oh yes, the article...

That's it!

Right now, every time your particle publishes something, you will get a push notification to your phone:

Notes

  • IFTTT Maker Channel: if you are using the maker channel your hardware is already set. Just make your recipes use the pushbullet channel and you are ready to go.
  • multiple destinations: this article covers the case where you and only you want notifications from your hardware. But what if you want your phone AND your wife's phone to receive them (quick example: laundry is finished). I will write an article on how to do this soon. UPDATE: I got around to write the article and you can find it here.

Final words

Due to superior UX behavior, I now recommend the use of the Pushbullet channels instead of this mechanism. Please find the article I wrote here.

The end

Hope you liked it!

Feel free to visit my projects to get real examples on how I use this mechanism.

Gustavo

Psst: please find my other projects here.

Help

If you require professional help with your projects, don't hesitate to write me a line about your needs at gusgonnet@gmail.com. Thank you!

Code

webhook

You need to configure this in the Particle cloud following the instructions above

Credits

Photo of gusgonnet

gusgonnet

If you need professional help with a project, contact me at gusgonnet@gmail.com

   

Leave your feedback...