Automatically turning on the light in a greenhouse using Arduino. Thermostat for greenhouses - Designs of medium complexity - Schemes for beginners

This article is not just a list of instructions for replicating my smart greenhouse, I tried to make a real presentation of automation for greenhouses to inspire you.

I wanted to make with my own hands such a smart greenhouse on a microcontroller, in which the plants would not dry out without supervision for several days. The two main factors of plant life in a greenhouse are water and temperature, so the emphasis in the control scheme was placed on these factors.

Brief description of the system:
Rainwater is collected from the roof and stored in tanks. One rain tank has a submersible pump. It pumps water into a feed tank in the greenhouse. The feed tank contains 7 pumps that directly water the plants.

All plants are planted in pots, each of the seven pumps is connected to four pots. In each group of four pots, one contains a soil moisture sensor that transmits data to the Arduino module. In the app on my phone, I can set the humidity level at which it will produce automatic watering these four pots.

There are two temperature sensors installed in the greenhouse. If it gets too hot, a fan turns on to bring cool air from outside into the greenhouse (there are also vents in the roof of the greenhouse automatic ventilation). If the temperature drops too low, a small heater inside the greenhouse comes on to keep the plants from freezing.

In the following paragraphs I will explain the main points of the work different parts systems.

Step 1: Rain Tanks



I have two rainwater tanks connected to a gutter. The tanks are equipped with automatic overfill protection, which requires setting the fill level. The tanks are connected to each other by a hose, so a siphon spillway is carried out between them to achieve the same water level in both tanks.

The tank closest to the greenhouse contains a submersible pump and an ultrasonic sensor that measures the distance to the surface of the water. They are connected to an Arduino module located in the greenhouse, which sends data to my phone. Measuring the distance to the surface will also prevent the pump from turning on if the water level is below the water intake.

Step 2: Makeup Tank

The pump supplies water from the rain tank to the make-up tank located in the greenhouse. It contains seven pumps from cheap windshield washers. Ultrasonic sensor controls the tank fill level, I set the limits to 50% and 75% for automatic mode. Filling occurs from a rainwater tank.

Pumps 1-4 are connected to groups of four pots, pumps 5 and 6 are spare, and pump 7 is connected to a humidifier nozzle. I did the latter as an experiment, pursuing the following goals: the first is to cool the air, and the second is to increase humidity, which cucumbers really like.

Step 3: Soil Moisture Sensors in Pots

Soil moisture sensors collect and send data every half hour. The set value and data from the sensors are reflected on the phone screen, and I can also change the settings from the phone.

Step 4: Turbulent Pot Rack

Hoses run from the pump to the turbulence struts in the four pots.

Step 5: Fan

The operation of the fan depends on the set value in the phone and is controlled by PWM (Pulse Width Modulator), depending on how much higher the current temperature is than the set values.

Step 6: Temperature Sensors

To measure temperature I installed two single wire DS18B20 sensors, one at the top and one at the bottom. Data from them is transmitted every ten minutes. Depending on the readings, I turn on the fan or heater.

Step 7: Humidifier

Spray nozzle for increasing air humidity and cooling if the fan cannot cope.

Step 8: Arduino Control System

Now I will not give a control program for Arduino, while I am attaching a photo of the connection of the board with various relays and others like them. This tangle of wires was caused by the changes I made after each test.

Step 9: Blynk Interface

I am attaching pictures of the interface for greenhouse automation. It was made using the Blynk app.

First picture: shows an indication of low water level in the tanks or a signal error. In both cases I stop the pumps. As well as a graph of historical data on water levels in both tanks.

Second picture: temperature monitoring data, also with a data history graph. Here you can see the set values ​​for the maximum and minimum temperatures in the greenhouse. Average temperatures are shown along with the percentage of fan power when temperatures exceed the set values. You can also see if the heater is working.

Third picture: data from soil moisture sensors and the set value for the start of irrigation. Countdown until the next measurement, interval 30 min. A graph of the measurement history with the readings obtained.
Fourth picture: the ability to control the operation of pumps directly from the phone, mainly for debugging purposes. Also here I can put parts of the system into automatic mode. And set the duration of watering sessions.

Pumps Auto: The rain tank pump and feed tank pumps go into automatic mode, that is, water fills the feed tank and the plants are watered.
Watering 13:00 (watering 13:00): in automatic mode, plants are watered once a day, at 13:00.

