Another environmental sensor for my parents' house: Unterschied zwischen den Versionen

Aus DL8RDS Wiki
Wechseln zu: Navigation, Suche
(Images)
(Images)
Zeile 198: Zeile 198:
 
[[Image:2016-12-27-envsensor3.jpg|400px]]
 
[[Image:2016-12-27-envsensor3.jpg|400px]]
 
[[Image:2016-12-27-envsensor4.jpg|400px]]
 
[[Image:2016-12-27-envsensor4.jpg|400px]]
 +
[[Image:2016-12-27-envsensor8.jpg|400px]]
  
 
[[Image:2016-12-27-envsensor5.jpg|400px]]
 
[[Image:2016-12-27-envsensor5.jpg|400px]]
 
[[Image:2016-12-27-envsensor6.jpg|400px]]
 
[[Image:2016-12-27-envsensor6.jpg|400px]]
 
[[Image:2016-12-27-envsensor7.jpg|400px]]
 
[[Image:2016-12-27-envsensor7.jpg|400px]]
 
[[Image:2016-12-27-envsensor8.jpg|400px]]
 

Version vom 27. Dezember 2016, 13:26 Uhr

1 Project Scope

As I have created an environmental sensor for the heating system of my parents' house a couple of years ago, I can monitor some basic values my parents' heating system. But the overall performance of the pumps can only be certified if we meeasure the heat that arrives in the last floor right under the roof. Given that this is a floor that is not visited every day, it was a good point to place another environmental sensor there.

2 Parts List

  • Arduino Duemillanove (Atmel 328P)
  • Arduino Ethernet Shield V1
  • TEMT6000 light sensor
  • Watterott BME 280 environmental sensor
  • DC/DC step down converter
  • two reactor coils to block HF from the DC converter
  • passive POE injector

3 Links

I found these resources very helpful:

4 Software

4.1 Arduino software

In order to use the cactus.io code examples, it was necessary to use the latest Arduino code. I downloaded the version 1.8.0.

4.2 The Code

The SPI hookup of the BME 280 sensor was not attractive as I an very convinced of I2C on the Arduino platform. The Adafruit libraries are focussing SPI, so they are not so well usable. I decided to use the cactus implementation instead.

Connectivity to the TEMT6000 sensor is straight forward as it is just a direct wire to the ADC pin 0.

In order to display everything on the web, I combined the cactus sketch with the standard Ethernet Webserver example.

/***************************************************************************
  This is a library for the BME280 humidity, temperature & pressure sensor
  Designed specifically to work with the BME280 Breakout board
  ----> http://www.adafruit.com/products/2650
  This sketch only supports the I2C bus for connection.
 ***************************************************************************/

#include <Wire.h>
#include "cactus_io_BME280_I2C.h"
#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xAA, 0xAA, 0xED
};
IPAddress ip(192, 168, 1, 177);

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);


// Create the BME280 object
BME280_I2C bme;              // I2C using default 0x77 
// or BME280_I2C bme(0x76);  // I2C using address 0x76

int temt6000Pin = 0;

void setup() {
  Serial.begin(9600);
  Serial.println("Bosch BME280 Barometric Pressure - Humidity - Temp Sensor | cactus.io"); 

  if (!bme.begin()) {
    Serial.println("Could not find a valid BME280 sensor, check wiring!");
    while (1);
  }

  bme.setTempCal(-1);

  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

   // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());

  Serial.println("Pressure\tHumdity\t\tTemp\t\tTemp");
}

void loop() {

  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        // 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("Connection: close");  // the connection will be closed after completion of the response
          client.println("Refresh: 2");  // refresh the page automatically every 5 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          client.println("<table>");
          bme.readSensor(); 
          
          Serial.print(bme.getPressure_MB()); Serial.print(" mBar\t");    // Pressure in millibars
          client.println("<tr><td>");
          client.println("Pressure"),
          client.println("</td><td>");
          client.print(bme.getPressure_MB()); 
          client.println("</td><td>");
          client.println(" mBar"); 
          client.println("</td></tr>");

          Serial.print(bme.getHumidity()); Serial.print(" %\t");
          client.println("<tr><td>");
          client.println("Humidity"),
          client.println("</td><td>");
          client.print(bme.getHumidity()); 
          client.println("</td><td>");
          client.println(" %");
          client.println("</td></tr>");

          Serial.print(bme.getTemperature_C()); Serial.print(" *C\t");
          client.println("<tr><td>");
          client.println("Temperature_C");
          client.println("</td><td>");
          client.print(bme.getTemperature_C()); 
          client.println("</td><td>");
          client.println(" °C");
          client.println("</td></tr>");

          Serial.print(bme.getTemperature_F()); Serial.print(" *F\t");
          client.println("<tr><td>");
          client.println("Temperature_F"),
          client.println("</td><td>");
          client.print(bme.getTemperature_F()); 
          client.println("</td><td>");
          client.println(" °F");
          client.println("</td></tr>");

          int value = analogRead(temt6000Pin);
          Serial.print(value); Serial.println(" L");
          client.println("<tr><td>");
          client.println("Light");
          client.println("</td><td>");
          client.print(value); 
          client.println("</td><td>");
          client.println(" L");
          client.println("</td></tr>"),

          client.println("</table>");
          client.println("</html>");
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        } else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
    Serial.println("client disconnected");
  }

}

5 Images

2016-12-27-envsensor1.jpg 2016-12-27-envsensor2.jpg

2016-12-27-envsensor3.jpg 2016-12-27-envsensor4.jpg 2016-12-27-envsensor8.jpg

2016-12-27-envsensor5.jpg 2016-12-27-envsensor6.jpg 2016-12-27-envsensor7.jpg