Page 1 of 1

Using Android Sensors

Posted: Thu Nov 24, 2016 2:57 am
by WisdomWarlord
Is there a way to report to Raspberry Pi the readings of the various sensors in an Android phone? I'd love to give my Pi project the GPS, compass, gyroscope, accelerometer and light sensor from an Android phone, instead of needing all of those sensors connected to the GPIO pins.

Re: Using Android Sensors

Posted: Thu Nov 24, 2016 6:23 am
by DougieLawson
Not easily. You're going to have to write a custom built Android app that delivers the data in a consumable way. That's the not primary development goal for Android apps (they're intended to do funky stuff on the phone, not to emit sensor data).

Best of luck, with that.

Re: Using Android Sensors

Posted: Thu Nov 24, 2016 8:29 am
by bensimmo
There are many sensor reporting apps on android.
There is even the Google made experiment one.
There is one that is good for graphing.

I can't remember what their names are of hand.

I don't know if any open a socket to collect the data externally, they do make text files etc.

Used in eduction as they are a good source of sensors.


Just had a quick look
AndroSensor and Evothings Viewer (and studio) are ones me ruined and used in Education papers. But not while also using a Pi.
Worth a look at though, they may do or be able to help.
Or see if some of the Pi android App develops know or can help you out.

Re: Using Android Sensors

Posted: Thu Nov 24, 2016 8:37 am
by bensimmo
Another option, though no GPS, is the micro:bit for Bluetooth sensors access.

Re: Using Android Sensors

Posted: Thu Nov 24, 2016 8:50 am
by sandcrabjarv
Ive been playing with qpython on my android tablet sending the sensor data over bluetooth the pi being the server. Made a basic mouse with it, not finished it yet though. It as been easy enough :)

Re: Using Android Sensors

Posted: Thu Nov 24, 2016 9:36 am
by mattmiller
Its one of those things that certainly possible and easy to do - OOTTOMH -Scratcher Control does it to feed data into Scratch - Sensor Node Free does the same to provide MQTT messages.

Main consideration if to what sensor info you want and how fast/slow you need it so you could end up needing to write a custom 'droid app and a custom way of communicating the info yo your Pi

Re: Using Android Sensors

Posted: Sun Feb 12, 2017 12:53 pm
by MrLunk
Hi there,

I see this is an older thread but Let's share the solution I use / found :)
This worked for me...

I use this Android app:
https://play.google.com/store/apps/deta ... or4scratch

Manual:
http://koutsonikos.weebly.com/uploads/9 ... d_app_.pdf

Since I am on a home network behind a firewall I could skip all the iptable stuff. And because Scratch runs on Raspbian jessie on the RBpi3b in the same network asswell as my Android device, no configuring of the windows firewall needed ;)

Good luck all ;)

Rasb-noob:
Peter Lunk

;)

Re: Using Android Sensors

Posted: Sun Feb 12, 2017 4:01 pm
by hippy
I have used App Inventor 2 to create Android programs which can report button pushes, sensor and other data as GET/POST requests to a HTTP server on a PC using TinyWebDB. It would be easy enough to create a Pi-based server

App Inventor 2 makes it incredibly simple to create Android programs and those also run on a Pi3B under AndroidThings. Took me a minute at most to have my Android phone reporting sensor data back to my PC. As simple as ...
ai2.jpg
ai2.jpg (60.14 KiB) Viewed 4184 times

Re: Using Android Sensors

Posted: Sun Feb 12, 2017 6:10 pm
by mattmiller
Took me a minute at most to have my Android phone reporting sensor data back to my PC
Inc setting up database and webserver on your PC - impressive :)

Re: Using Android Sensors

Posted: Mon Feb 13, 2017 4:52 pm
by hippy
mattmiller wrote:
Took me a minute at most to have my Android phone reporting sensor data back to my PC
Inc setting up database and webserver on your PC - impressive :)
No, that was written long ago. I just display and discard the data received so all I had to do was start a new AI2 project, add the sensor, create the 'When' block, generate and save the .apk, side-load that to my phone and it just worked.

The data sent is simply a POST to http://www.xxx.yyy.zzz:80/setvalue with the posted data being tag="accelerometer"&value="1.23,4.56,7.89" so not hard to deal with. One can even have it so the URL includes all the data so no need to handle the posted data, just parse the URL.