# Getting noise data into sensor.community

**URL:** https://forum.sensor.community/t/getting-noise-data-into-sensor-community/828
**Category:** Feature Requests
**Created:** [September 5, 2021, 12:56pm UTC](https://forum.sensor.community/t/getting-noise-data-into-sensor-community/828 "2021-09-05T12:56:49Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![Roland](https://forum.sensor.community/letter_avatar_proxy/v4/letter/r/3ab097/32.png) [@Roland](https://forum.sensor.community/u/Roland)
#### Post date: [November 8, 2023, 1:45pm UTC](https://forum.sensor.community/t/getting-noise-data-into-sensor-community/828/6 "2023-11-08T13:45:58Z")

</div>

I have just completed my ESP32 noise sensor based on [LoRaSoundkit](https://github.com/meekm/LoRaSoundkit). I forward the TTN data to my own server und from there via logstash pipeline to the [API](https://api.sensor.community/v1/push-sensor-data/). The tricky think was to find the logstash commands to build the JSON structure.

```auto
input { pipeline { address => "sensor.community-noise" } }

filter {
  # process data for sensor.community
    mutate {
      add_field => ["[@metadata][app_id]", "%{[end_device_ids][application_ids][application_id]}" ]
      add_field => ["[@metadata][device_id]", "%{[end_device_ids][device_id]}" ]
    } # mutate
  #

  # BEGIN device specific configuration section
  # each TNN device (sensor) requires one configuration section
  if ([@metadata][device_id] == "YOUR-TTN-DEVICENAME") {
    mutate {
      add_field => { "[@metadata][send_data]" => "true" }
      add_field => { "[@metadata][sensor]" => "YOUR-NODE-ID" }
    }
  }
  # END device specific configuration section

  if ([@metadata][send_data] == "true") {
    mutate {
      add_field => { "software_version" => "1.0" }
    }

    ruby {
        code => '
          event.set("sensordatavalues", [
            {"value" => event.get("[uplink_message][decoded_payload][la][avg]"),"value_type" => "noise_LAeq"},
            {"value" => event.get("[uplink_message][decoded_payload][la][min]"),"value_type" => "noise_LA_min"},
            {"value" => event.get("[uplink_message][decoded_payload][la][max]"),"value_type" => "noise_LA_max"}
          ] )
        '
    }

  } #if

  mutate { remove_field => ["app_id","@version","@timestamp","host","received_at","_source","headers","correlation_ids","uplink_message","end_device_ids"] }
} # filter

output {
# curl test command to upload parameters
# curl --location --request POST 'https://api.sensor.community/v1/push-sensor-data/' --header 'Content-Type:application/json' --header 'X-Pin:15' --header 'X-Sensor:YOUR-NODE-ID' --data-raw '{"software_version": "1.0", "sensordatavalues":[{"value_type":"noise_LAeq","value":"21.21"},{"value_type":"noise_LA_max","value":"22.22"}, {"value_type":"noise_LA_min","value":"23.23"}]}'

  if ([@metadata][app_id] == "YOUR-TTN-APPLICATION-ID" and [@metadata][send_data] == "true") {
    http {
     url => "https://api.sensor.community/v1/push-sensor-data/"
     #url => "http://localhost:1099"
     http_method => "post"
     format => "json"
     headers => {
       "X-Pin" => "15"
       "X-Sensor" => "%{[@metadata][sensor]}"
     }
    } # http

   # for DEBUG only
   # file {
   # path => "/tmp/sensor.community-%{[@metadata][device_id]}.log"
   #
    #}

  #stdout { 
  # codec => rubydebug { metadata => true } 
  #}
 } # if [@metadata][app_id] 
} # output

```

The community version of Logstash is available at [Download Logstash Free | Get Started Now | Elastic](https://www.elastic.co/de/downloads/logstash).

The ESP32 consumes 35 mA in the middle and now I will connect the device to my [solar based PM sensor](https://opensensemap.org/explore/60c14256b2a183001cd39959).

I send the noise data also to [opensensemap](https://opensensemap.org/explore/653e2f3d6e2d820008c9ec1a) with a second logstash pipeline.

---

_[View the full topic](https://forum.sensor.community/t/getting-noise-data-into-sensor-community/828)._