Cooling Auto: The fan is in automatic mode and will start running when the temperature rises above the set value. The higher the temperature rises, the higher the fan power.

Heater Auto: The heater is in automatic mode and will start operating as soon as the temperature drops below the set value. The hysteresis is 1°, that is, the heater will turn off as soon as the temperature exceeds the set value by 1 degree.

Greenhouses are designed to provide an optimal microclimate for the growth and development of plants. These can be large industrial buildings or a small place on the windowsill for growing your favorite flower. But even the tiniest greenhouse on the windowsill needs care: watering, maintaining the desired temperature, light level, etc.

Many are happy to take up such farming, but they just don’t have the energy or time for it. And only a dream suggests: if only there was a design that would be so smart that it would do everything itself. Such a greenhouse will be in demand by those who do not want to spend a lot of time caring for plants, and may also not have the opportunity to do this in the event of a long absence - business trips, vacations, etc.
We will begin to create such a greenhouse, let's call it smart. And it will help us create smart greenhouse controller Arduino. What functions will a smart greenhouse perform?
Firstly, it is necessary to quickly obtain all the necessary information about the climatic parameters of our greenhouse: air temperature and humidity, soil temperature and moisture, greenhouse illumination. Those. monitor the climatic parameters of the greenhouse.

What client problem will the monitoring function solve? First of all, it will eliminate concerns about whether everything is okay with the plants during his absence: is there water in the system, has the electricity been turned off, can the ventilation system provide the desired temperature if the room becomes too hot, etc.

You can display monitoring data on the display, or use LEDs to notify about critical values ​​of climate parameters, or receive data via the Internet or on a tablet.
Next, it is necessary to implement the ability to control the greenhouse - watering, heating, ventilating plants, and adjusting the lighting of plants. Control can be done automatically, or remotely (via the Internet or via phone (tablet)).

The next stage is the autonomy function of the greenhouse. When the soil moisture level drops below a certain value, it is necessary to turn on watering; when the temperature in the greenhouse drops, it is necessary to turn on the heating; the illumination of the greenhouse must be carried out according to a certain cycle.

Figure 1. Schematic representation of a smart greenhouse

In our lessons we will look at the practical implementation of a smart greenhouse project. Let's create a smart greenhouse project -
"Home Flower" And let's start with the implementation of the function of monitoring greenhouse parameters. To monitor, we need to obtain the following data about the environment of our flower:

  1. air temperature;
  2. air humidity;
  3. soil moisture;
  4. flower illumination.

To implement the monitoring function we need the following details:

  1. Arduino Uno;
  2. USB cable;
  3. Prototyping board;
  4. Male-male wires – 15 pcs;
  5. Photoresistor – 1 piece;
  6. 10 kOhm resistor – 1 piece;
  7. Temperature sensor TMP36 – 1 piece;
  8. Air temperature and humidity module DHT11 – 1 pc.
  9. Soil moisture module – 1 pc.

Positions 1-6 are available in the “Dare” series kits (“Basic”, “ ” and “Smart Home”), the TMP36 temperature sensor is available in the “Basic” and “Learning Arduino” kits. Links to positions 8 and 9 will be given at the end of the article.
First, let's get acquainted with the sensors that we will use for the monitoring function of the parameters of our project.
Using a photoresistor (Figure 2), illumination is measured. The fact is that in the dark the resistance of the photoresistor is very high, but when light hits it, this resistance drops in proportion to the illumination.

Figure 2. Photoresistor

The TMP36 analog temperature sensor (Figure 2) allows you to easily convert the output voltage level into a temperature reading in degrees Celsius. Every 10 mV corresponds to 1 0C. You can write a formula to convert the output voltage to temperature.

0C = [ (Vout in mV) - 500] / 10

Offset -500 for working with temperatures below 0 0C.

Figure 3. TMP36 analog temperature sensor

The DHT11 sensor consists of a capacitive humidity sensor and a thermistor. In addition, the sensor contains a simple ADC for converting analog values ​​of humidity and temperature. We will use the sensor in the module version for Arduino (Figure 4).

Figure 4. DHT11 module

