Sending compass sensor info to laptop via Bluetooth

199 views
Skip to first unread message

Joao Barcia

unread,
Sep 26, 2016, 8:43:29 AM9/26/16
to DroidScript
Hi everyone, I would like to code a simple program that would send (either continuously, or upon pressing a button on the screen) the compass coordinates (lat, long, bearing) to a laptop via bluetooth. Is DroidScript suitable for this? I will start working on this project next week, just wanted to be sure if I should invest time with DroidScript, or consider an alternative.

Thank you very much!

Dave Smart

unread,
Sep 27, 2016, 6:39:11 AM9/27/16
to DroidScript
Hi Joao,

It depends on what you are planning to do on the laptop end.  DroidScript can talk via Bluetooth Serial or Bluetooth LE, but you might want to consider using WebSockets if you have a Wifi access point available (or running on your laptop).  

What are you going to code the PC end in?

You could simply run a browser on your laptop (if you have Wifi available) and then run a web server inside DroidScript. 

Regards
David

Joao Barcia

unread,
Oct 5, 2016, 6:32:20 AM10/5/16
to DroidScript
Hi Dave,

Thanks for the quick reply. Turns out "email updates to me" wasn't turned on by default so I just got to see your reply now.

The plan is to use droidscript to send GPS and Compass info to a laptop. Another source connects to the laptop to give distance to a remote object. The laptop calculates GPS coordinates of the remote object and stores it.

Is there any straightforward way to calculate the compass true north value from the magnetic sensor?

Cheers

Dave Smart

unread,
Oct 5, 2016, 4:56:22 PM10/5/16
to DroidScript
Probably best to use the 'Orientation' sensor.


Getting true north from the magnetic north (azimuth) value might not be straight forward though.  You might need to hunt for a JavaScript function to do it for you.

We probably need to add it DS in the future like this:-


Joao Barcia

unread,
Oct 6, 2016, 4:14:52 AM10/6/16
to DroidScript
Hi Dave,

Exactly. After some research it turns out that it seems that good compass programs actually use a mix of the Magnetometer, the Orientation sensor, GPS and some calculations about magnetic deviation (which I didn't know existed until today https://en.wikipedia.org/wiki/Magnetic_deviation).

Will take a look at it. Thanks
Reply all
Reply to author
Forward
0 new messages