# Class «sensor»

{% hint style="info" %}
This article is automatically translated from Russian by Google Translator.
{% endhint %}

Represents a sensor (analog or digital) connected to ports A1, ..., A6, D1, D2.

| Method                                                                            | Description                                                                               |
| --------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| [read](/en/trik/programming-code/object-brick/class-sensor.md#read)               | Returns the current reading of the sensor (digital or analog) connected to this port.     |
| [readRawData](/en/trik/programming-code/object-brick/class-sensor.md#readrawdata) | Returns the current raw reading of the sensor (digital or analog) connected to this port. |

## read

Returns the current reading of the sensor (digital or analog) connected to this port. The present value is returned, depending on the port configuration, which is described in the file `model-config.xml` in the `trik` folder on the robot.

For example, the IR distance sensor returns a value in centimeters.

#### Syntax

{% tabs %}
{% tab title="JavaScript" %}

```javascript
var data1 = brick.sensor(sensorName).read();
var data2 = brick.sensor("sensorName").read();
```

{% endtab %}

{% tab title="Python" %}

```
data1 = brick.sensor(sensorName).read();
data2 = brick.sensor("sensorName").read();
```

{% endtab %}
{% endtabs %}

## readRawData

Returns the current raw reading of the sensor (digital or analog) connected to this port. The range of values depends on the specific sensor and does not take into account the configuration of the robot (the physical readings of the sensor are returned, e.g. the delay of the received ultrasonic signal).

#### Syntax

{% tabs %}
{% tab title="JavaScript" %}

```javascript
var data1 = brick.sensor(sensorName).readRawData();
var data2 = brick.sensor("sensorName").readRawData();
```

{% endtab %}

{% tab title="Python" %}

```
data1 = brick.sensor(sensorName).readRawData();
data2 = brick.sensor("sensorName").readRawData();
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.trikset.com/en/trik/programming-code/object-brick/class-sensor.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