The soil moisture module (Figure 5) is designed to determine the moisture content of the soil in which it is immersed. It allows you to find out about insufficient or excessive watering of your household or garden plants. The module consists of two parts: a YL-28 contact probe and a YL-38 sensor, the YL-28 probe is connected to the YL-38 sensor via two wires. A small voltage is created between the two electrodes of the YL-28 probe. If the soil is dry, the resistance is high and the current will be less. If the ground is wet, the resistance is less, the current is a little more. Based on the final analog signal, you can judge the degree of humidity.

Figure 5. Soil moisture module

Now let’s assemble the circuit shown in Figure 6 on a breadboard.

Figure 6. Connection diagram for monitoring parameters for “Home Flower”.

Let's start writing the sketch. The photoresistor, TMP36 temperature sensor and soil moisture module are common analog sensors. For the TMP36 sensor, we can convert analog values ​​to temperature readings in degrees Celsius. To work with the DHT11 module we will use the Arduino DHT library (Download). We will measure the data at intervals of 5 seconds and output the values ​​to the Arduino serial port.
Let's create a new sketch in the Arduino IDE, add the code from Listing 1 into it and upload the sketch to the Arduino board. We remind you that in the Arduino IDE settings you must select the board type ( Arduino UNO) and board connection port.

Listing 1.

// connecting the DHT library #include "DHT.h" // DHT sensor type #define DHTTYPE DHT11 // contact for connecting the data input of the DHT11 module int pinDHT11=9; // contact for connecting the analog output of the soil moisture module int pinSoilMoisture=A0; // contact for connecting the analog output of the TMP36 temperature sensor int pinTMP36=A1; // contact for connecting the analog output of the photoresistor int pinPhotoresistor=A2; // instantiating a DHT object DHT dht(pinDHT11, DHTTYPE); void setup() ( // start the serial port Serial.begin(9600); dht.begin(); ) void loop() ( // receive data from DHT11 float h = dht.readHumidity(); if (isnan(h) ) ( Serial.println("Failed to read from DHT"); ) else ( Serial.print("HumidityDHT11= "); Serial.print(h);Serial.println(" %"); ) // getting the value from analog output of the soil moisture module int val0=analogRead(pinSoilMoisture); Serial.print("SoilMoisture= "); Serial.println(val0); // getting the value from the analog output of the TMP36 temperature sensor int val1=analogRead(pinTMP36); // conversion to mV int mV=val1*1000/1024; // conversion to degrees Celsius int t=(mV-500)/10; Serial.print("TempTMP36= "); Serial.print(h);Serial.println( " C"); // getting the value from the analog output of the photoresistor int val2=analogRead(pinPhotoresistor); Serial.print("Light= "); Serial.println(val2); // pause 5 seconds Serial.println(); delay (5000); )

After loading the sketch onto the board, open the serial port monitor and observe the output of values ​​​​with the readings of our sensors (Figure 7).

Figure 7. Outputting values ​​with the readings of our sensors to the Arduino serial port monitor.

And here is our grown flower (Figure 8).

Figure 8. Project “Home Flower”

Viewing sensor readings via a serial port is not entirely convenient; in the next lesson we will look at more

As I already wrote in the last part, initially it was not planned to configure the greenhouse parameters using buttons with display on the display, so I provided buttons and switches in the box.

All this could also be implemented programmatically, but since I’ve already done it, they retain their functionality:

Soil heating switch (heating off / automatic heating on),
- air heating switch (heating off / automatic heating on),
- three-position window opening switch (automation disabled, windows open / automatic window control / automatic disabled, windows closed),
- button for adding water to the tank,
- watering button,
- watering mode switch (once a day / twice a day)
- button for turning on the display backlight, installed on top of the drawer. Turns on the backlight for 30s.

It’s immediately clear that all this is for cases in which something suddenly goes wrong with the automation.
Now about the settings that can be set from the buttons on the panel. This winter, trying to simulate a greenhouse as much as possible, I worked on writing code for a box lying on the table.

So, the main menu consists of 3 items:
1. Settings menu.
2. Setting the date and time.
3. Test program for limit switches and window opening motors.

Everything is clear with setting the date and time. Test program - to connect windows, drive them using buttons, check how they close, whether they are connected correctly, adjust the operation of limit switches, etc.

In the settings menu you can set the following parameters:

