sensors — sensors
10/22/22Less than 1 minute
The sensors module reads hardware sensor streams: proximity, light, gravity, orientation, and more. It only reads sensor data; Auto.js Pro does not spoof or inject fake sensor values or events.
Table of contents
Enums
Interfaces
Types
Functions
Types
Sensor
Sensor: AndroidSensor & SensorExt
The object returned by getSensor: Android’s Sensor plus helpers from SensorExt (e.g. enabling events).
Functions
getSensor
getSensor(name: string): Sensor | undefined
Looks up a sensor by logical name. Returns undefined if the device has no matching sensor.
Common names:
accelerometer— accelerationmagnetic_field— magnetometerorientation— orientation (legacy stack)gyroscope— gyroscopelight— ambient lightpressure— barometertemperature— temperature (often absent on modern phones)proximity— proximity / “distance”gravity— gravity vectorlinear_acceleration— linear acceleration (gravity removed)
For the full constant list, see Android Sensor.
Example
"nodejs";
const { getSensor, SensorDelay } = require("sensors");
const sensor = getSensor("light");
sensor.enableSensorEvent(SensorDelay.Normal).on("change", (light) => {
console.log(light);
});
$autojs.keepRunning();Parameters
| Name | Type | Description |
|---|---|---|
name | string | Sensor name string (see list above). |
Returns
Sensor | undefined
The sensor wrapper, or undefined if unavailable.
