/ JS

Mobile sensor reading in JS

So i gave myself a mini project to look into sensor reading, with researching this on the internet it mostly told you ways of achieving it by writing an app on the device. However i was looking into doing it through a website using JS, this way any device can just access a website and receive there readings.

Link to project

What I've acheive is:

  • Accelerometer
  • Light sensor
  • Battery Reading

Each except from the battery reads updates in real time and displays it to the user in a minimal text based fashion using Google Web starter Kit for the UI and Jquery to power progress bars. The result is a basic site which tells you all the readings you need to know in a basic form.


Yes there was problems, but this is mainly browser compatibility issues. Only the Accelerometer readings work in all browsers, the rest will only work when running the Firefox browser. Though an error message will appear instead of null readings.

What have i learned?

That it is possible to get readings from some of the sensors on a device though it is limited only to the Firefox browser for now. With this you can use readings to automate site themes so if its dark you can swap to a dark theme.

The real purpose of this mini one day hack project was just to see if i can get readings and how easy it would be to take the readings display it and alter the information to do fun things.

In the future I will be looking to use what i've learnt to mess about with image alterations, multiple layer imagery (forgot name) or anything i can really think of.