1. Watering time.
2. Time of the second watering (if the watering mode is turned on 2 times a day)
3. Water collection time.
4. Window opening temperature.
5. Window closing temperature.
6. Switch-on temperature for soil heating.
7. Soil heating shutdown temperature.
8. Air heating switch-on temperature.
9. Air heating shutdown temperature.

The wife said that since there is no backup and protection if the limit switches do not work, it is also necessary to set the limit for the operation of the pump and window motors. This was a correct and fair remark, so I had to enter the following settings:

10. Limit operating time of window opening motor 1.
11. Limit operating time of the window opening motor 2.
12. Limit operating time of window closing motor 1.
13. Limit operating time of window closing motor 2.
14. Limit pump operating time.
15. Pump operating time to start irrigation.

Now, to illustrate how the menu works, I suggest watching a short video:/p>

Despite the fact that we still had snow in mid-April, I installed the control unit in the greenhouse and connected the heating of the soil (warm floor) for now without automation and heating the air with a heater with automatic control. After a week has passed that the soil has warmed up to 30 degrees, at the time of inspection the heater is turned off, the air temperature is 22 degrees - the sun is already working as it should.
In addition, on April 15, I turned on auto ventilation to observe its operation. You can also see how self-ventilation works in the video:

Tried the following settings:

Window opening 25 degrees;
- closing windows 21 degrees;
- turning on the heater 18 degrees;
- turn off the heater 20 degrees.

The settings turned out to be suboptimal. That is, the temperature outside is 8 degrees and windy. Approximately every 20 minutes the temperature in the greenhouse reached 25 degrees, the windows opened, the greenhouse was quickly ventilated, the windows began to close at 21 degrees, while they were closing, the temperature dropped even lower, so immediately after closing the windows for 5 minutes. the heater turned on.

Changed settings:

Window opening 28 degrees;
- closing windows 22 degrees;
- turning on the heater 16 degrees;
- heater off 19 degrees.

Everything settled down, the greenhouse stopped slamming its windows. Perhaps you need to install a temperature sensor outside and somehow correlate the temperature control in the greenhouse based on its readings.

For two weeks, not only was the automatic temperature maintenance system tested in the greenhouse, but also cucumbers were planted on the 20th of April. Now I’ll tell you about automatic watering. Its design in my greenhouse looks something like this:>

