# Case 04: Urban noise detection Level: ![level](images/level2.png) ![auto_fit](images/Case4/case-04_1.png)

## Goal


Make a noise detection point to detect the noise volume near the roadside using noise sensor.

## Background


What is urban noise detection?

It is a system to detect noise near the road as noise pollution caused by cars on the road seriously affect the living standard of people. By installing a monitor to detect the noise volume near the roadside can help engineer to gather noise information and find solution to solve the problem in the future.

Noise detection operation

The noise sensor can detect the volume in dB near the roadside and show the volume on the OLED. A bar graph of sound intensity will be shown on the micro:bit.

![pic_70](images/Case4/Concept-diagram-Case4.png)

## Part List


![pic](images/Case4/Case4_parts.png)

## Assembly step


Step 1

Attach the OLED to D1 model with M2 * 10mm screws and nuts.

![pic](images/Case4/Case4_ass1.png)

Step 2

Attach noise sensor to D1 model with M4 * 10mm screws and nuts.

![pic](images/Case4/Case4_ass2.png)

Step 3

Put together all the cardboard parts (D1-D2).

![pic](images/Case4/Case4_ass3.png)

Step 4

Assembly completed!

![pic_40](images/Case4/Case4_ass4.png)

## Hardware connect


Connect Noise Sensor to P1 port of IoT:bit

Extend the connection of OLED to I2C connection port of IoT:bit

![pic](images/Case4/Case4_hardware.png)

## Programming (MakeCode)


Step 1

Step 1. Initialize OLED screen and variable * Drag `Initialize OLED with width:128, height: 64` to `on start` * Set `Noise` to 0 from `variables` ![auto_fit](images/Case4/Case4_p1.png)

Step 2. Show noise value on micro:bit LED

* In block `forever`. Set `noise` to round `get noise level (dB) at pin P1` * Drag `plot bar graph of …` from `Led` and draw variable `Noise` into the plotted value. Set value up to 100 * Drag `Pause` to the loop for wait for 0.5 second for next checking ![auto_fit](images/Case4/Case4_p2.png)

Step 3. Show the noise value on OLED screen

* Snap `clear OLED display` from `OLED` to avoid overlap * Snap `show string` to the loop and show value of the variable `Noise` ![auto_fit](images/Case4/Case4_p3.png)

Full Solution

MakeCode: https://makecode.microbit.org/S73074-92559-00368-70628 ![pic_80](images/Case4/Case4_full_program.png)

## Results


After initializing WiFi extension board and OLED, micro:bit will show a bar graph for the sound intensity in a city.

![pic](images/Case4/Case4_result.gif)

![pic](images/Case4/Case4_result2.png)

## Think


Q1. How to make a notification if noise pollution problem is serious? i.e. showing red LED