Notification

DYI: Notifications from SGPro to an electricimp device

Posted on Updated on

This is a quick way to send notifications from SGPpro to a device. Depending on the type of message the SGpro sends to the device, the device will light up a certain color LED. I am using an electricimp, if you are nor familiar with this particular device start here. SGP sends emails with the following titles:

  1. SGPro Error
  2. SGPro Warning
  3. Test Message from SGPro
  4. SGPpro….Completed

The messages will be from SGPro through a mailgun account and routed to the electricimp. The imp will parse the message subject and accordingly will display:

  • Green – All good
  • Red – Error
  • Yellow – Warning
  • Blue – Test
  • All – Unknown message

First you need to setup a free mailgun account. Follow the steps in this post. After completing this step you need to set up a route. Effectively, mailgun receives your message then sends an HTTP Post with details to your imp. There are four parts:

  1. Hardware Setup
  2. Electricimp code
  3. Mailgun routing setup
  4. SGpro Setup

1. Hardware Setup

You need an electric imp device. I also connected a LiPo battery since I wanted it to be portable. However, that is not a necessary step as you can power your imp through USB. You can also put the device in a case to make it more visually appealing.

IMG_0737

Hardware list

  1. Electricimp
  2. Electricimp breakout
  3. Red,Blue,Yellow,Green Led
  4. Mini Breadboard
  5. Jumper wire
  6. Optional: Polymer Lithium Battery
  7. Optional: LiPo USB charger
  8. Resistors (I used 200KΩ)

There is plenty room to adjust components in the list. I just used my spare parts.

The first step is to assemble and power your electricimp. Read this.

Then connect your leds to the pins via a resistor as follows. Read this first.

  1.  Blue led goes to pin 7
  2. Red led goes to pin 8
  3. Yellow led goes to pin 9
  4. Green led goes to pin 5

All the cathodes are connected to ground.

IMG_0738

This step might take awhile, be patient.

2. Electricimp code

The imp uses an online IDE. Read this to understand how to setup and program the imp.

electricimp

My code is available here. Finally make a note of the agent’s address (the one circled) It should look like this:

agentimp

3. Mailgun routing setup

Before this step you need to have a mailgun account setup. See my post and follow instructions.

Now lets set up the routing options. Read more about routes here.  In mailgun, select the following routes:

Routes

Create a new route

Screenshot-2015-04-04-08.33.11

The rules are pretty simple.

  1. Filter Expression = sgp@xxxxx.mailgun.org
  2. Actions : Store(Notify:https://agent.electricimp.com/xxxxxxx

4. SGPro Setup

SGPMail

In SGPro add a new Address, which is the sgp@xxxx.mail.org. Press Test and you should see :

IMG_0740

Enjoy!!!! 😉

DYI: Notifications from SGPro to your iphone

Posted on Updated on

SGPro added notifications through email. This is a quick way to get notifications in Prowl (and Growl) on your iphone.

IMG_0736

First you need to purchase Prowl form the iTunes store here. Or through your iPhone’s store

You also have to have a mail account. I created a mailgun account so I do not clutter my main mailbox.

To create a mailgun account, and get the settings go to www.mailgun.com. Sign up for a free account. Then form the mail panel:

mailgun

You will be given API Keys and the default postmaster@XXX.mailgun.org account. You will need to create a new account.

click on activate:

maigunmailsettings

click Manage SMTP credentials

maigunaccount

and create a new account. I used sgp@xxxxx.mailgun.org and password. You will need this to configure the SGP mail settings

You next have to create a Prowl email account. So go to prowlapp.com

Prowl

Select API Keys and generate a new key. Name it SGPPro:

ProwlApi

And generate:

prowlkey

Now you have an API Email for your app (xxxxx@api.prowlapp.com). Now lets tailor it together.

Start SGPro and Select Tools/Configure Notifications/Settings

SGPMail

For address enter the prowl email you created above

SGPMailEncircled

and for you settings add the settings from your mailgun server.

Use smpt.mailgun.org for SMTP Server

Username and password are the ones you created  (sgp@xxxxx.mailgun.org)

SPGmailMailConfic

Press test and watch for the notification in your iPhone. Enjoy!!!! 😉