From a large tank, once a day at a certain time (set using the menu), water is poured into a tank located in the greenhouse using a pump. In my case at 10-00. The amount of water is determined by the activation of the float sensor. Just in case, through the menu you can set the maximum operating time of the pump (protection against sensor failure. So, the water has filled:

After this, the water in the tank is heated all day in the greenhouse, which is warm. And in the evening, I have it set at 19-00, the pump turns on for 40 seconds, the water overflows and, by gravity, according to the law of communicating vessels, pours out onto the garden bed:

How I set up automatic watering can also be seen in the video:

In early May, the temperature dropped to -8C on several nights. The heater was working, the temperature in the greenhouse was not lower than +12C, the soil temperature was +20C. Working in this mode revealed the shortcomings of Chinese relays. Despite the fact that the specifications state 10A 250V, and the heater is 1kW, the relay responsible for turning on the air heater began to get warm and “stick.” I had to put a more powerful relay in series. Automatic watering is currently turned on and working. Next week I hope to bring the greenhouse online so that I can observe its parameters on my website.
Currently, the sketch for Arduino looks like this: https://ideone.com/GvHs7u Please do not criticize the code - I am a beginner programmer, but the code is working, which has been proven, albeit for a short time, by operation.

GuyverControl– a universal timer controller for greenhouses and other places where automation is needed using a timer or microclimate indicators/other sensors, has 10 separately configurable control channels, is assembled from inexpensive Chinese components and replaces several “store-bought” controllers for various purposes: control of irrigation, lighting, opening doors and much more. Can be used both for greenhouses/beds, and for aquariums, terrariums, incubators and other automatic systems. Be sure to read the documentation to the controller (links above), all the possibilities are described there in detail. Here's just a short list!

This project is completely open-source, that is, any of you can make your own controller for a greenhouse with your own hands. GyverControl combines a controller for watering, lighting, ventilation and much more. The most important thing is that you can make such a smart greenhouse controller for yourself at cost, i.e. at the retail cost of Chinese components. And it's very cheap.

Iron:

  • ArduinoNano(ATmega 328p) as the main system controller
  • 7 channels with a 5V logical output, to which you can connect a regular relay, solid-state relay, power switches (transistors, transistor-based modules)
  • 2 channels servos, connect conventional model servos of large and small sizes
  • 1 channel control of a linear electric drive with motion limit switches and time-out operation
  • Air temperature sensor ( BME280)
  • Air humidity sensor ( BME280)
  • 4 analog sensors(soil moisture or others)
  • Reference (real) time module RTCDS3231 self-powered
  • Big LCD display(LCD 2004, 20 columns, 4 lines)
  • Government - encoder
  • Supports DHT11/DHT22 humidity, DS18b20 temperature and thermistor sensors

Software features:

  • Storing all settings in non-volatile memory ( do not reset on reboot)
  • Soil moisture sensors (all analog sensors) are not under constant voltage, it is served only at the time of the survey, which allows you to extend the life of even the cheapest soil moisture sensors (voltage is applied 50 ms before polling and turns off 50 ms after).
  • Optimized display data
  • Each of the 10 channels (7 relays, 2 servos and 1 drive) has individual settings and can work by timer or sensors
  • 4-6 operating modes each channel: three different timers and conditional operation from sensors, PID and dawn modes
  • Servo works with my library ServoSmooth, this ensures their smooth movement: smooth acceleration and braking with a maximum speed limit, as well as the absence of jerks and unplanned movements when starting the system
  • The linear drive has limit switches,external buttons for management and speed setting movements. The PWM driver frequency is 31 kHz, i.e. doesn't squeak
  • Debug screen, where all current information about the state of hardware and sensors is displayed
  • Charts air temperature and humidity and readings from analog sensors over the past 24 hours
  • Service menu, allowing you to manually control each piece of hardware

Application as greenhouse/box controller:

  • Periodic watering (relay)
    • Scheme with individual pumps/valves
    • Scheme with one pump and several valves
  • Watering based on readings from soil moisture sensors
  • Lighting control (relay) based on time of day
  • Ventilation (drive opens window/servo opens damper) based on temperature or humidity sensor
  • Humidification (turning on the humidifier) ​​using an air humidity sensor
  • Heating (turning on the heater) by temperature sensor
  • Performing servo-driven actions (pressing buttons on devices, turning handles, turning valves, moving objects) based on a sensor or timer

Application as aquarium controller:

  • Dawn mode for LED strips (via MOSFET) and incandescent lamps (servo drive)
  • PID controller to maintain water temperature
  • Servos (2 pcs) for food reset
  • The remaining channels can be used by timers to run filters/aerators/backlights

Other uses:

  • The system supports 4 analog sensors, these do not necessarily have to be soil moisture sensors, the Chinese have a lot of other “sensor modules” that similar connected to the circuit:
    • Light sensor: smart lighting system, backup lighting
    • Thermistor(up to 80 degrees): object heating control
    • Sound sensor: closing the window when there is a lot of noise outside (why not? =))
    • IR sensor(fire sensor) - different options for signaling, or even extinguishing (turn on the water pump, open the servo tap)
    • Rain sensor: closing windows, signaling, turning on pumps for pumping
    • Water level sensor/water presence sensor: automatic filling of the tank, automatic pumping of water from the tank/basement with a pump, shutting off water lines in case of leakage, leakage alarm
    • Gas analyzers in stock: alarm or even ventilation (open the window) for the level of carbon monoxide and other industrial gases
    • Optic obstacle sensor: imagination is needed here
    • Potentiometer: as an additional system control body
  • The servo drive is quite a universal thing, it can open/close flaps, it can press buttons of other devices, rotate the adjustment knobs of other devices, and with an attached connecting rod it has the ability to linearly move objects/sliders of other devices. There are servos different sizes, from micro (2 kg/cm) and medium (13 kg/cm) to very powerful (50 kg/cm)
  • The relay can close power contacts and control any devices; the relay can also turn on a power supply (for example, an LED strip). The relay can be placed parallel to the wires to the button of another device, and it will turn it on or off.
  • Version 1.4 and higher allows you to maintain the temperature using a PID controller, for
    terrariums/incubators/any temperature maintenance:
    – Apply a PWM signal to the field-effect transistor that controls heating
    – Turn the network dimmer knob using a servo drive
  • Version 1.4 and higher has a Dawn mode that allows you to use the controller for
    aquarium/terrarium and other “animal farms”
  • The main governing body is encoder, the handle of which can rotate and press(it is a button). When the system starts, we get to setting channel 0. By rotating the encoder handle, you can move the selection cursor (arrow) through the menu items. To change the value of the selected item, you need press the encoder knob and turn it while holding it down. You can also click on the button, the cursor will change from an arrow to a check mark > , and by rotating you can change the selected value. Clicking again will return the arrow, which can be used to select another menu item. Hold rotation when the channel name is selected – change the channel for tuning. Scroll to the right and we will have in order 7 relay channels, two servos and a linear drive.
  • To go to setting the mode, you need hover the cursor over it and click the button without turning. A mode settings window will open, which you can exit by clicking on the BACK sign. By holding and rotating the knob on the selected mode name, you can change the mode, there are 4 in total.
  • At the root of the menu(channel selection) scrolling to the left of channel 0 will open the debugging screen ( DEBUG) and service mode ( SERVICE). The debug screen shows all current relay positions, actuators and sensor readings. Rotating the knob on the debugging screen scrolls sequentially daily charts readings from sensors: air temperature, humidity and readings from analog sensors. The divisions on the graph have a step 1.6 hours. On the service screen, you can control any channel in manual mode; when the service screen is active, the automation does not work, the system is completely in manual mode. By turning the knob, you can select the desired channel, servo position or current time setting, and hold the turn to change it.
  • If turn on the system with the handle clamped encoder will happen full reset channels and modes.

