Merge branch 'develop' into sherzog_dev
This commit is contained in:
commit
c9dc8f545f
@ -1,5 +1,6 @@
|
|||||||
#include <header.h>
|
#include <ArduinoJson.h>
|
||||||
#include <ArduinoNvs.h>
|
#include <ArduinoNvs.h>
|
||||||
|
#include <header.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
//using namespace std;
|
//using namespace std;
|
||||||
@ -8,12 +9,9 @@ extern "C" {
|
|||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MQTT_MOISTURE MQTT_PATH_PUB "moisture"
|
#define MQTT_SENSOR_DATA MQTT_PATH_PUB "data"
|
||||||
#define MQTT_TEMPERATURE MQTT_PATH_PUB "temperature"
|
|
||||||
#define MQTT_HUMIDITY MQTT_PATH_PUB "humidity"
|
|
||||||
#define MQTT_BRIGHTNESS MQTT_PATH_PUB "brightness"
|
|
||||||
|
|
||||||
char buffer[16];
|
char buffer[128];
|
||||||
|
|
||||||
// Feldkapazität des Bodens in Prozent: Standard ist Humus
|
// Feldkapazität des Bodens in Prozent: Standard ist Humus
|
||||||
int fieldCapacity = 44;
|
int fieldCapacity = 44;
|
||||||
@ -23,31 +21,38 @@ int permanentWiltingPoint = 25;
|
|||||||
int soilSaturation = 69;
|
int soilSaturation = 69;
|
||||||
|
|
||||||
void readSensors() {
|
void readSensors() {
|
||||||
|
StaticJsonDocument<128> doc;
|
||||||
float lxValue = readLightSensorValue();
|
float lxValue = readLightSensorValue();
|
||||||
Serial.print("Light intensity: ");
|
Serial.print("Light intensity: ");
|
||||||
Serial.print(lxValue);
|
Serial.print(lxValue);
|
||||||
Serial.println(" lx");
|
Serial.println(" lx");
|
||||||
sprintf(buffer, "%f", lxValue);
|
doc["brightness"] = lxValue;
|
||||||
publishMessage(MQTT_BRIGHTNESS, buffer);
|
//sprintf(buffer, "%f", lxValue);
|
||||||
|
//publishMessage(MQTT_BRIGHTNESS, buffer);
|
||||||
|
|
||||||
int mstValue = readCapacitiveSoilMoistureSensor();
|
int mstValue = readCapacitiveSoilMoistureSensor();
|
||||||
Serial.print("Soil moisture: ");
|
Serial.print("Soil moisture: ");
|
||||||
Serial.println(mstValue);
|
Serial.println(mstValue);
|
||||||
sprintf(buffer, "%i", mstValue);
|
// sprintf(buffer, "%i", mstValue);
|
||||||
publishMessage(MQTT_MOISTURE, buffer);
|
// publishMessage(MQTT_MOISTURE, buffer);
|
||||||
|
doc["moisture"] = mstValue;
|
||||||
|
|
||||||
float humidityValue = readHumidity();
|
float humidityValue = readHumidity();
|
||||||
Serial.print("Humidity: ");
|
Serial.print("Humidity: ");
|
||||||
Serial.println(humidityValue);
|
Serial.println(humidityValue);
|
||||||
sprintf(buffer, "%f", humidityValue);
|
// sprintf(buffer, "%f", humidityValue);
|
||||||
publishMessage(MQTT_HUMIDITY, buffer);
|
// publishMessage(MQTT_HUMIDITY, buffer);
|
||||||
|
doc["humidity"] = humidityValue;
|
||||||
|
|
||||||
float temperatureValue = readTemperature();
|
float temperatureValue = readTemperature();
|
||||||
Serial.print("Temperature: ");
|
Serial.print("Temperature: ");
|
||||||
Serial.println(temperatureValue);
|
Serial.println(temperatureValue);
|
||||||
sprintf(buffer, "%f", temperatureValue);
|
// sprintf(buffer, "%f", temperatureValue);
|
||||||
publishMessage(MQTT_TEMPERATURE, buffer);
|
// publishMessage(MQTT_TEMPERATURE, buffer);
|
||||||
|
doc["temperature"] = temperatureValue;
|
||||||
Serial.print("\n");
|
Serial.print("\n");
|
||||||
|
serializeJson(doc, buffer);
|
||||||
|
publishMessage(MQTT_SENSOR_DATA, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool openValve() {
|
bool openValve() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user