A Step by step guide on configuring ThingSpeak to auto post to PushBullet, I use ESP8266’s but the you can use this for anything posting to ThingSpeak.

I’ve been messing with the ESP8266 chips, a really cheap Wifi SoC that can be used with Arduino, but also with the right firmware can be used on their own without a master control processor.

There are lots of examples of doing this, I use the nodeMCU firmware, along with ESPlorer to write the code in lua to program the ESP8266.

NOTE:These 8266-01 versions are cheap and everywhere but do yourself a favour and look for an 03 or better the 12, they have more pins available and capable of deepsleep and are just as cheap.

The downside to all this is that the current firmware has no capacity for https connections, and much of the IoT web relies on https, else any crackpot could connect to your service as the API keys are being sent in the clear.  I really hope the nodeMCU people can add the http/sockets/https libs for lua into the firmware cos I failed, no time to ramp up knowledge to that level yet.

thingspeak

ThingSpeak, however lets you collect data using an API key but its done the in the clear, not exactly safe, but for many IoT devices a necessary evil.

And example of a temperature logger is on instructables.

My boy wants a gizmo that will notify him when someone goes into his room.  He has an android phone.  Rather than get my Ximian on and google notification services and all that painful stuff I just need some kind of Android Growl service.  In the past I used NotifyMyAndroid,  but since then I have been using a much better system called

you can send notifications to it without having the pain of writing your own App and notification hooks.  PushBullet is actually so much cooler than just notifications, I use it because it can examine notifications on your phone and relay them to a chrome plugin on the desktop, so I never miss texts and stuff when I cant hear my phone.

So the point of this article is to figure out home to send information to PushBullet via ThingSpeak.  This is really a part two to an article I haven’t written yet, but as the instructable article has already described how to program an 8266 and post to ThingSpeak I will expect you to have done that and we continue from there.

I have created a channel called PushBulletTrigger. It doesn’t really do anything except take a “Field1” input, which I only ever send a value of “1” to.  Because In my instance I only ever log something to ThingSpeak if the detector sees someone in the room.

Of course on your project you can use any existing channel and check any field for a value in that to trigger a notification.

 

 

 

Next we need to create the ThingSpeak App based on “ThingHTTP”. Click on Apps in the Menu bar and then the thinghttp

 

 

ThingHttp Icon

 

You will need your pushbullet API key here, but the rest I’ve already figured out from the API docs so you can copy pretty much all of this.

Give a good name I chose PushBulletAppSend, and set the URL that you need to connect to in our case

https://api.pushbullet.com/v2/pushes

Set the Method to POST

Set the Content Type to “application/json”

The HTTP version is 1.1

The host is api.pushbullet.com

We need to add a header name = Authorisation

and the value for that is

“Bearer [PushBulletAPI]”

No quotations and the space is important.

Lastly the Body

{“type”: “note”, “title”: “IOT Message”, “body”: “Detector Triggered”}

You can set the title value and body value to what you want.  I haven’t figured out how to replace the values so if you want different messages and title then create different ones per message type.

So now we can log into ThingSpeak and we have something that can call into PushBullet which will send a notification to an Android OR iPhone.

Lastly we need to tie these things together and we do this also inside ThingSpeak.

react

To do this click on the Apps menu option at the top

and then on the React Icon

 

 

Name the React, ReactToPushBulletTrigger

We are testing a string so the Condition Type is String

We are testing on every Insertion, other options are on timers

Our condition is Channel “PushBulletTrigger” this is the Channel that logs data to thingspeak.

Then we test Field1 = 1

if this is true we call into the ThingHttp by setting the Action to ThingHttp and selecting our React “PushBulletAppSend”

Save it.

That’s it.

Now whenever your IoT device sends a piece of data into ThingSpeak, ThingSpeak will automatically relay a post to PushBullet and in turn notify your devices.

So thing to remember here is that ThingSpeak API allows for a data post every 15 seconds,  so if you’re dumb enough to post every 15 seconds and have tied a react event to it, you could very well swamp your mobile with notifications and drive yourself insane.

In my version of the 8266 code, I have utilised the tmr events to only notify a maximum of once every 30 minutes, if the rooms been empty for 10 then it will notify immediately.  But as I haven’t built the circuit board properly I’m waiting before I do a post on this, as I have to yet source 3.3v regulators, figure out how to boot the device with an active low state on the GPIO pins without sending the 8266 into firmware mode.  It may be I have to wait till I get my 8266-12’s  instead of the 01’s I’ve been using.

 

Advertisements