Channel operating modes

  1. Timer– simple periodic timer: periods are set PAUSES and time WORKS in the format HH:MM:SS. With the PAUSE period, the selected action is performed and executed during the WORK period. For example, PAUSE costs 1 hour, WORK costs 10 seconds. Every hour there will be an action for 10 seconds, that is, if a relay channel is selected, the relay will turn on and off after 10 seconds, then turn on again after an hour and turn off after 10 seconds and so on. How the channel behaves in the OPERATION section is specified in the DIRECTION parameter, that is, it can be on off And off/on(relay), right left And left right(servo) and open close And close/open(linear actuator). This mode is not tied to real time; rebooting the system resets the current timer. Attention! WORK should not be longer than a PAUSE!
    • Min. value: 1 second
    • Max. value: 999 hours
    • Real time reference: no
  1. TimerRTC– a periodic timer, unlike the previous one, is linked to real time and has a setting PERIOD inclusion and duration WORKS(in seconds) that will be performed, and START– the initial hour from which the period begins ( for periods longer than 2 hours). For example, period 15 minutes, operation 10 seconds: every 15 minutes there will be an action lasting 10 seconds. Linking to real time works as follows: the action will be performed with the selected period from the beginning of the hour, that is, if 15 minutes is selected, then the action will be at 0, 15, 30 and 45 minutes everyone hours. If the selected PERIOD is more than an hour (two or more), then you can select the START hour from which the countdown will begin. All periods are multiples of 24 hours, so work starts at the same hours every day! Example: PERIOD 8 hours, starting hour 0. The action will be performed at 0, 8 and 16 hours of each day. If you set the initial hour (START) to 3 o'clock, then the action will be performed at 3, 11 and 19 o'clock every day. When the power is reset, the next action will be performed at the earliest "alarm" time. Attention! WORK should not be longer than PERIOD!
    • Selectable periods: every 1, 5, 10, 15, 20, 30, 60 minutes and 1, 2, 3, 4, 6, 8, 12, 24 hours
    • Application: watering in hydroponic systems, ventilation without sensor
