element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi Projects
  • Products
  • Raspberry Pi
  • Raspberry Pi Projects
  • More
  • Cancel
Raspberry Pi Projects
Blog Alert from Raspberry pi to Android
  • Blog
  • Documents
  • Events
  • Polls
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi Projects to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: camuyano
  • Date Created: 26 May 2014 3:42 PM Date Created
  • Views 2447 views
  • Likes 0 likes
  • Comments 0 comments
  • android
  • raspberry
  • raspberry-pi
  • raspberrypi
  • raspberry_pi_projects
Related
Recommended

Alert from Raspberry pi to Android

camuyano
camuyano
26 May 2014

Always wanted to send push notifications from an embedded device into my phone and I wanted it to be easy and free. Google have the API with no quota for free and then a friend recommended me a web hosting site that offers free small apps hosting. So with all pieces in place finally decided to put words into code. Just released an app into the play store to do just that, the app has a web component written in python and hosted in a free account at heroku.com. App has not be tested carefully but then again, nothing is in the hacking community. Better to have something that nothing, bugs and enhancements can be latter added.

image

 

The concept is.

Create a message on the embedded device triggered by a simple action event. It may be a sensor read or other condition. Then post a message to the server with the desired text. That message is then pushed into the phone, For this there is a web API I created using python and Flask and from there the message is forwarded to the google cloud messaging site to get pushed into your phone.









The FUN PART, How to use it:

1. Install RemoteAlert on your phone (available for free from Google play store) (https://play.google.com/store/apps/details?id=com.soy.remotealert)

2. In the app you are prompted with your device UniqueId. That id is arbitrary created within the app, so it means nothing outside of RemoteAlert.

3. Using the UniqueId from the app just issue a post with a json containing the message you want to show on the device.

 

Sample Code:

After installing the app in your phone will see an screen similar to this:

image

Using the orange id from the above image you may issue a simple post to send a message.

Example using a curl command from the shell (you can just run this on the shell of any computer that has curl)

curl -X POST -H "Content-Type: application/json" http://remote-alert.herokuapp.com/post/a32b831c-7623-4c43-99cf-b614ff54e902 -d '{"message":"Hellow Push Message World"}'

 

A python sample will look like this:

import json

import urllib2

 

class RemoteAlert:

    def send(self, device_id, message ):

        data = { 'message' : message }

        url = 'http://remote-alert.herokuapp.com/post/' + device_id

        req = urllib2.Request( url )

        req.add_header('Content-Type', 'application/json')

        urllib2.urlopen(req, json.dumps(data))

        return 'OK'

 

ra = RemoteAlert()

dev_id = 'a32b831c-7623-4c43-99cf-b614ff54e902'

 

print ra.send(dev_id, 'Hellow Push Message World')

 

This is how the received message looks like:

image

 

A simple POST with a JSon body with the mesaage is all it is needed. You may use https if you prefer is the same

http://remote-alert.herokuapp.com/post/<device_id>

{ "message" : "There you go" }

 

You may use the language of preference for this, C#, ruby, C++, perl, etc etc etc. And this can be used from anywhere not just an embedded computer. For example you may have an script on your PC start up to send you a message if somebody logged into your computer. Or a script on your raspberry pi that sends you your public IP when it changes...

This is a work in progress and software projects are never finished but just wanted to put it out there so anybody can use if wanted. All code will be posted open source to freely use. You may print it all into a shirt or a bed cover it will be public. There is nothing special in the code and that's the idea. We all should have basic features for free at least to hack away and learn.

More sample codes to come. Planning on adding some sample to push notifications directly from an arduino, if the web API needs to be changed for that it will be change. Adding the notifications straight from the arduino will make this even more fun.

The app is free, no personal info, no registration/login required. As long as there is free web hosting this will be online.

No message are stored on the server and no personal info. The android app has no sign in, there is no special permissions except the network access because without internet this will not work.

Said that, I would not recommend nobody to share confidential data using this. This app has no error correction, it just sends a message to the google cloud messaging to get push into your phone as soon as you post it. However the Google Cloud Service do not push the message to the phone instantly, from testing I have seen that messages may take close to a minute to get to the phone. Normally I get the messages in 20 secs more or less (haven't time it carefully).

If anybody use it, add a comment bellow so others in the community can benefit, be gentle but if it does not work please post it as well. Save time to others if you do not like it, or vice-versa.

 

Sample video just to have an idea of how much time it takes for the message to be sent and received. Un-edited just to show a real world sample of the time it took.

Code from the video: https://github.com/soynerdito/RaspberryPiTalk/blob/master/in_out_sample/push_no_block_event_led.py

library https://github.com/soynerdito/RaspberryPiTalk/blob/master/in_out_sample/remotealert.py

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

Hope this can help others, this is just a simple project put together to help me do other projects faster. I will blog again in progress and features, take care to all!

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube