From 0652515727f7d8063c82fddf55246962d3995881 Mon Sep 17 00:00:00 2001 From: klaute Date: Sat, 9 Dec 2017 18:08:37 +0100 Subject: [PATCH] Added som debug messages --- firmware/config.h | 11 ++++++++++- firmware/firmware.ino | 28 +++++++++++++++++++++------- firmware/influxdb.ino | 7 +++++-- 3 files changed, 36 insertions(+), 10 deletions(-) mode change 100644 => 100755 firmware/config.h mode change 100644 => 100755 firmware/firmware.ino mode change 100644 => 100755 firmware/influxdb.ino diff --git a/firmware/config.h b/firmware/config.h old mode 100644 new mode 100755 index 811da32..f590a84 --- a/firmware/config.h +++ b/firmware/config.h @@ -11,10 +11,19 @@ #define STATUS_LED_PIN BUILTIN_LED #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 uint16_t INFLUXDB_PORT = 80; const char *INFLUXDB_DB = "weatherstation"; const char *INFLUXDB_USER = "oko"; const char *INFLUXDB_PASS = "de1873a0d2f8f21f17cf4d8db4f65c59"; -String DEVICE_NAME = "aaron"; +String DEVICE_NAME = "aaron"; diff --git a/firmware/firmware.ino b/firmware/firmware.ino old mode 100644 new mode 100755 index ff439f2..07976d6 --- a/firmware/firmware.ino +++ b/firmware/firmware.ino @@ -3,7 +3,7 @@ #include #include #include -#include +#include // https://github.com/hwwong/ESP8266Influxdb auchecken und code+header in das firmware verzeichnis kopieren #include // Adafruit Unified Sensor #include // https://github.com/adafruit/Adafruit_APDS9960 #include // https://github.com/adafruit/Adafruit_BME280_Library @@ -59,30 +59,44 @@ void setup() { // Open the InfluxDB session influxdb.opendb(INFLUXDB_DB, INFLUXDB_USER, INFLUXDB_PASS); - delay(2000); // Initialize and configure the sensors apds.begin(); 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); } void loop() { digitalWrite(STATUS_LED_PIN, LOW); - + + + #ifdef DEBUG + Serial.println("---"); + digitalWrite(STATUS_LED_PIN, HIGH); + #endif currentSensorData[SENSOR_TEMPERATURE] = fetchTemperature(); + Serial.print("*"); currentSensorData[SENSOR_HUMIDITY] = fetchHumidity(); - currentSensorData[SENSOR_LIGHT] = fetchLight(); + Serial.print("*"); + //currentSensorData[SENSOR_LIGHT] = fetchLight(); + Serial.print("*"); currentSensorData[SENSOR_WINDSPEED] = fetchWindspeed(); + Serial.print("*"); currentSensorData[SENSOR_PRESSURE] = fetchPressure(); + Serial.println("*"); #ifdef DEBUG Serial.println(""); Serial.println("Current readings:"); Serial.println("Temperature: " + String(currentSensorData[SENSOR_TEMPERATURE]) + " °C"); - Serial.println("Humidity: " + String(currentSensorData[SENSOR_HUMIDITY]) + "%"); + Serial.println("Humidity: " + String(currentSensorData[SENSOR_HUMIDITY]) + " %"); Serial.println("Light: " + String(currentSensorData[SENSOR_LIGHT]) + " Lumen"); Serial.println("Windspeed: " + String(currentSensorData[SENSOR_WINDSPEED]) + " Km/h"); Serial.println("Pressure: " + String(currentSensorData[SENSOR_PRESSURE]) + " hPa"); @@ -91,4 +105,4 @@ void loop() { pushToInfluxDB(DEVICE_NAME, currentSensorData); delay(UPDATE_INTERVAL*1000); -} +} diff --git a/firmware/influxdb.ino b/firmware/influxdb.ino old mode 100644 new mode 100755 index 2756d63..c96d1a6 --- a/firmware/influxdb.ino +++ b/firmware/influxdb.ino @@ -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 + " light=" + String(sensorValues[SENSOR_LIGHT])); 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)); + +}