Commit f3518cc6 authored by Peter Müller's avatar Peter Müller

Added Readme, Added config option to disable DHT sensor

parent ea47a47e
Pipeline #191 passed with stage
in 1 minute and 13 seconds
# Automatic Watering System
The *Automatic Watering System* uses capacitive sensors to measure the soil moisture.
If the soil is too dry it opens magnetic valves for watering the plants.
It also measures the air temperature and humidity and sends them via 433 MHz radio messages.
Using the 433 MHz radio messages you are able to control and configure the watering system. For this the [RadioHead](http://www.airspayce.com/mikem/arduino/RadioHead/) library is used.
A full description of the *Automatic Watering System* is available at https://crycode.de/diy-automatisches-bewaesserungssystem (in german only).
## Software
The software is based on [PlatformIO](https://platformio.org/).
PlatformIO takes care of all dependencies automatically and you don't need to install anything else by hand.
Alternatively you may use ArduinoIDE for flashing the microcontroller.
Then you have to install the following librarys by hand:
* [RadioHead v1.82](https://platformio.org/lib/show/124/RadioHead/installation)
* [DHTStable v0.2.4](https://platformio.org/lib/show/1337/DHTStable/installation)
* [PinChangeInterrupt v1.2.6](https://platformio.org/lib/show/725/PinChangeInterrupt/installation)
### Configuration using 433 MHz radio messages
To configure the *Automatic Watering System* you may use the control app included in this software package.
The control app is available in the `control` directory.
All needed information are there in the [readme](control/README.md).
## License
Licensed under GPL Version 2
Copyright (c) 2018 Peter Müller <peter@crycode.de> (https://crycode.de/)
......@@ -38,12 +38,11 @@
#define SENSOR_2_ADC A6
#define SENSOR_3_ADC A7
#define BATTERY_ADC A2
#define BRIGHTNESS_ADC A3
/*
* DHT temperature and humidity sensor
*/
// Type of the used Sensor, 11 for DHT11, 12 for DHT12, 22 for DHT22
// Type of the used Sensor, 11 for DHT11, 12 for DHT12, 22 for DHT22, 0 for no Sensor
#define DHT_TYPE 22
/*
......
......@@ -17,35 +17,38 @@ bool adcOn = false;
void loop () {
unsigned long now = millis();
// check if we need to read from the dht sensor
if (checkTime(now, dhtNextReadTime)) {
// read from the sensor using the correct method for the sensor type
#if DHT_TYPE == 11
int dhtResult = dhtSensor.read11(DHT_PIN);
#elif DHT_TYPE == 12
int dhtResult = dhtSensor.read12(DHT_PIN);
#elif DHT_TYPE == 22
int dhtResult = dhtSensor.read22(DHT_PIN);
#else
#error DHT_TYPE must be 11, 12 or 22!
#endif
// check the result
if (dhtResult == DHTLIB_OK) {
// sensor read ok
// send RadioHead message
memcpy(&rhBufTx[1], &dhtSensor.temperature, 4);
memcpy(&rhBufTx[5], &dhtSensor.humidity, 4);
rhSend(RH_MSG_DHTDATA, 9);
// DHT code only if DHT_TYPE is not zero
#if DHT_TYPE != 0
// check if we need to read from the dht sensor
if (checkTime(now, dhtNextReadTime)) {
// read from the sensor using the correct method for the sensor type
#if DHT_TYPE == 11
int dhtResult = dhtSensor.read11(DHT_PIN);
#elif DHT_TYPE == 12
int dhtResult = dhtSensor.read12(DHT_PIN);
#elif DHT_TYPE == 22
int dhtResult = dhtSensor.read22(DHT_PIN);
#else
#error DHT_TYPE must be 11, 12, 22 or 0!
#endif
// check the result
if (dhtResult == DHTLIB_OK) {
// sensor read ok
// send RadioHead message
memcpy(&rhBufTx[1], &dhtSensor.temperature, 4);
memcpy(&rhBufTx[5], &dhtSensor.humidity, 4);
rhSend(RH_MSG_DHTDATA, 9);
} else {
// sensor read error
blinkCode(BLINK_CODE_DHT_ERROR);
}
} else {
// sensor read error
blinkCode(BLINK_CODE_DHT_ERROR);
}
// calc next dht read time
dhtNextReadTime = now + ((uint32_t)settings.dhtInterval * 1000);
}
// calc next dht read time
dhtNextReadTime = now + ((uint32_t)settings.dhtInterval * 1000);
}
#endif
// check if we need to turn on the adc and sensors 1 second before reading the adc values
// this is to give the sensors and the adc some time to reach a stable level
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment