I'm creating a project that will notify a users Android device when their plant needs to be watered. I'm building the Android app myself using Android Studio. I'm using a Grove Pi moisture sensor to record the readings from the Pi coded in Python. I'm also using a USB WiFi dongle for RPi internet connection.

My problem is I'm not sure how to get the android application to access the information recorded from the Pi. Should I be using an intermediate server that the Pi posts to and the Android device reads from? If anybody could tell me what to do I would be eternally grateful and forever in your debt.

Thanks :)


closed as too broad by goobering, joan, Milliways, Dmitry Grigoryev, Jacobm001 Feb 7 '17 at 23:30

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.


Either option can work...

Store The Info On The Pi

For this the Pi will have to be accessible from the public internet (assuming you are not wanting it to alert only when the Pi and Android device are on the same network.

To make it publicly addressable you'll need a static ip (or dynamic dns client) and a domain name. It will also likely require port forwarding on your firewall/router - so that when the Android app checks http://yourdomain.com/doesmyplantneedwatered it can actually resolve where to find that server (your Pi) and connect to it.

Likely a web server on the Pi, which responds with the yes/no indicator.

Store The Info On a Public IoT Data Logging Service

This is arguably the slightly easier option. You create you own channel at one of the many IoT data logger services - this will hold the status on the plant (e.g. 0 = I'm fine, 1 = I need water) Write some code/script on your Pi to regularly grab the data from the sensor and send it to your channel - which can be achieved with something as simple as a curl POST.

The Android app checks the channel (parse the response to a simple http GET request) and alert as needed.

A couple of popular data loggers are https://data.sparkfun.com/ and https://thingspeak.com/

  • Sort of a separate answer, but also sort of a "1.b" option here: If the app only has to work locally, you could use a custom broadcast to discover the pi a la zeroconf/avahi, etc. (I think only Android 5+ actually implements zeroconf proper, something to investigate since it would make things easier). No static ip, no need to configure the router. – goldilocks Feb 7 '17 at 12:39
  • @goldilocks Good point. I'm not sure about zeroconf/avahi on android though - I've not had it work successfully on 5, 6 or 7.... but maybe that's just me :-) – KennetRunner Feb 7 '17 at 12:42
  • Neither have I but I did not try hard (port scanners apps will pick up on it -- awkward). I noticed the thing about Lollipop in someone's blog when I did a quick search to double check this: medium.com/@_tiwiz/… – goldilocks Feb 7 '17 at 12:45
  • Thanks for your clear and concise response, I will have a think about both options and then decide on an approach :) – Jack Haymes Feb 7 '17 at 12:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.