Merge branch 'develop' into sherzog_dev
This commit is contained in:
commit
09c045fd2e
@ -14,5 +14,6 @@ board = az-delivery-devkit-v4
|
|||||||
framework = arduino
|
framework = arduino
|
||||||
|
|
||||||
lib_deps =
|
lib_deps =
|
||||||
# ID of Lightsensor library BH1750
|
439 #ID of Lightsensor library BH1750
|
||||||
439
|
19 #DHT sensor library
|
||||||
|
31 #Adafruit Unified Sensor
|
||||||
@ -19,7 +19,7 @@ void setupCapacitiveSoilMoistureSensor() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loopCapacitiveSoilMoistureSensor() {
|
int loopCapacitiveSoilMoistureSensor() {
|
||||||
// subtract the last reading:
|
// subtract the last reading:
|
||||||
total = total - readings[readIndex];
|
total = total - readings[readIndex];
|
||||||
// read from the sensor:
|
// read from the sensor:
|
||||||
@ -37,5 +37,6 @@ void loopCapacitiveSoilMoistureSensor() {
|
|||||||
|
|
||||||
// calculate the average:
|
// calculate the average:
|
||||||
average = total / numReadings;
|
average = total / numReadings;
|
||||||
Serial.println(average);
|
|
||||||
|
return average;
|
||||||
}
|
}
|
||||||
12
src/header.h
12
src/header.h
@ -6,14 +6,24 @@
|
|||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
|
#include <SPI.h>
|
||||||
#include <BH1750.h>
|
#include <BH1750.h>
|
||||||
|
#include <Adafruit_Sensor.h>
|
||||||
|
#include <DHT.h>
|
||||||
|
#include <DHT_U.h>
|
||||||
|
|
||||||
|
|
||||||
extern int meineVariable;
|
extern int meineVariable;
|
||||||
|
|
||||||
// moisture
|
// moisture
|
||||||
extern void setupCapacitiveSoilMoistureSensor();
|
extern void setupCapacitiveSoilMoistureSensor();
|
||||||
extern void loopCapacitiveSoilMoistureSensor();
|
extern int loopCapacitiveSoilMoistureSensor();
|
||||||
|
|
||||||
// light
|
// light
|
||||||
extern void setupLightSensor();
|
extern void setupLightSensor();
|
||||||
extern int readLightSensorValue();
|
extern int readLightSensorValue();
|
||||||
|
|
||||||
|
// temperature & humidity
|
||||||
|
extern void setupTemperatureSensor();
|
||||||
|
extern int readHumidity();
|
||||||
|
extern int readTemperature();
|
||||||
17
src/main.cpp
17
src/main.cpp
@ -8,6 +8,7 @@ void setup() {
|
|||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
setupCapacitiveSoilMoistureSensor();
|
setupCapacitiveSoilMoistureSensor();
|
||||||
setupLightSensor();
|
setupLightSensor();
|
||||||
|
setupTemperatureSensor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
@ -16,6 +17,18 @@ void loop() {
|
|||||||
Serial.print(lxValue);
|
Serial.print(lxValue);
|
||||||
Serial.println(" lx");
|
Serial.println(" lx");
|
||||||
|
|
||||||
loopCapacitiveSoilMoistureSensor();
|
uint16_t mstValue = loopCapacitiveSoilMoistureSensor();
|
||||||
delay(200); // delay in between reads for stability
|
Serial.print("Soil moisture: ");
|
||||||
|
Serial.println(mstValue);
|
||||||
|
|
||||||
|
uint16_t humidityValue = readHumidity();
|
||||||
|
Serial.print("Humidity: ");
|
||||||
|
Serial.println(humidityValue);
|
||||||
|
|
||||||
|
uint16_t temperatureValue = readTemperature();
|
||||||
|
Serial.print("Temperature: ");
|
||||||
|
Serial.println(temperatureValue);
|
||||||
|
Serial.print("\n");
|
||||||
|
|
||||||
|
delay(2000); // delay in between reads for stability
|
||||||
}
|
}
|
||||||
32
src/temperatureSensor.cpp
Normal file
32
src/temperatureSensor.cpp
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#include <header.h>
|
||||||
|
|
||||||
|
#define DHTPIN 4
|
||||||
|
|
||||||
|
#define DHTTYPE DHT11
|
||||||
|
|
||||||
|
|
||||||
|
DHT_Unified dht(DHTPIN, DHTTYPE);
|
||||||
|
|
||||||
|
void setupTemperatureSensor() {
|
||||||
|
Serial.begin(9600);
|
||||||
|
dht.begin();
|
||||||
|
Serial.println(F("DHT11 Unified Sensor Ready"));
|
||||||
|
sensor_t sensor;
|
||||||
|
dht.temperature().getSensor(&sensor);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get humidity event and its value.
|
||||||
|
int readHumidity(){
|
||||||
|
|
||||||
|
sensors_event_t event;
|
||||||
|
dht.humidity().getEvent(&event);
|
||||||
|
return event.relative_humidity;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get temperature event and its value.
|
||||||
|
int readTemperature(){
|
||||||
|
sensors_event_t event;
|
||||||
|
dht.temperature().getEvent(&event);
|
||||||
|
return event.temperature;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user