Dmitriy
Published © GPL3+

DumbBell

A doorbell with custom ringtones that can be muted on a schedule and notifies you on the phone if someone rings the door when you're away.

IntermediateWork in progress2,118
DumbBell

Things used in this project

Hardware components

Speaker
Can be substituted by a buzzer/doorbell
×1
Raspberry Pi 2 Model B
Raspberry Pi 2 Model B
×1
Cell phone
Could also be a tablet or another portable computing device
×1
Button
Any button will do, re-using an existing doorbell button makes most sense
×1

Software apps and online services

Windows 10 IoT Core
Microsoft Windows 10 IoT Core
Microsoft Azure
Microsoft Azure

Story

Read more

Schematics

Button wiring

This is the wiring required for the button to operate properly as an input. Wired it to GPIO 4, but you can use any other GPIO pin. Used a 10k Ohm resistor on the ground path and 330 Ohm on the GPIO path. A good tutorial and explanation can be found here: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/robot/buttons_and_switches/

Code

Ringing the bell

C#
This function processes the button press
 private async void Pin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            System.Diagnostics.Debug.WriteLine("New pin value: " + args.Edge.ToString());
            if (args.Edge.Equals(GpioPinEdge.RisingEdge))
            {
                Windows.Storage.StorageFile storageFile = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFileAsync("Recording.m4a");
                var stream = await storageFile.OpenAsync(Windows.Storage.FileAccessMode.Read);
                if (null != stream)
                {
                    media.SetSource(stream, storageFile.ContentType);
                    media.Play();
                }
            }
        }

Initializing GPIO

C#
Enables Raspberry Pi to listen for button press input on GPIO 4 (feel free to use another pin, but remember to change the constant then)
pin = GpioController.GetDefault().OpenPin(4);
            //Ignore changes in value of less than 50ms
            pin.DebounceTimeout = new TimeSpan(0, 0, 0, 0, 50);
            pin.SetDriveMode(GpioPinDriveMode.Input);
            pin.ValueChanged += Pin_ValueChanged;

Credits

Dmitriy

Dmitriy

1 project • 2 followers

Comments