more comments and typos
This commit is contained in:
parent
3fdbe940b8
commit
29d22e9c98
@ -18,9 +18,7 @@ monitor_speed = 115200
|
||||
lib_deps =
|
||||
439 #ID of Lightsensor library BH1750
|
||||
19 #DHT sensor library
|
||||
; 31 #Adafruit Unified Sensor
|
||||
AutoConnect@^1.1.7
|
||||
AsyncMqttClient@^0.8.2
|
||||
ArduinoJson@^6.15.2
|
||||
PubSubClient@^2.8
|
||||
ArduinoNvs@^2.5
|
||||
|
||||
@ -5,19 +5,22 @@
|
||||
|
||||
const int numReadings = 20;
|
||||
|
||||
// reads soil moisture multiple times and calculates average to eliminate noise
|
||||
int readCapacitiveSoilMoistureSensor() {
|
||||
int total = 0; // the running total
|
||||
// read from the sensor:
|
||||
// read from the sensor
|
||||
for (int readIndex = 0; readIndex < numReadings; readIndex++) {
|
||||
total = total + analogRead(PIN_MS);
|
||||
delay(2);
|
||||
}
|
||||
int measurement = total / numReadings;
|
||||
|
||||
// map measurement to relative soil moisture value in %
|
||||
int finalRes = map(measurement, VALUE_AIR, VALUE_WATER, 0, 100);
|
||||
Serial.print("current soil moisture: ");
|
||||
Serial.println(finalRes);
|
||||
|
||||
// clamp mesurement to a value between 0 and 100
|
||||
if (finalRes < 0) {
|
||||
return 0;
|
||||
} else if (finalRes > 100) {
|
||||
|
||||
@ -120,7 +120,7 @@ void onMqttMessage(char *topic, byte *payload, unsigned int payload_length) {
|
||||
Serial.println();
|
||||
|
||||
if (strcmp(topic, MQTT_LIGHT_PROPERTIES) == 0) {
|
||||
Serial.println("receiving light treshold...");
|
||||
Serial.println("receiving light threshold...");
|
||||
Serial.println(topic);
|
||||
StaticJsonDocument<1024> doc;
|
||||
DeserializationError err = deserializeJson(doc, payload);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user