Arduino Standalone Web Enabled Bell





Introduction: Arduino Standalone Web Enabled Bell

Inspired by this post, I wanted to create an Arduino powered bell that was completely standalone.

With a little PHP and (if you like) some jQuery on any website, you can make this bell ring whenever a specific action is performed.

This Arduino stack is wifi; once it's been configured, you can simply power it from a 9v DC supply.  It also works when powered through the USB connector using a standard USB charger; I've tested it with an Amazon charger designed for the Kindle which works fine.

I used:

An Ardunio Uno from eBay, about £18
A WiFly Shield by Sparkfun, from eBay, about £23 (which was cheap; they're normally more than that).  If you're buying one, note that you'll need to solder some header pins onto the board.
A project board (that's the plastic sheet everything's fixed to) from the brilliant Oomlaut
Some jumper wires
A length of cat5 cable, to position the servo and bell a good distance from the control board
A standard Acoms servo from eBay (about £5)
A 9v power supply from Maplin (£10)
A little brass bell (from my inlaws, no charge!)

This could obviously be done with an ethernet shield or an ethernet enabled Arduino; the sketch would be a little different in this case.

The bell is connected to the servo using a paperclip; this means we don't have to move the servo arm much.  The flexibility of the paper clip causes the bell to ring nicely.  It also means the bell can hang properly, which it needs to in this case.

At the moment, the sketch is NOT perfect.  The stack takes some re-starting sometimes; it doesn't always respond to requests.

Here's the sketch.  Note that my setup does NOT require the setting of IP address details; I programmed my router to always assign the same IP address by DHCP.

// webserver sketch
// based on Zoomkat code from Arduino forums

#include "WiFly.h"
#include "Servo.h"
#include "SPI.h"

Servo myservo;  // create servo object to control a servo
Server server(80); //server port
String readString; //create readString class


void setup(){

  pinMode(2, OUTPUT); //pin selected to control
  myservo.attach(2);  //the pin for the servo control
  myservo.write(0);   //set initial servo position if desired

  //enable serial data print

  //exit CMD mode if not already done
  Serial.println("Exited CMD mode");
  //set into CMD mode
  Serial.println("Into CMD mode");

  //switch DHCP on
  SpiSerial.println("set ip dhcp 1");
  Serial.println("Set DHCP"); 

  //set authorisation level
  SpiSerial.println("set w a 1");
  Serial.println("Set authorisation level");

  //set passphrase
  SpiSerial.println("set wlan key [enter your WLAN key here, no brackets]");
  Serial.println("Set WLAN key");
  //set localport
  SpiSerial.println("set i l 80");
  Serial.println("Set port");
  //disable *HELLO* default message on connect
  SpiSerial.println("set comm remote 0");
  Serial.println("Set comm remote 0");

  //join wifi network
  SpiSerial.println("join [enter your SSID here, no brackets]");
  Serial.println("Join network");

  //exit CMD mode
  Serial.println("Exiting SpiSerial");
  Serial.println("Starting server"); 


void loop(){
  // Create a client connection
  Client client = server.available();
  if (client) {
   Serial.println("Client connected"); 
    while (client.connected()) {
      if (client.available()) {
        char c =;
        //read char by char HTTP request
        if (readString.length() < 100) {
          //store characters to string
          readString += c;
        //if HTTP request has ended
        if (c == '\n') {
          Serial.println("HTTP request ended");
          Serial.print("readString = ");
          Serial.println(readString); //print to serial monitor for debugging

          //now output HTML data header
          client.println("HTTP/1.1 200 OK"); //send new page
          client.println("Content-Type: text/html");
          client.println(" ");

          //stopping client
          Serial.println("Stopped client");

          ///////////////////// control arduino pin
          if(readString.indexOf("w") >0)//checks for w
            Serial.println("w found");
          if(readString.indexOf("b") >0)//checks for b
            Serial.println("b found");

          //clearing string for next read
            Serial.println("Cleared readString");

        } // end if HTTP request is ended
      } // end if client available
    } // end if client connected
  } // end if client
} // end loop

I'm using pin 2 for the servo control; you can use any pin but be careful not to use any pins that are used for something else on the WiFly, Ethernet or any other shield you may be using.

Test the setup by connecting the USB cable to your machine (without the servo connected, unless you're sure it wont blow the USB fuse in your machine - it works OK for me but not all computers have the ability to power a server) and start the serial monitor to check your stack connects to the wireless network and registers client connections.

If it does, connect it to a power supply and connect the server.

You can trigger the bell by entering the IP address into a browser like this (where xx.xx.xx.xx is replaced by the IP address of the stack):

(rings the bell once)


(rings the bell twice)

If you enter the address with nothing after the IP address, the stack will not ring the bell.

To set the bell to ring when specific pages are accessed on a website, you need some PHP and jQuery skills.  Here's what I did:

1) Forwarded port 80 on my router to the private IP of the Arduino stack on my internal network

2) Created a php file called ding.php

    curl_setopt($ch,CURLOPT_URL,'http://[my WAN IP address]/?w');
    curl_exec ($ch);

3) Called this file using jQuery in the page I'm monitoring:


(You'll need to add jQuery to your page too).

Doing it this way means no-one discovers your WAN IP address.  Not that important but still, some people like to keep theirs quiet!

My setup can be accessed at the following URL.  If you click it, you'll ring a little brass bell in my Christmas tree!  The page won't display anything, but the bell will ring.  Have a look at the video to see what happens when you do.




    • Water Contest

      Water Contest
    • Clocks Contest

      Clocks Contest
    • Creative Misuse Contest

      Creative Misuse Contest

    2 Discussions

    Hi there

    Not really. I did find some amendments to the WiFly libraries that helped, but it was never rock solid.

    Since this project, I've started using the latest Arduino IDE and moved to wired ethernet shields.

    If I was to use a WiFi shield again I'd use the official Arduino one since it's probably better supported. At the time of this project, there wasn't one.

    Another tip... Get an LCD display and build some onscreen debug, unless it's easy to run your project connected to a PC with serial monitor open, of course.

    And use the Arduino forums. They can be very harsh but there are many very knowledgeable people there!

    Hello SimonUK, I followed this post from the Arduino forum and I was wondering if you ever worked out the occasional freeze that occurs on making a request. I too experience unexplained lockups in a project while using the arduino as a webserver. Any update would be appreciated. Thanks!