Period Once a day When it works
1 min 1440 Every minute
3 min 480 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57 min. every hour
5 minutes 288 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55 min. every hour
10 min 144 0, 10, 20, 30, 40, 50 min. every hour
15 minutes 96 0, 15, 30, 45 min. every hour
30 min 48 0.30 min. every hour
1 hour 24 Each hour
2 hours 12 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22 hours of each day (+ shift to start hour)
3 hours 8 0, 3, 6, 9, 12, 15, 18, 21 hours of each day (+ shift to start hour)
4 hours 6 0, 4, 8, 12, 16, 20 hours of each day (+ shift to start hour)
6 hours 4 0, 6, 12, 18 hours of each day (+ shift to start hour)
8 ocloc'k 3 0, 8, 16 hours of each day (+ shift to start hour)
12 hours 2 0.12 hours every day (+ shift to start hour)
24 hours 1 0 o'clock every day (+ shift to start hour)
  1. Week(formerly Day) - a simple timer for one action with reference to real time, has a setting On(time in HH:MM:SS format) – time from which the action is active, and Off(time in HH:MM:SS format) – time from which the action is not active. There are also 7 “cells” - days of the week Days, from Monday to Sunday. When rebooted, the action will return to the desired position according to the current time. Example: The timer is set to 6 and 20 hours (Start and Stop). The action corresponding to the current channel and Direction parameter will be active from 6 am to 8 pm, and inactive from 8 pm to 6 am the next day. In case of a sudden reboot, the system will perform the action as it should be in this period of time, that is, from the previous example, if a sudden reboot occurs between 6 and 20 hours, at startup the system will activate the action through the channel. Attention! On must be less than Off!
    The mode also has a setting Global, which forces any other mode to work “on schedule” Week. What does this give: for example, you can set up watering on Tuesday and Friday from 17 to 18 pm (from a barrel), check the global box and configure the Sensor mode for watering. How it will work: the system will water this channel using the Sensor mode, but will do it only on a schedule (Tuesday and Friday 17-18).
    • Select day of week
    • Time selection: 0-23 hours, multiples of 1 hour
    • Real time reference: yes
    • Application: ideal for lighting and infrequent watering
  1. Sensor– sensor-based action. With polling period PERIOD the selected sensor called SENSOR and when the threshold value is exceeded THRESHOLD the action is performed according to the selected channel (relay/servo/drive). The polling PERIOD is specified in seconds or minutes (as increasing). The sensor is selected from the list: T.VDM.- air temperature, V.VDM. SENS_1 By SENS_4. The THRESHOLD value is set from 0 to 1023 with steps of 1 up to a value of 50 and with steps of 10 starting from 50 (soil moisture sensors have a range of values ​​0-1023). For example, an air temperature sensor is selected, the polling period is 1 hour and the threshold value is 25. Every hour the system checks the temperature; if 25 degrees is exceeded, the action corresponding to the channel will be performed (turn on the relay, open the window). The check will be done again in an hour.
    • Application: opening/closing of flaps based on temperature/humidity (drive), watering based on soil moisture, control of a fan/humidifier (relay) or dampers (servo) based on temperature/humidity.
  1. PID(for channels 3, 4 and servo) – proportional-integral-derivative controller, allows you to maintain the controlled value (heater-temperature, damper-temperature, fan-temperature, fan-humidity, and so on) with high accuracy. The mode is available for channels 3 and 4 (marked with an asterisk), as well as both servo channels in servo mode. Has odds settings P, I, D(You probably won't need D in real work, but it's still there). Choose Sens– input signal source – one of the sensors, as in Sensor mode ( Air t.- air temperature, Air h.– air humidity and 4 analogue sensors (soil humidity) with SENS_1 By SENS_4). Settings Set indicates to what reading value from the selected sensor the regulator will try to bring the system. Settings
    T sets the iteration period of the calculation; for slow processes it makes sense to set it larger (read in the separate chapter “Setting up the PID controller”). Settings min And max are responsible for the minimum and maximum control signal from a given channel, for channels 3 and 4 this is a PWM signal, operating range 0-255. For servo channels this is an angle of 0-180 degrees.
    Application: maintaining a given value (temperature, humidity) in a non-relay way, i.e. smoothly and without sudden inclusions. The PWM signal can control the transistor, which is responsible for the heater. The servo can turn dampers (ventilation) or dimmer knobs to control network heaters, fans and other equipment.
  1. Dawn(for channels 3, 4 and servo) – “dawn” mode for controlling lighting with a smooth dawn and dusk. The mode is available for channels 3 and 4 (marked with an asterisk), as well as both servo channels in servo mode. Smoothly turns on on the hour Start for Dur minutes, then turns off at an hour Stop during Dur minutes. Turns on until maximum value specified in max, and turns off until min. On channels 3 and 4, this value sets the duty cycle of the PWM signal, the operating range is 0 - 255. You can control field effect transistor, For example, LED strip. On servo channels, the operating range is 0 - 180 degrees of rotation of the servo shaft. Can control the mains dimmer knob for incandescent or dimmable LED lamps.
    Application: organization of lighting conditions close to real ones for aquariums, terrariums, chicken coops, etc.

