Added som debug messages

This commit is contained in:
klaute 2017-12-09 18:08:37 +01:00
parent 8a4f73d425
commit 0652515727
3 changed files with 36 additions and 10 deletions

9
firmware/config.h Normal file → Executable file
View file

@ -11,6 +11,15 @@
#define STATUS_LED_PIN BUILTIN_LED #define STATUS_LED_PIN BUILTIN_LED
#define ANEMOMETER_PIN D4 #define ANEMOMETER_PIN D4
#define BME_SCK 13
#define BME_MISO 12
#define BME_MOSI 11
#define BME_CS 10
#define SEALEVELPRESSURE_HPA (1013.25)
#define BME280_ADDRESS 0x76
const char *INFLUXDB_HOST = "influxdb.okoyono.de"; const char *INFLUXDB_HOST = "influxdb.okoyono.de";
const uint16_t INFLUXDB_PORT = 80; const uint16_t INFLUXDB_PORT = 80;
const char *INFLUXDB_DB = "weatherstation"; const char *INFLUXDB_DB = "weatherstation";

22
firmware/firmware.ino Normal file → Executable file
View file

@ -3,7 +3,7 @@
#include <DNSServer.h> #include <DNSServer.h>
#include <ESP8266WebServer.h> #include <ESP8266WebServer.h>
#include <WiFiManager.h> #include <WiFiManager.h>
#include <ESP8266Influxdb.h> #include <ESP8266Influxdb.h> // https://github.com/hwwong/ESP8266Influxdb auchecken und code+header in das firmware verzeichnis kopieren
#include <Adafruit_Sensor.h> // Adafruit Unified Sensor #include <Adafruit_Sensor.h> // Adafruit Unified Sensor
#include <Adafruit_APDS9960.h> // https://github.com/adafruit/Adafruit_APDS9960 #include <Adafruit_APDS9960.h> // https://github.com/adafruit/Adafruit_APDS9960
#include <Adafruit_BME280.h> // https://github.com/adafruit/Adafruit_BME280_Library #include <Adafruit_BME280.h> // https://github.com/adafruit/Adafruit_BME280_Library
@ -59,12 +59,16 @@ void setup() {
// Open the InfluxDB session // Open the InfluxDB session
influxdb.opendb(INFLUXDB_DB, INFLUXDB_USER, INFLUXDB_PASS); influxdb.opendb(INFLUXDB_DB, INFLUXDB_USER, INFLUXDB_PASS);
delay(2000);
// Initialize and configure the sensors // Initialize and configure the sensors
apds.begin(); apds.begin();
apds.enableColor(true); apds.enableColor(true);
bme.begin();
bool status = bme.begin(0x76);
if (!status) {
Serial.println("Could not find a valid BME280 sensor, check wiring!");
while (1);
}
delay(100); delay(100);
} }
@ -72,11 +76,21 @@ void setup() {
void loop() { void loop() {
digitalWrite(STATUS_LED_PIN, LOW); digitalWrite(STATUS_LED_PIN, LOW);
#ifdef DEBUG
Serial.println("---");
digitalWrite(STATUS_LED_PIN, HIGH);
#endif
currentSensorData[SENSOR_TEMPERATURE] = fetchTemperature(); currentSensorData[SENSOR_TEMPERATURE] = fetchTemperature();
Serial.print("*");
currentSensorData[SENSOR_HUMIDITY] = fetchHumidity(); currentSensorData[SENSOR_HUMIDITY] = fetchHumidity();
currentSensorData[SENSOR_LIGHT] = fetchLight(); Serial.print("*");
//currentSensorData[SENSOR_LIGHT] = fetchLight();
Serial.print("*");
currentSensorData[SENSOR_WINDSPEED] = fetchWindspeed(); currentSensorData[SENSOR_WINDSPEED] = fetchWindspeed();
Serial.print("*");
currentSensorData[SENSOR_PRESSURE] = fetchPressure(); currentSensorData[SENSOR_PRESSURE] = fetchPressure();
Serial.println("*");
#ifdef DEBUG #ifdef DEBUG
Serial.println(""); Serial.println("");

5
firmware/influxdb.ino Normal file → Executable file
View file

@ -3,5 +3,8 @@ void pushToInfluxDB(String device, float sensorValues[]) {
influxdb.write("weather,device=" + device + " humidity=" + String(sensorValues[SENSOR_HUMIDITY])); influxdb.write("weather,device=" + device + " humidity=" + String(sensorValues[SENSOR_HUMIDITY]));
influxdb.write("weather,device=" + device + " light=" + String(sensorValues[SENSOR_LIGHT])); influxdb.write("weather,device=" + device + " light=" + String(sensorValues[SENSOR_LIGHT]));
influxdb.write("weather,device=" + device + " windspeed=" + String(sensorValues[SENSOR_WINDSPEED])); influxdb.write("weather,device=" + device + " windspeed=" + String(sensorValues[SENSOR_WINDSPEED]));
influxdb.write("weather,device=" + device + " pressure=" + String(sensorValues[SENSOR_PRESSURE])); int tmp = influxdb.write("weather,device=" + device + " pressure=" + String(sensorValues[SENSOR_PRESSURE]));
Serial.println("Opendb status: " + String(tmp));
} }