Bugfix array size

This commit is contained in:
klaute 2017-12-09 19:10:31 +01:00
parent f7c1d4dee9
commit 284e3940ea
3 changed files with 21 additions and 21 deletions

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

@ -26,7 +26,7 @@
* - https://github.com/marvinroger/homie-esp8266 * - https://github.com/marvinroger/homie-esp8266
*/ */
float currentSensorData[4] = {0.0, 0.0, 0.0, 0.0}; float currentSensorData[5] = {0.0, 0.0, 0.0, 0.0, 0.0};
WiFiManager wifiManager; WiFiManager wifiManager;
@ -64,7 +64,7 @@ void setup() {
// Initialize and configure the sensors // Initialize and configure the sensors
//apds.begin(); //apds.begin();
//apds.enableColor(true); //apds.enableColor(true);
//bme.begin(); bme.begin(0x76);
delay(100); delay(100);
} }
@ -73,22 +73,22 @@ void loop() {
digitalWrite(STATUS_LED_PIN, LOW); digitalWrite(STATUS_LED_PIN, LOW);
currentSensorData[SENSOR_TEMPERATURE] = fetchTemperature(); currentSensorData[SENSOR_TEMPERATURE] = fetchTemperature();
//currentSensorData[SENSOR_HUMIDITY] = fetchHumidity(); currentSensorData[SENSOR_HUMIDITY] = fetchHumidity();
//currentSensorData[SENSOR_LIGHT] = fetchLight(); //currentSensorData[SENSOR_LIGHT] = fetchLight();
//currentSensorData[SENSOR_WINDSPEED] = fetchWindspeed(); // currentSensorData[SENSOR_WINDSPEED] = fetchWindspeed();
//currentSensorData[SENSOR_PRESSURE] = fetchPressure(); currentSensorData[SENSOR_PRESSURE] = fetchPressure();
#ifdef DEBUG #ifdef DEBUG
Serial.println(""); Serial.println("");
Serial.println("Current readings:"); Serial.println("Current readings:");
Serial.println("Temperature: " + String(currentSensorData[SENSOR_TEMPERATURE]) + " °C"); 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("Light: " + String(currentSensorData[SENSOR_LIGHT]) + " Lumen");
//Serial.println("Windspeed: " + String(currentSensorData[SENSOR_WINDSPEED]) + " Km/h"); Serial.println("Windspeed: " + String(currentSensorData[SENSOR_WINDSPEED]) + " Km/h");
//Serial.println("Pressure: " + String(currentSensorData[SENSOR_PRESSURE]) + " hPa"); Serial.println("Pressure: " + String(currentSensorData[SENSOR_PRESSURE]) + " hPa");
#endif #endif
pushToInfluxDB(DEVICE_NAME, currentSensorData); pushToInfluxDB(DEVICE_NAME, currentSensorData);
delay(UPDATE_INTERVAL*1000); delay(UPDATE_INTERVAL*1000);
} }

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

@ -1,7 +1,7 @@
void pushToInfluxDB(String device, float sensorValues[]) { void pushToInfluxDB(String device, float sensorValues[]) {
influxdb.write("weather,device=" + device + " temperature=" + String(sensorValues[SENSOR_TEMPERATURE])); influxdb.write("weather,device=" + device + " temperature=" + String(sensorValues[SENSOR_TEMPERATURE]));
//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])); influxdb.write("weather,device=" + device + " pressure=" + String(sensorValues[SENSOR_PRESSURE]));
} }

12
firmware/sensors.ino Normal file → Executable file
View file

@ -2,17 +2,17 @@ int anemometerRotations = 0;
unsigned long currentTime = 0; unsigned long currentTime = 0;
float fetchTemperature() { float fetchTemperature() {
return 10; //return 10;
//return bme.readTemperature(); return bme.readTemperature();
} }
float fetchPressure() { float fetchPressure() {
return 10; //return 10;
//return bme.readPressure() / 100.0F; return bme.readPressure() / 100.0F;
} }
float fetchHumidity() { float fetchHumidity() {
//return bme.readHumidity(); return bme.readHumidity();
} }
float fetchLight() { float fetchLight() {
@ -41,4 +41,4 @@ float fetchWindspeed() {
return (float)anemometerRotations / 5.0 * 2.4; return (float)anemometerRotations / 5.0 * 2.4;
} }