Meta

EGO BOX

-or physical website visits display-

Introduction

If you have a blog or any other kind of website then this is for you. It’s a little box that connects to the internet and displays how many visits you have on your website. It’s designed to work independently of your computer, connecting directly to the internet via your router. Mine even steals power from one of the routers USB ports.

Meet the ego box.

By now the name should explain itself: it’s called ‘ego’ because it’s suppose to tickle your ego when you see just how many people visit your site. And ‘box’ because it’s … ammm… all packed in a nice box.

Don’t be fooled by the picture, the box is really small (about 6 x 9 cm / 2.4 x 3.3” footprint to stay technical). No, I didn’t want a large display placed on the wall. I wanted a small box that can find a place anywhere. After all, it’s the displayed number that it is important.

I’ve used the toner transfer to ABS method to make the front panel. Things came out very well except that the whole thing is a little tilted, but in an optimistic way. The top of the box gets its own writing with the things name.

The display consists of 8 digits capable of displaying up to 99.999.999. Sorry, this project is not for those of you with more than 100 million page visits (still, it’s easy to extend it to as many digits as you want).

Update 16th July 2011

Last night I stayed up late to watch this happen:

The technical bit

How does all this work? The whole system consists of two parts. The first part is a small php script that is ran every time someone visits my website. It reads the number stored in a text file, increases it and writes it back. I’ve placed it in the header.php file of my wordpress theme so that it is run every time some page is loaded. See info on script here.

The second part is the box. It’s got an Ethernet interface that connects it to the internet through a router and accesses the text file that contains the number of visits. Then the number is extracted and displayed on the 7 segment display.

Let’s get to the technical details of making all this work.

The counter

First of all, a file to hold the number of visits is required. If you are using cpanel the online file manager works easily. I chose to create a separate folder to hold that file. Just create a new folder named, let’s say, counter in the www folder. On your computer create a text file containing just #$$%0 and save it. I’ve named it hits.html. You may also check your website statistics and put the actual visits number so that you may start with the correct value, e.g. #$$%101256. (Update: Initially the file contained just the number, but I chose to include a header #$$% in front of the number to make things better at the microcontroller side). Upload this file to the counter folder. Because the script needs to be able to change the file you need to change its access permissions so that it can be written by the user and readable by the rest of the world(644). Check out below:

Now the script needs to be added. You may use the same file manager. Say you will place it in the header, navigate to /wp_content/themes/your_theme/header.php. Choose to edit it and add the following script in the header file:

Just make sure that you have the correct file and location for your counter file(highlighted above). Example below:

This concludes the online part of the counter. Test it and see that the number is correctly increasing. Just navigate to the counter file see that it increases correctly as you access your website. For my website this is located at http://www.electrobob.com/counter/hits.html . This will be the address that the box will read.

The box

As I have mentioned, the box connects to the internet with an Ethernet interface. I’ve used the very popular Microchip ENC28J60 MAC and PHY because it is easy to use. There is plenty of good working software for controlling it already available and this has positively contributed to a quick development. My choice is the stack available at www.tuxgraphics.org written by Guido Socher which provides most of the functions required to access a web page.

The microcontroller of choice is the ATMEGA168. It has just enough pins (the display needs 15) and enough memory for the whole applications. To complete the circuit for this project I’ve added a display and the driving circuitry. I’ve chosen an old fashion 7 segment display because of its visibility and the technological look it gives to the project. Be aware that there was no way for me to capture the real pure red of the display with my camera. The 8 digits display is composed of two KW4-361ASB, 4 digits each.

For the power supply I planned on using 5V from one of the free USB ports of my router. As the whole circuit needs 3.3V, a LM1117-3.3 LDO regulator was used. There is a serial port that I have used for debugging during the development and for loading the software via a bootloader. I ended up not using an external oscillator for the microcontroller, but there is space for one on the PCB. Other than that, the schematic is self explanatory and it can be seen below:

The PCB was designed to fit a certain project box that I had. I managed to make it very compact and single sided. It’s built using my UV exposure box.

The software

The software contains the TCP/IP stack for use with the ENC28J60, a display controller, interrupts, functions for accessing the counter page, processing it etc. The firmware is well documented and it is included in the project archive at the end.

Some things need to be changed and it has to be compiled for usage in your project. For the Ethernet part it needs to be given a MAC address, a local IP address and a gateway address. You will also need to set the URL of your counter file.

There is an option to choose how fast the update is made. I’ve chosen 1 minute which is a reasonable time, but gives you over 40.000 accesses to the counter file per month. I think that this is a rather low load, but you may increase the time.

The build:

I’ve put together a small gallery below during the build of the box. First off is the PCB:

Most of the parts mounted:

The PCB mounted inside half of the case:

Soldering the wires on the display:

Mounting everything inside the case:

Transferring the image on the top

half of the case:

Making the first tests(shutter speed ate one digit):

And the final box, fully functional. I didn’t mount the back panel to allow for the inside components to be seen:

Download

Finally the software and eagle files can be downloaded from here. The software is licensed under GPL V2 and the eagle files are free for personal use.

34 comments to EGO BOX

[…] My ego box is a quick candidate to become wireless, but as I wanted to keep the original intact, I made a new temporary one. My greatest concern was to establish if the HW, with default firmware(less important), is capable of running stable for a long time. The build puts together an Xmega header board with an IL9341 2.2” QVGA LCD and, of course, the ESP8266 module. […]

[…] mobile optimized web configuration interface. The idea for the etherfeed project came from the electrobob’s “egobox” a physical hitcounter based on pic microcontroller and a 7 segment LCD Display. There are two […]

[…] mobile optimized web configuration interface. The idea for the etherfeed project came from the electrobob’s “egobox” a physical hitcounter based on pic microcontroller and a 7 segment LCD Display. There are two […]

I have completed the AVR Statistics device that I have previously discussed with you. It is called etherfeed, It displays Google Analytics Visits,Hitcount, It displays also PayPal IPN sales (SUM of sales), Google weather data etc. The device uses ATMEGA644. see http://www.etherfeed.com

Hey everyone!
Sorry for this delay, I’ve been busy with exams…
I’ve considered your requests to going commercial with it. Unfortunately I’ve got too little free time to actually built some extra boxes and ship them worldwide.
The project also has some limitations, you have to know the link of the file, IP address etc, then compile the code and program the micro.

Luckily, the project is open source so that anyone can build one.
At this moment I could make PCBs available for everyone if I could find some service, such as BatchPCB that was available to worldwide customers.

I’m also considering a version 2 of this, switching to a microcontroller with integrated Ethernet and easily customizable address and IP.

In the mean time, thank you very much for the appreciation and I’ll do my best to come up with great projects.

Just like lots of others here I would like one of those but find myself too busy to put all the pieces together. If this would be available as a solder yourself and “pre programmed” I would order one in a heartbeat. Bob, when you are ready to pursuit monetizing on your project contact me. If anyone else wants to make a buck and with Bob’s permission contact me to build me one. In any event keep up with your passion. You rock.

Like I have mentioned in the text: “The 8 digits display is composed of two KW4-361ASB, 4 digits each.” You can find the datasheet of the display online.

Regarding the TCP/IP stack, there are a few versions out there, for various types of micros or ethernet adapters, such as Microchip’s, uIP, the one from tuxgraphics that I have used etc.
If you want to know more about how communication in the internet is done, check out a bit about the ‘OSI model’.