WisdomWarlord
Posts: 4
Joined: Mon Jan 21, 2013 5:59 pm

Using Android Sensors

Thu Nov 24, 2016 2:57 am

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.

User avatar
DougieLawson
Posts: 35813
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Using Android Sensors

Thu Nov 24, 2016 6:23 am

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.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
bensimmo
Posts: 4159
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Using Android Sensors

Thu Nov 24, 2016 8:29 am

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.

User avatar
bensimmo
Posts: 4159
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Using Android Sensors

Thu Nov 24, 2016 8:37 am

Another option, though no GPS, is the micro:bit for Bluetooth sensors access.

sandcrabjarv
Posts: 18
Joined: Sun Jun 26, 2016 8:06 pm
Location: UK, sheffield
Contact: Website

Re: Using Android Sensors

Thu Nov 24, 2016 8:50 am

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 :)
https://www.facebook.com/SandcrabJarv/ non-ferrous metal casting

mattmiller
Posts: 2101
Joined: Thu Feb 05, 2015 11:25 pm

Re: Using Android Sensors

Thu Nov 24, 2016 9:36 am

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

MrLunk
Posts: 4
Joined: Wed Feb 08, 2017 4:46 pm
Location: Netherlands
Contact: Website

Re: Using Android Sensors

Sun Feb 12, 2017 12:53 pm

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

;)

hippy
Posts: 5790
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Using Android Sensors

Sun Feb 12, 2017 4:01 pm

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 4107 times

mattmiller
Posts: 2101
Joined: Thu Feb 05, 2015 11:25 pm

Re: Using Android Sensors

Sun Feb 12, 2017 6:10 pm

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 :)

hippy
Posts: 5790
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Using Android Sensors

Mon Feb 13, 2017 4:52 pm

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.

Return to “Android”