I need to connect to a Raspberry-pi from an Android, over a long distance (so via the internet).

My aim is to switch a controller circuit from a remote location, by using internet and android app.

In this case, there are N number of circuit and N number of user mobile. Every circuit will have their dedicated Android mobile app.

I need a protocol that will pass the command from android app to Controller circuit, then the circuit feed back to Android app. I use Python for the server scripting.

The android app and RPI are not in same network, therefore I can not make direct communication between them. For example, Consider, Subhankar has a home automation system in Delhi, and right now He went to London, but he has to start and stop his "water pump" daily, by remote control. This case Subhankar has the "android app" and his home automation system has "Raspberry pi".

Which communication protocol will be best to achieve this?

  • I am not understanding which part of the communication you are asking about, is it: between android-app and control-circuit, between android-app and remote-server, or other? – ctrl-alt-delor Apr 22 '19 at 18:19
  • "Between android-app and control-circuit." The commands must reach at control circuit, from the android app. – Subhankar Majumder Apr 23 '19 at 5:29
  • What is on the control circuit, what software is it running? – ctrl-alt-delor Apr 23 '19 at 8:09
  • In the control circuit block, There are a Raspberry pi. – Subhankar Majumder Apr 23 '19 at 9:58
  • In the control circuit block, There are a Raspberry pi. I will do some operation (in RPI) with the received command(received from android app), then RPI will send feedback to to android app. – Subhankar Majumder Apr 23 '19 at 10:06

If the Pi will be turning on and off the pump each day, then consider a simple timer. The Pi can be programmed to do this at the time that you want.

If you still decide to do it remotely, then consider ssh:


ssh is a secure protocol that is primarily used for remote shell sessions, but can also be used to carry any protocol.

E.g. it is used by github and bitbucket to carry git, subversion and mercurial. It can also be used to tunnel X11, or to forward ports between machines: this allows it to be used my applications that know nothing about it,

ssh will create one connection, per client, so clients can be identified by their connection.

You may also want to look at insecure TCP communication, and combine it with ssh (to make it secure). This bit is about what the messages are, the ssh will then make it secure.

|improve this answer|||||

Finally I got solution of my problem.

There is an interesting protocol 'MQTT'. This is the best option for a client to client communication.

Thanks to all for ur valuable concern to my post.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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