Tutorial: Use all Android sensors of your phone via websockets (All source incl.)

It will empower you to do -for example- things like this:

See also: VR Mech Simulator - YouTube
But this time for Armory3D!

If you figure out how to interpret the real time data stream from your phone, you can use it as an awesome input device. As it seems that there is some quite heavy math involved, i decided to publish it now and don´t let you wait until me slowpoke has figured out the math to rotate the default cube according to phone movement. If someone is good and fast at math, you are welcome to see this as a little challenge (see game_rotation_vector, me scratch head, hmm quaternion maybe?) to further develop it. It is also a demo for websockets and how to access other computers on your network.

How-to for Linux:
Should also work on legacy OS (Win, Äppel). Its just that i don´t like to support this yesterday sh :smile:

Get my blend, bundled canvas and install GitHub - umer0586/SensorServer: Android app which stream phone's motion sensors to websocket clients ( PC , raspberry pi , arduino , webbrowser etc ) over Wi-Fi , USB and device's Hotspot.

Sensor server apk compiles fine using git clone, but he also offers a readily made apk. Min. Android 5.
Good if you happen for example to have an old S5. They are packed with all kind of sensors.
Phone and PC must be logged in to the same WLAN.

Install and run Sensor server. Read IP and choose sensor name, paste it in the blend node setup as client addresses.
It should work with all offered sensors.

I open up a new client for every sensor. Does anybody know how to do this more elegantly?

Optional support commands under Linux (not necessary as phone app shows ip address at server start)

Scan and show all connected computers on your WLAN.
nmap -sP

Find IP address of your phone
Deactivate WLAN on your phone, run above command, note ip addresses.
Activate WLAN and run again. Note difference.

Ip route
Shows you which one is your router. You do not want to mix up your phone with the router.

Note: If you stopped the connection for more than some minutes you will probably have to stop and restart the server on your phone.

WS_android_sensors_WLAN_2_values.blend (945.4 KB)
Bundled.zip.hx (3.9 KB)
License: Zlib

Note: In order to use all the sensor data on your phone app after development open settings in the sensor app and activate local host. Replace remote address with local host one in Blender before you generate the Android source. Then compile and upload. This renders the sensor app a requirement to run your software on Android. But, hey, at least it works.


It would be great if someone could convert this into a video as I really have no idea what I’m doing with networking but this is the sort of thing people tag me all the time asking for tutorials. HELP!!!???

1 Like

Hi, that´s what i thought when i was writing the tutorial. As it is not really intuitively evident an additional video would be really nice. While a video attracts a certain audience and might help them in the beginning, i feel tinkering with the node setup is needed for a deeper understanding. I recommend doing the same with the new official network example.

Once i understood how it interacts and which possibilities it opens, my motivation was rising exponentially. You can control a house, a workshop or even a factory line with it. Like using a virtual cable with or without wires. If someone has the time and patience to help making a video tutorial for this, I´d be willing to help as much as i can. Maybe a little script from my side, helping to explain the node setup, would come in handy.

People who tried it out are welcome to post here and tell me about it. If someone is stuck and needs more info on some subject, i will try to help. I also need the feedback in order to get ideas and motivation for better tutorials…

1 Like

Found a better client for testing and debugging connections. I used something like that during the development of my above example. It is on Github and also Online available.

Of course you can only connect to hosts/servers with that. But the connection can be simultaneous with others. I just saw that i submitted a wrong Github link and did correct it.