> For the complete documentation index, see [llms.txt](https://iot.datalit.de/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://iot.datalit.de/appendix/other-sensors/sound-pressure-sensor.md).

# Sound Pressure Sensor

Working with a [Sound Pressure Level](https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Sound_Pressure_Level.html) sensor works as described in the general article on [how to use sensors](/2-internet-of-things/iot-in-our-apps/program-the-devices/sensors.md). In this article, we assume you have successfully initialized the devices with the [Tinkerforge Device Manager](/2-internet-of-things/iot-in-our-apps/connect-to-devices/the-tinkerforge-device-manager.md), and you stored all connected devices on a global variable `devices`. We also declared a global variable called `sound`.&#x20;

Next, we need to know the device identifier, which **290**:

```javascript
// Get the sound pressure level sensor via its device identifer
sound = devices.getDeviceByIdentifier(290);
```

Once we have a reference to the sensor, we can register a callback function:

```javascript
// We want to be informed when a new sensor value arrives
sound.registerListener(soundChanged);
```

Of course, we have to actually define the function:

```javascript
function soundChanged(val) {
   // Do something with the value object
}
```

## Reading the sound pressure level

Instead of just one single value, the sensor delivers four different values:

1. Sound level in decibel
2. Spectrum length
3. Spectrum chunk offset
4. Spectrum chunk data

We can access the array of value via the `val` object:

```javascript
function soundChanged(val) {

    // Get the decibel value
    var decibelValue = val.getValue("decibel_value");
    
    // Check if this actually was decibel event, if not we get -1 as result
    if(decibelValue !== -1 && decibelValue.type === "decibel_value") {
        log("Decibel: " + decibelValue.value)
    }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://iot.datalit.de/appendix/other-sensors/sound-pressure-sensor.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
