Test All Format

Test All Format

Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

Code

#include "Wire.h"
#include "ESP8266WiFi.h"
#include "ESP8266WebServer.h"
#include "hp_BH1750.h"
#include "Adafruit_Sensor.h"
#include "Adafruit_BME280.h"
#include "SparkFunCCS811.h"
// Web server
const char* ssid = "ssid";
const char* password = "password";

ESP8266WebServer server(80);

// Sensors
Adafruit_BME280 bme280;
hp_BH1750 BH1750;
CCS811 mySensor(0x5A);

float temperature;
float humidity;
float pressure;
float lux;
float CO2;
float TVOC;

long previousMillis = 0;
long interval = 1000;


void handleRoot()
{
  Serial.println("Request: /");

  // Build response
  String response = "";
  response += "{";
  response += "\"temperature\":";
  response += temperature;
  response += ",\"humidity\":";
  response += humidity;
  response += ",\"pressure\":";
  response += pressure;
  response += ",\"lux\":";
  response += lux;
  response += ",\"CO2\":";
  response += CO2;
  response += ",\"TVOC\":";
  response += TVOC;
  response += "}";

  // Send response
  Serial.println(response);
  server.send(200, "application/json", response);
}

void setup() {

  // Setup I2C
  Wire.begin(D2, D1);

  // Setup Serial
  Serial.begin(115200);
  delay(2000);
  Serial.println();

  // Connect Sensors
  bme280.begin(0x76);
  BH1750.begin(BH1750_TO_GROUND);

  // Start Wifi
  WiFi.begin(ssid, password);
  Serial.println("");

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  server.on("/", handleRoot);

  // CSS811 Connected?
  if (mySensor.begin() == false) {
    Serial.print("CCS811 error. Please check wiring. Freezing...");
    while (1);
  }

  // Begin server
  server.begin();
  Serial.println("HTTP server started");


}

void loop() {
  server.handleClient();

  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis > interval) {
    previousMillis = currentMillis;

    mySensor.readAlgorithmResults();

    // Read temperature (°C)
    temperature = bme280.readTemperature();
    Serial.print(temperature);

    // Read humidity (%)
    humidity = bme280.readHumidity();
    Serial.print(" °C\t");
    Serial.print(humidity);

    // Read pressure (hPa)
    pressure = bme280.readPressure() / 100;
    Serial.print(" %\t");
    Serial.print(pressure);

    // Read light intensity
    BH1750.start();
    lux = BH1750.getLux();
    Serial.print(" hPa\t");
    Serial.print(lux);

    // Read CO2
    CO2 = mySensor.getCO2();
    Serial.print(" lux\t\t");
    Serial.print(CO2);

    // Read TVOC
    TVOC = mySensor.getTVOC();
    Serial.print(" ppm\t\t");
    Serial.print(TVOC);
    Serial.println("ppb");
  }


}

Hello

Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

Hoi ik ben Sven!!


Where does it come from?

Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.