home |  electronics |  toolbox |  science club |  tuxtalk |  photos |  e-cards |  online-shop

http://tuxgraphics.org/electronics




Content:
By Guido Socher

 

Temperature and humidity measurements with the AVR web-server

[Illustration]

Abstract:

The tuxgraphics Ethernet board has a lot of general purpose IO pins where external hardware such as sensors can easily be attached.

In this example we use the sensirion sht11 sensor to

  • measure temperature
  • measure humidity
  • calculate the dew point
All that is done with just one sensor. No other external components are needed.
_________________ _________________ _________________

 

The sht11

The sht11 from www.sensirion.com is a fully calibrated sensor. Not a single external component is needed to use it in combination with an avr microcontroller. It has: A datasheet is available in the download section of this article or from www.sensirion.com.

It is a very good quality sensor developed in Switzerland.

A few things are a bit misleading when you read the datasheet of the sensor and I mention it here to avoid surprises:  

What you need



... and this is what you get (two sensors, s0 and s1, attached to the ethernet board):



You can have one or more sensors attached to one ethernet board. The above web page is an example with two sensors.

Humidity and temperature data accessible from any web-browser. Using the NAT port forwarding feature in your DSL router you can even make it available on the internet and access it e.g from your mobile phone:



 

What is the dew point?

The dew-point temperature is the temperature to which the air must be cooled to reach saturation. When the temperature cools to the dew point, fog or dew can occur.

Example: In your bath room you measure 23'C and 61% humidity. The resulting dew point is about 15'C. If your window or wall temperature would be 15'C or less then it would become wet.  

Connecting the sensor

The SHT11 humidity and temperature sensor can be connected the Atmega microcontroller as follows. No additional components are needed.

Nothing must be connected to pin 1 (at the top) and the pins on the right. Those seem to be used for test and calibration during production.

You need just one more IO-pin per extra sensor in case you want to connect more than one sensor. The sck line can be shared but each sensor needs its own data-line as the sensors are all identical and can thus not be connected in a bus system.

As of software version eth_rem_dev_sensirion-3.3 there is a possibility to connect more than one sht11 sensor to one board. The sensor has to be connected as follows:
SHT11Web-server, new software (versions 3.3 and up)
First sensor:
Vcc 3.3V (available on the analog port or digital IO port)
Data PD0 (available on the digital IO port)
SCK PB0 (available on the digital IO port)
GNDGND (available on the digital IO port)
Second sensor (optional):
Vcc, SCK, GND same as first sensor
Data PD1 (available on the digital IO port)
Third sensor (optional):
Vcc, SCK, GND same as first sensor
Data PD4 (available on the digital IO port)


It is possible to connect even more sensors.

The older software eth_rem_dev_sensirion-3.0, eth_rem_dev_sensirion-3.1 and eth_rem_dev_sensirion-3.2 is designed to accept only one sensor which has to be connected as follows:
SHT11Web-server board with older software (versions 3.0, 3.1 and 3.2)
Vcc 3.3V (available on the analog port or digital IO port)
Data PD1 (available on the digital IO port)
SCK PD0 (available on the digital IO port)
GNDGND (available on the digital IO port)
 

My application

There are certainly plenty of applications for this. You can use it anywhere where you want to measure any or all of the values temperature, dew-point and humidity.

I just want to tell you what my use of it is. When I go on vacation I do usually switch off the heating in the house to save cost. The problem with this can be that it can either become too cold and/or too humid in the house. If you leave a window open then it might become too cold. If you have the window closed it can become very tropic (=too humid) due to the flowers in the rooms and no ventilation. With this sensor I can monitor the situation.

I can monitor that from my mobile phone or any computer at any time.

Sht11 with 100nf capacitor
 

Extending the sensor cable length

The length of the cable between microcontroller and SHT11 sensor should not be more than 50cm to ensure reliable operation. You can however extend it to a 2-3 meters by soldering a 100nF capacitor between the power supply pins of the sensor.

If you want to cover a whole building with humidity sensors then you can just use a couple of ethernet boards with sensors attached to each of them. Ethernet cables can be 100m long and this way a very large area can be covered. It is possible to make a number of ethernet boards, running each their own web server software, available via only one DSL router You need to configure different port numbers for the different web servers and then setup port forwarding in the DSL router for each of them. For this you need to change the "#define MYWWWPORT" in file main.c. The setup could e.g look like this:
Internal IP and portExternal URL
192.168.0.10, web server port 80 http://Your.Domain
192.168.0.11, web server port 88 http://Your.Domain:88
 

Automatically updating the web page

Personally I don't like web pages which reload themselves automatically. Many people have however written to me that they would like to have such a feature and maybe it makes sense here. You can leave the browser open and it shows you always the current situation. As of software version 3.1 the page updates every 5min. If you want additional updates in-between then you can just click on the link "refresh page" at the bottom of the page.

The automatic page update is done by adding the http-refresh in the server header. The server header is part of the http protocol and you don't see it if you click on page source in you web browser. A refresh very 5min would look like this:
HTTP/1.0 200 OK
Content-Type: text/html
Pragma: no-cache
Refresh: 300
The corresponding avr web-server C-code would look like this (one line):
plen=fill_tcp_data_p(buf,0,PSTR("HTTP/1.0 200 OK\r\nContent-Type: text/html
\r\nPragma: no-cache\r\nRefresh: 300\r\n\r\n"));
 

References





© Guido Socher, tuxgraphics.org

2009-09-07, generated by tuxgrparser version 2.57