Relay channel settings

  1. Direction– how the relay behaves when activated by a timer/sensor. ON OFF or OFF-ON
  2. TYPE– logic of relay operation
    • Relay– the relay channel behaves like a regular relay and can be used to control any DC or alternating current(manage network devices): watering with individual pumps, watering with individual valves from a pressurized water source, control of humidifiers, heaters, fans, lighting devices and everything else like that. Does not depend on other channels.
    • Valve– a type of relay channel for a system where there is a common pump/valve from a water source and several individual valves for watering different areas. A relay channel configured as a valve simultaneously with its activation (by timer/sensor) activates another channel/channels configured as general.
    • General– a type of relay channel for a system where there is a common pump/valve from a water source and several individual valves for watering different areas. A relay channel configured as common has no mode settings. Instead he activates itself simultaneously with any other channel configured as valve. Automatically deactivates itself if there are no inactive valve channels.

Servo channel settings

  1. Direction– how the servo behaves when activated by a timer/sensor. Turn in direction MIN-MAX angle or vice versa MAX-MIN corner
  2. Limits– servo rotation angles from 0 to 180 degrees in increments of 10
  3. Additionally: in the sketch in the settings section there is a setting for the maximum speed of movement of the servos (SERVO1_SPEED and SERVO2_SPEED) and their acceleration for acceleration and deceleration (SERVO1_ACC and SERVO2_ACC). I did not add them to the settings of the service menu and channels, because... they are not needed very often.

Drive channel settings

  1. Direction– how the drive behaves when activated by a timer/sensor, OPEN CLOSE or CLOSE-OPEN
  2. Time-out– time that the signal to move the drive will be given. The limit switch (if there is one) will interrupt the movement of the drive

Dear Colleagues!
I would like to slightly supplement the publications already available on the forum with a small article that complements the series of accessible automation for summer cottages. STM32 as a series of microprocessors may well complement the group of automation devices built on Arduino.
A little history - why such a system was born in the first place. Just recently I became the proud owner of 140 remontant raspberry bushes, and of course, I planted them. Despite the fact that efforts were made, the result was disastrous. The planting was covered with mulch and equipped drip irrigation- but more than half of the bushes turned out to be unviable by autumn. What’s surprising is that no pests or diseases were noticed. This was precisely the impetus for starting work.
First of all, a water analysis was carried out - and it turned out that the water has a composition that is not very well accepted by raspberries. The sad news is that this means that without a special preparation system it is impossible to use the water that is simply available in excess on the site. Of course, the Internet helps me - and the results are simply shocking... The price of a ready-made system exceeds 270 thousand rubles, and you can’t just buy it - it’s made individually, and for my volume the Sony has too much performance. It became a shame for the country - and now, after a year (!) of work, a system was born that successfully passed tests and this year will control the watering and fertilizing of my plantings. And not only raspberries.
Actually, you will rightly note - this is open landings, and here we are discussing closed ground. Yes - the fact is that my colleague, who has 3 greenhouses, became interested in the project. And now controllers have been made for him in a small series, photos of which you see below

A few technical details - the main board is a debug board with stm32f103c8t6 installed. The power supply is 220V AC, there is a galvanically isolated bus of the RS485 standard and also a galvanically isolated bus of the 1-wire standard. The controller is freely programmable - the commands are fully compatible with the Mitsubishi FX2N controller.
Supports Modbus RTU communication protocol for both master and slave. Also has a 2nd serial data port - but only supports modbus RTU slave.
Thanks to the presence of a 1-wire bus, it easily works with common DS18B20 temperature sensors. Moreover, it supports up to 128 pieces.
I would also like to add to this publication a video of the operation of a system of 4 controllers operating via a modbus bus.

Why did I decide to make such a publication? Yes, it’s very simple - after all, not everyone can pick up a soldering iron and assemble what they need. This controller makes it possible to implement any farmer’s idea or idea without special knowledge.
I described the system a little chaotically - sorry. If you have any questions, you are welcome, I will answer everything as much as possible. Also, if this post is missed, I will publish materials on how this system will be installed in a greenhouse. I hope this experience will be useful.