Measure some environmental values in my parents' heating unit: Unterschied zwischen den Versionen
Aus DL8RDS Wiki
Dl8rds (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „== Project == This little project has a manifold background: * My parents have a heating room in their house which holds an oil heater. * My parents recently…“) |
Dl8rds (Diskussion | Beiträge) (→Sketch) |
||
Zeile 81: | Zeile 81: | ||
float humidity = getHumidity(); | float humidity = getHumidity(); | ||
− | client.print("<html><head><title>Temperaturen und Feuchtigkeit im Heizungsraum</title></head>\n"); | + | client.print("\<html><head><title>Temperaturen und Feuchtigkeit im Heizungsraum</title></head>\n"); |
client.print("<body>\n"); | client.print("<body>\n"); | ||
Version vom 28. Juni 2013, 23:02 Uhr
Inhaltsverzeichnis
1 Project
This little project has a manifold background:
- My parents have a heating room in their house which holds an oil heater.
- My parents recently had a solar water heater installed on their roof.
- My mother usually dries the washed clothes in that room, which results in some higher air moisture, which can be measured.
So I decided to build a networked arduino that does all these measurements. The temperature measuring facility should be extensible in order to cover some more measuring points.
2 Hardware
- Arduino Duemillanove
- Arduino Ethernet board
- SHT15
- a couple of DS18B20 sensors: http://datasheets.maximintegrated.com/en/ds/DS18B20.pdf
3 Sketch
I tried a number of libraries over some time. Particularly the SHT1x library didn't seem to work. Then I discovered another sketch by somebody on the internet which eventually worked. Another sketch that
- SHT15 sketch: http://bildr.org/2012/11/sht15-arduino/
- DS18B20 code sample: http://x.openjumper.com/en/ds18b20/
So I integrated the two sketches with the standard Webserver example and this was the result:
//Based of the wiring code at http://wiring.org.co/learning/basics/humiditytemperaturesht15.html #include <SPI.h> #include <Ethernet.h> #include <OneWire.h> byte mac[] = { 0xAE, 0xAD, 0xAE, 0xAF, 0xAE, 0xAD }; IPAddress gateway(192, 168, 1, 1); IPAddress ip(192, 168, 1, 175); IPAddress dns(192, 168, 1, 1); IPAddress subnet(255, 255, 255, 0); int SHT_clockPin = 4; // pin used for clock int SHT_dataPin = 6; // pin used for data OneWire ds(9); // on pin 9 // Initialize the Ethernet server library // with the IP address and port you want to use // (port 80 is default for HTTP): EthernetServer server(80); void setup(){ Serial.begin(9600); // open serial at 9600 bps Ethernet.begin(mac, ip, dns, gateway, subnet); } void loop(){ byte i; byte present = 0; byte type_s; byte data[12]; byte addr[8]; float celsius, fahrenheit; // listen for incoming clients EthernetClient client = server.available(); if (client) { // an http request ends with a blank line boolean currentLineIsBlank = true; while (client.connected()) { if (client.available()) { char c = client.read(); // if you've gotten to the end of the line (received a newline // character) and the line is blank, the http request has ended, // so you can send a reply if (c == '\n' && currentLineIsBlank) { // send a standard http response header client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println(); //these can take a bit to get the values (100ms or so) float temperature = getTemperature(); float humidity = getHumidity(); client.print("\Temperaturen und Feuchtigkeit im Heizungsraum \n"); client.print("\n"); client.print("Temperaturen und Feuchtigkeit im Heizungsraum
\n
\n"); client.print("
Lufttemperatur: | |
Luftfeuchtigkeit: | |
Sensor: "); for( i = 0; i < 8; i++) { client.print(" "); client.print(addr[i], HEX); } client.print(" |