How to build a small Webserver.... in 90 Minutes... :-)

 

Status: almost complete (documentation pending)

 

 

This small project should show what´s possible to create in about only 90 minutes, in case all necessary parts are in front of you, or at least at reachable distance.
What is the aim of this? Nowadays almost everybody seems to have a broadband internet connection at home with some kind of flat rate, for beeing ´always on´. What´s more desirable having a small Webserver you can ask from any point of the planet, what´s going on at home, or which enables you toggling a number of functions remotely

Since 10th of October 2009 the server is running in work environment.
If you want you can have a look here:
dougie´s heating control

 

>

 

 

 

I was looking for some kind of project like this for almost 5 years now, since I created my first PC-Laptop based control hardware for my central heating. I never found the right moment to start with the work on a µProcessor solution, because I have an estimation how much work this is and how much time it´ll cost. But with this guide it took me only two weeks, which were used for learning the programming language C.

What was the original problem?
In our home we have underfloor heating in every room, so changing temperature quickly isn´t easily achievable and needs some careful monitoring. On top, the initially installed bi-metal temperature sensors for switching the electrical valves for the different heating slopes were not suitable at all for getting the temperatures under control.. Because we have only few walls inside, one slope automatically partly heats up the neighbouring areas, and the bi-metal switches are by far too inaccurate, that you could adjust them in a way that would serve the purpose.

Here are two pictures of the old bi-metal switches and how I did the modification by installing digital temperature sensors..

 

>

 

 

>

 

 

It must have been in 2003/2004 when I decided to change the setup using bi-metal switches. I read about a small program called digitemp, which enables the communication with Dallas 1-Wire temperature sensors called DS18S20. This seemed a perfect match! The sensors only need two or three wires and all can operate on one bus (the 1-Wire Bus). They deliver the temperature with an accurracy of up to 12bits (I used only 10bits, it´s faster, easier to program and for a result with 0,1°C good enough). Because I didn´t want to put new cables in the walls, I simply used the existing cables to the bi-metal switches. Unfotunately I wasn´t able to use the software in another way than running it on an old Laptop in a 4-DOS Box under Win98SE. Sounds weird? Well... this worked extremly reliable over 5 years with only one outage, when the power supply of the laptop suddenly died.
However: running your central heating on a laptop isn`t a real engineers solution, but for the time beeing it was okay and gave time to watch out for a µP based one. Murphy said that ...nothing´s more durable than a provisional arrangement ... and he was right!

Below you can see a picture of my old setup. The seven different heating slopes and the heating main switch were triggered by the eight data-pins of the laptop parallel port.

 

>

 

 

But recently I came across a small Webserver Project which immediately caught my attention: Webserver with 1-Wire protocol support, Ethernet Interface, SD Card support and many features more. A reasonable guy called Ulrich Radig already had developed a tiny PCB and an excellent software package, making the start of the project really easy. In his webshop you can order the PCB and all special components which are hard to find elsewhere for a few Euros. The remaining parts are available at almost every better electronics store. Cost of the Hardware might be in the range of 40 Euros.

 

Here´s an idea what you could get: with the help of MS Excel and some lines of Visual Basic Macros you will be able to download logfiles stored on your Webservers SD-Card from any place of this planet with the simple push of a button, checking what´s going on at home. Version 1.2 of the Excel Tool can be downloaded here. Remember to enable Macros when opening. You only have to amend the desired date and the link to your webserver. A detailed description will be added later.

This here is a full chart including Outside Temp (lower curve )and Heating Supply Temp & Water Supply Temp (Upper two curves). All Room Temperatures are the colored lines in the middle.

 

>

 

 

 

Because room temperatures cannot be checked in detail, theres the ´room temp chart´ which gives better resolution.

 

 

>

 

 

 

Now, let´s start with the real work on the webserver.
Today at 10:00 I received the PCB and the other parts and started to put everything together. Here a picture of the empty PCB Top-Side.

 

>

 

 

10:15 At a first step I soldered the µProcessor onto the backside of the PCB. This small chip for 5,20 € will do all the work. It´s an Atmel AT-Mega 644 with 64k of Flash memory running at about 14MHz

 

 

>

 

 

10:30 After 15mins we already have the Bottom Side completed. On the left you can see the MAX3232 RS232/TTL level shifter, and on the right the filter network for the Ethernet interface.

 

 

>

 

 

 

11:00 Top Side is a bit more work, but in case you´ve got a good soldering iron (I use a number of those from Weller, Type WTCP-S with an 0,8mm tip)it should be achievable within 30mins. I did it in a bit less, but I had to take the pictures in between :-)

 

 

>

 

 

 

iThe remaining 30 minutes are used for searching a suitable power supply. I would recommend a cheap 5V or 12V Power Socket Supply, as the whole Webserver runs on 3,3V. If you would like using the external LCD, vou´ll need the 5V, and if the LCD has a backlight, you might need the 12V.
In case you would like to switch relays with the optional outputs, a 12V supply is strongly recommended.
What else? For getting the Webserver into operation, you´ll need flashing the hex-file you can freely download from the web-page mentioned above into the AT Mega644 Processor. There is more than one way how to do that. I simply used one of my USB ISP Programmers you can either buy for a few euros at any corner, or build it yourself.
Please be aware that in the ready compiled hex-file the IP and MAC Address of your webserver is preset! You can change it later via the terminal connection, but it might be more convenient having the desired IP address right from the beginning. In that case (and for all amendments you would like to make to the code, it might be best downloading and installing WinAVR and/or AVR Studio. Both are free of charge available on the web and the software package of the webserver comes as a complete project package. So the risk for messing something up or not getting started is quite low.

 

 

Once the program had been amended meeting my requirements, the only missing part was creating the necessary outputs for switching power loads. Here´s my quick-and-dirty 4-Channel relay board. One switches the valves of the upper floor, and a second one those on ground level. The Interface board between the Webserver and the Relay Boards will be described later here as well.

 

 

>

 

 

 

When using µProcessors you´ll find earlier or later that you never have enough IO Pins available for connection your whole environment. Here´s a small example how to overcome this obstacle.
I used only 3 IO Pins to serially export the desired data. With the help of a latched shift register 4094 I can clock 8 bits out. In case 8 outputs are not enough, you can stack the 4094 and add 8 outputs with every 4094. The outputs of the 4094 cannot drive loads, as they only deliver half of a mA. Therfor I used a ULN2003 darlington driver stage. The ULN2003 comprises only 7 drivers, so i added one extra relay as my heating main switch. The 7 Driver lines of the ULN2003 switch the relays for the heating valves.

 

 

>