> ## Documentation Index
> Fetch the complete documentation index at: https://docs.neuro-tech.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Read a sensor

> Make a first read using the Agent Things JavaScript API

This guide reads momentary values from one standalone device. It assumes the device already exists; creating and provisioning device firmware is a separate task.

## Before you start

Obtain:

```text theme={null}
Neuron host: https://neuron.example.com
Account:     <username and password>
Device JID:  sensor@example.net
```

The account must be able to communicate with the device, and the device's provisioning rules must allow sensor readouts. An address alone does not grant access.

## 1. Load the client libraries

Create a development page served over HTTPS:

```html theme={null}
<!doctype html>
<html>
  <head>
    <meta charset="utf-8" />
    <script src="https://neuron.example.com/Agent.js"></script>
    <script src="https://neuron.example.com/Agent.Things.js"></script>
    <script src="https://neuron.example.com/Events.js"></script>
  </head>
  <body>
    <pre id="output">Open the browser console and run the example.</pre>
  </body>
</html>
```

For a page on another origin, the Neuron must allow that origin. Set the API host before making requests:

```javascript theme={null}
AgentAPI.IO.SetHost("neuron.example.com", true);
```

## 2. Sign in

In the browser developer console:

```javascript theme={null}
await AgentAPI.Account.Login("<USERNAME>", "<PASSWORD>", 3600);
```

The library keeps the JWT in browser session storage. Do not put the password or token in the page's source.

## 3. Read momentary fields

```javascript theme={null}
const result = await AgentAPI.Things.Sensor.ReadStandaloneDevice(
  "sensor@example.net",
  "en",
  true,  // momentary
  false, // peak
  false, // status
  false, // computed
  false, // identity
  false, // historical
  [],    // all allowed fields
  null,  // from
  null,  // to
  null   // when
);

console.log(result.Fields);
console.log(result.Errors);
```

Success means `result.Fields` contains one or more values, or the device returns a valid empty readout. Preserve each field's timestamp, unit, type, and quality information.

## If the read fails

* **Authentication error:** confirm the Agent API login first.
* **Device unavailable:** verify the JID, roster relationship, and device connection.
* **Forbidden or empty result:** review provisioning for this account and field set.
* **Browser CORS error:** host the page on the Neuron or allow its exact origin.

Next, learn the [device model](/iot/device-model) before addressing concentrator nodes, or see [sensor data](/iot/sensor-data) before requesting historical or subscribed values.
