Select Page
This entry has been published on 2015-03-20 and may be out of date.

Last Updated on 2015-03-20.

 

Scenario

If you are using an IP Intercom like 2N Helios IP or a similar Mobotix product, you might have seen that the variety of IP compatible sound modules for a simple internal doorbell is quite low. But something like this is necessary for many homes, as SIP / VoIP smartphone apps can be unreliable.

Some IP doorbells offer a hardware relais to do it the old-school way and lay wires between doorbell / sound module and intercom, but this should not be the solution for a modern intercom system in my opinion.

 

Solution approach

In this tutorial, I will show you how to create a sound module which can be controlled via HTTP request commands.

Arduino doorbell

The Arduino Ethernet Board is a good way to achieve this, because

  • there are Power over Ethernet compatible versions, or you can extend it yourself with a PoE module
  • low power consumption
  • reliable device
  • simple coding

Although it seems a bit expensive just for usage as sound module, note you can use this piece of hardware for many other scenarios, so this money is not wasted 🙂

This is what you need:

 

Download the Arduino IDE from here and install it.

Read the Getting Started tutorial and connect your board via USB (do not forget to set the right serial port).

Within the Arduino software, use this code to create a webserver which can start the sound output:

#include <SPI.h>
#include <Ethernet.h>

bool soundoutputPending = false;

String httprequest = "";

byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xEB
};
IPAddress ip(10, 1, 0, 84);

EthernetServer server(80);

void setup() {
  Ethernet.begin(mac, ip);
  server.begin();
}

void loop() {
  EthernetClient client = server.available();
  if (client) {
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        httprequest += c;
        if (c == '\n' && currentLineIsBlank) {
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          client.println("<body>");
          client.println(httprequest);
          client.println("</body>");
          client.println("</html>");
          
          if (httprequest.indexOf("soundOutput") > -1)
            soundoutputPending = true;
            
          httprequest = "";
          break;
        }
        if (c == '\n') {
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
          currentLineIsBlank = false;
        }
      }
    }
    delay(1);
    client.stop();
    

  }
  
  if (soundoutputPending)
  {
    sound();
    soundoutputPending = false;
  }
}

void sound()
{
  tone(9, 200, 200);
  delay(300);
  tone(9, 300, 200);
  delay(300);
  tone(9, 400, 200);
  delay(300);
  tone(9, 500, 200);
  delay(300);
  tone(9, 600, 200);
  delay(300);
  tone(9, 800, 500);
  delay(300);
}

Connect the speaker’s black wire to a ground pin and the red one to Pin 9. You can also use another pin number in the sound() function, but I experienced some distortion noise e.g. on 10 and 11.

Adujst e.g. IP or port settings for your needs, then upload the script to your Arduino.

To test it, open your browser and type http://[yourIp]:[yourPort]/soundOutput, e.g.: http://10.1.0.84/soundOutput