11-01-2017 04:40
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

11-01-2017 04:40
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
Hi,
Has anyone tried using the Orientation Sensor?
I haven't been able to get the sensor to work.
Would love some sample code if possible.
Thanks heaps in advance,
Echo
11-01-2017 07:15
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

11-01-2017 07:15
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

11-01-2017 15:52
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

11-01-2017 15:52
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Thanks Allan for your reply.
I've got the Accelerometer working. I'm talking about the OrientationSensor API.
I'm trying this as there also seem to be problems with the Gyroscope as well.

11-02-2017 02:33
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

11-02-2017 02:33
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

03-03-2018 13:07
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

03-03-2018 13:07
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Same happens to me:
const orientationSensor = new OrientationSensor(); setInterval(() => { console.log(orientationSensor.readings); if (orientationSensor.readings) { const { quaternion } = orientationSensor.readings; console.log(quaternion); if (quaternion) { console.log(quaternion.join()); } } }, 1000);
Prints forever:
[22:06:21]undefined app/index.js:28,1 [22:06:22]undefined app/index.js:28,1 [22:06:23]undefined app/index.js:28,1 [22:06:24]undefined app/index.js:28,1 [22:06:25]undefined app/index.js:28,1 [22:06:26]undefined app/index.js:28,1 [22:06:27]undefined app/index.js:28,1 [22:06:28]undefined app/index.js:28,1 [22:06:29]undefined app/index.js:28,1 [22:06:31]undefined app/index.js:28,1 [22:06:32]undefined app/index.js:28,1 [22:06:33]undefined app/index.js:28,1 [22:06:34]undefined app/index.js:28,1 [22:06:35]undefined app/index.js:28,1 [22:06:36]undefined app/index.js:28,1 [22:06:37]undefined app/index.js:28,1 [22:06:38]undefined app/index.js:28,1 [22:06:39]undefined app/index.js:28,1 [22:06:40]undefined app/index.js:28,1 [22:06:41]undefined app/index.js:28,1 [22:06:43]undefined

03-06-2018 16:49
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

03-06-2018 16:49
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hi Sergius,
Sorry for taking so long to respond, busy days.
I'm working on the orientation sensor these days. Once I have more information I'll share here.
Eddie

05-11-2018 05:44
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

05-11-2018 05:44
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hi,
any news?
Thank you.
Regards,
Mark

05-11-2018 12:57 - edited 05-11-2018 12:58
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

05-11-2018 12:57 - edited 05-11-2018 12:58
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Have you tried the example in the sensor guide?
It uses onreading plus it starts the sensor orientation.start() which it needs for operation otherwise you are just reading an empty record. Also it sets the interval so you should not need to use setInterval().
import { OrientationSensor } from "orientation"; let orientation = new OrientationSensor({ frequency: 60 }); orientation.onreading = function() { console.log("Orientation Sensor Reading: " + "timestamp: " + orientation.timestamp, "quaternion[0]: " + orientation.quaternion[0], "quaternion[1]: " + orientation.quaternion[1], "quaternion[2]: " + orientation.quaternion[2], "quaternion[3]: " + orientation.quaternion[3]); } orientation.start();

