This blog post is badly organized because of the technical difficulty.(Blogger can not show HTML cords )
I highly recommend you to check this blog post with Opera browser.(Even Opera it is disorganized)
I did not check with other browser such as Safari, FireFox, Chrome and IE.
Do not copy and paste uploaded program to Arduino program. I do not know it is works or not.
Requirement
Temperature/Humidity sensor.
Four wires.
Two Ethernet cable
Router
Arduino
Arduino program
Arduino official Ethernet Shield with WIZnet W5100 chip
USB
computer with Ethernet and USB.
Knowledge of basic HTML
Finished my former tutorial of Ethernet Shield
In this experiment you will build up webpage that will show a temperature and humidity of the critic room of the sculpture studio. The webpage will broadcast thorugh a Arduino web server.
This experiment based on
http://wiring.org.co/learning/basics/humiditytemperaturesht15.html
I referred a program and example of circuit in the webpage.
You will put together Arduino's web server program and temp/humid program.
The program for temperature and humidity sensor is the most difficult program I have ever see.
However, we will modify ready made program so that it will not be so much complex.
First we need to do is to open a sample program of the web server.
This program has several functions.
The one is get a data from analog pins.
The second is answer the request of web browser and send a data based on http rule.
The Third is information of webpage itself.
I will not touch anything to the second function so that it will be more easy.
If you look through the program you will see a loop of "for".
In the section you will also see a lot of
client.print("");
This cord works as the same as "Serial.print".
In stead of send a data through serial connection, client.print send a data through Ethernet.
In side of the parenthesis of the "client.print("");" you will see "
Arduino sends a data of HTML to your browser with "client.print".
So if we change contents of the program of HTML the webpage will show up differently.
I changed a loop of "for" to the following
");
");
");
");
");
");
the
client.print("humidity ");
client.print((long)humidity, DEC);
These are commend that will show data from the sensor.
Do not wrongly erase a commend
break;
If you do that your web browser will load a webpage forever.
We already made the program for HTML.
We need to add a program of the sensor.
Basically you can copy the program that you got from the link which I introduced.
And paste them in a certain places.
However there is a one problem will occur.
The program of the sensor contains the commend
delay(300000);
which means that if you copy and paste directly your Arduino server work only every 5 minute.
Since 5 minute is too long, your web browser will be timed out.
Therefor, you need a lack to see the webpage which is none-sense .
However, if we delete it it must be not so good for arduino and server.
In order to avoid this issue we need to modify our program.
if(counter>=100000, ++counter)
{
sendCommandSHT(temperatureCommand, dataPin, clockPin);
waitForResultSHT(dataPin);
val = getData16SHT(dataPin, clockPin);
skipCrcSHT(dataPin, clockPin);
temperature = (float)val * 0.01 - 40;
sendCommandSHT(humidityCommand, dataPin, clockPin);
waitForResultSHT(dataPin);
val = getData16SHT(dataPin, clockPin);
skipCrcSHT(dataPin, clockPin);
humidity = -4.0 + 0.0405 * val + -0.0000028 * val * val;
counter=0;
}
you you change the program to this the Arduino check temperature only every 100 seconds and the rest of the time Arduino works as a server.
Now you are ready.
Setup MAC address and IP address based on former tutorial, upload and connect Ethernet cable.
You can see your webpage from your browser.
0 件のコメント:
コメントを投稿