DEV Community

Cover image for Improving my home-office environment with noise detection
Jorge Alberto Díaz Orozco (Akiel)
Jorge Alberto Díaz Orozco (Akiel)

Posted on

Improving my home-office environment with noise detection


I used a BBC micro:bit v2 to notify me when I am speaking too loud. Here is the project:


I usually don't speak too loud. Even when I'm mad, I try to remain calm and not to increase the volume of my voice as I dislike loud folks myself. There are, anyway, moments in which I involuntarily do speak really loud: When I'm wearing headphones and when I get really excited about what I'm talking about. And, guess what: That's exactly my everyday scenario since COVID19 forced us to close the offices and work from home. I work remotely for a fantastic software company and yes, my work is really exciting. On top of that, we do a lot of pair programming and have tens of meetings every week to discuss what we want to do and how we want to do it. All of this while wearing headphones that isolate me pretty well from the environment, so as you can imagine, I started speaking really loud.
This whole situation was not really fun especially for my wife. She is also a software engineer and we share the same space for working.
our office
Just imagine having meetings at the same time 😬

What to do

I needed to do something regarding this issue and engineers will try to solve everything with tech right? I researched for some hours and found out that the BBC micro:bit had released a new version of their development board. What was specifically so nice about this board is that it comes already packed with a bunch of sensors including a microphone. This also comes with a very nice price tag and a system so simple to use even kids can do it.

Using MakeCode

You don't know how to code? No problem, you don't need to write a single line of code. Microsoft MakeCode will allow you to express your automation desires in an intuitive way. After some minutes, this is what I ended up with:
code blocks
It is also very useful having an emulator and being able to play around and try everything.
MakeCode also allows you to code your solution in Python and JavaScript and applies translation from one codebase to another, so what I have just shown you in blocks looks like this in Python:

sound_enabled = False
sound_level = 0

def on_button_pressed_a():
    global sound_enabled
    sound_enabled = not (sound_enabled)
input.on_button_pressed(Button.A, on_button_pressed_a)

def on_forever():
    global sound_level
    sound_level = input.sound_level()
    if sound_level > 100:
        if sound_enabled:
            music.play_tone(262, music.beat(BeatFraction.WHOLE))
Enter fullscreen mode Exit fullscreen mode

and like this in JavaScript:

let sound_enabled = false
let sound_level = 0
input.onButtonPressed(Button.A, function on_button_pressed_a() {
    sound_enabled = !sound_enabled
basic.forever(function on_forever() {
    sound_level = input.soundLevel()
    if (sound_level > 100) {
        if (sound_enabled) {
            music.playTone(262, music.beat(BeatFraction.Whole))
    } else {
Enter fullscreen mode Exit fullscreen mode

As much as I want to explain much more, I would be only grasping the surface of this great tool, so go and give it a try 😄

Final result

I ended up with a pretty cool gadget that warns me visually if I'm being too loud and with the press of a button I can set it so it also beeps at me. I'm trying to condition myself to be a better home-office mate for my wife. At this point, I think I have not made much progress at it 😅 but this is only the beginning.
You can find the code for the project in this repository (which MakeCode allows you to do) and explore and play with it.

Kudos to Clem Onojeghuo for the cover picture

Top comments (4)

candost profile image
Candost Dagdeviren

Loved it! Thanks for sharing. I am a bit happy that I'm alone in the room. But this can be handy for many people.

llotz profile image
Lukas Lotz

This, sir, is absolutely amazing!

hurta2yaisel profile image
Yaisel Hurtado

so nerdy, i love it 😄😄😄

aneutrino profile image

You are the vest ;)