tomlepham2010
Posts: 6
Joined: Mon Mar 28, 2016 4:40 pm

Raspberry Pi 3 and Android App

Fri Apr 15, 2016 2:58 am

Hello I am pretty new to raspberry programming, I would like to ask where to start if I wanted to write an android app to communication and control the raspberry through the wifi. Currently using android studio to write my app. Trying to explore the different methods to control and collect data from the raspberry to the app. I would prefer to avoid the web server method. Advice needed. Thanks.

User avatar
MarkHaysHarris777
Posts: 1820
Joined: Mon Mar 23, 2015 7:39 am
Location: Rochester, MN
Contact: Website

Re: Raspberry Pi 3 and Android App

Fri Apr 15, 2016 3:02 am

That totally depends on what you mean by control the PI via Android over wifi... many people do that every day, and they didn't have to write one line of code.

I communicate using my Android phone, over an openvpn connection to my home (using .ovpn file, 2048 bit ras des3 AES encryption) to my rasppi1 openvpn server... from there I can ssh to any of my wifi connected machines, including all of my rasppi(s) !

You have asked a huge question... what specifically are you looking to do?
marcus
:ugeek:

tomlepham2010
Posts: 6
Joined: Mon Mar 28, 2016 4:40 pm

Re: Raspberry Pi 3 and Android App

Mon Apr 25, 2016 5:46 pm

Let me be more specific, the project I am currently working on is writing an app to control my pi3. I would like to control it through wifi, meaning creating some sort of connection between the app and the pi through wifi. Anyone with the app can control the pi essentially. The project is door lock, so the app should be able to toggle a unlock/lock triggering the gpio pins of the pi3. Would like to add camera functionally, nfc access tokens from tags or android smart phone, access log, possible cloud database, and general alerts sent to app.

Most of the different functionalities of what I want the pi3 and the app to do require sorting and storing data, first off it will be specific for different user information. In each user profile there will have more database for access information and log, camera snapshot, alerts and etc. I am also confused about how to connect a database between users? Because I assume I will need multiple databases to store the information in different categories.

What I am confused about is the actual communication between the pi3 and the android app? So far all research showed creating a webserver to retrieved and send the data.
Do i need to set the pi3 as wifi hotspot?
Not sure if i should use a webserver of some sort, http, apache, rest or websockets?
Node.js?
Along with that the data interaction between the two devices, using either xml or json?

Just trying to wrap my head around the idea a little bit better.

ghans
Posts: 7882
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Raspberry Pi 3 and Android App

Mon Apr 25, 2016 5:57 pm

Can you guarantee that the Pi is always comnected to
the Internet ? The smartphone ?

Perhaps you can connect them to same wireless/wired/mixed
LAN ?

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

User avatar
DougieLawson
Posts: 39302
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Raspberry Pi 3 and Android App

Mon Apr 25, 2016 10:52 pm

tomlepham2010 wrote:
What I am confused about is the actual communication between the pi3 and the android app? So far all research showed creating a webserver to retrieved and send the data.
Your choice.
TCP/IP is probably the fundamental transport (layer 3) mechanism (unless you want to explore BlueTooth).

Then you have to pick the application protocol (layer 4).
HTTP (including websockets)
GOPHER
FINGER
TELNET
MQTT
FTP
SSH
SAMBA/CIFS
NFS
VPN
Roll-your-own (RYO)

That's the piece your professor is trying to get you to do so that you learn about the common layer 4 protocols and can describe a RYO protocol to show you understand the concepts.

Stop fussing about the hardware connection (layer 1), the IP transport (layer2) and the transmission control (layer3) stuff, that's the easy bit and is all about MAC addresses, IPv4 addresses, IPv6 addresses and port numbers. It's the same for most of the application layer TCP/IP users. (I'm ignoring UDP at the moment.)
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Return to “Beginners”