|
In this series, we will analyze examples of the application of Kincony controllers in solving cases from practical applications. Practical cases are usually not complex, but they solve important things in the production process. In some cases, mistakes can cause large losses in production. Such systems need to be approached seriously.
author: wrote by Nebojsa from Croatia
Case study: Greenhouse temperature management
The user owns a greenhouse for growing vegetables. Summer temperature inside the greenhouse should not exceed 35oC. At a temperature of > 40oC the plants begin to be irreversibly destroyed.
When the temperature reaches 30oC, the automation system should immediately send an e-mail warning to the responsible person and start the industrial fans to injecting cooler air. If the temperature continues to rise and reaches (set + 4oC) 34oC, the system should start opening the sides via automatic actuators.
When the temperature drops below 30oC, it is necessary to stop the ventilation and close the sides.
Reading the current temperature inside the greenhouse, and changing the system parameters can be done through the website on the local network.
We will use these components:
KC868-A4 controller
Temperature sensor DS18B20
Contactors, 1 x 2NO; 1 x 1NO – 1 NC
Program structure:
This block enable data entry over LAN Web. Start any web browser and in address field enter IP what see after start program over Arduino IDE (for example: 192.168.8.153 as can see on screen)
Programing details
In my series of case studies will not so much fokusing on programming details. Some interesting parts of programs will be comented in source code.
I think you have read the published articles about the KC868-A4 controller, but to note in the Tools menu you should choose Board: NodeMCU 32S.
Include the necessary libraries via Manage Libraries ...
Included libraries:
#include <WiFi.h> // Enables network connection.
#include <AsyncTCP.h> // This is a fully asynchronous TCP library
#include <ESPAsyncWebServer.h> // Async HTTP and WebSocket Server
#include <OneWire.h> // Access 1-wire devices as temp. sensors
#include <DallasTemperature.h> // Library for Dallas Temperature ICs
#include "ESP32_MailClient.h" // Mail Client Arduino Library for ESP32
#include "time.h" // Date and Time functions, NTP sync.
Slanje maila preko KC868-A4
We recommend that you create a new mail, and do not use your existing mail account. This mail will be used to send emails. On this occasion, I opened a new gmail.com account via the link.
In the Select app field, choose mail and password.
The SMTP server settings for the sender email. - SMTP Server: gmail.com
- SMTP username: Complete Gmail address
- SMTP password: Your Gmail password
- SMTP port (TLS): 587
- SMTP port (SSL): 465
- SMTP TLS/SSL required: yes
// To send Email using Gmail use port 465 (SSL) and SMTP Server smtp.gmail.com
const String emailSenderAccount = "your mail@gmail.com";
const String emailSenderPassword = "your password";
const String smtpServer = "smtp.gmail.com";
const int smtpServerPort = 465;
The mailing address for reception, can be our existing mail or any other.
KC868-A4 Mailing source program download here.
Run the temperature mailing notification
Start Tools -> Serial monitor
First start WiFi connecting over assign SSID and password of the router WiFi.
Remember this IP address, will need later.
The program provided the date and time via an internet NTP server. It is important for real time the temperature monitoring. After this program read temperature from DS18B20 sensor.
As the case study defined, the temperature less than 30oC mean normal situation, no any action and there is no need to turn on the cooling, the fan stay Off and wall is closed.
After the temperature exceeds the set limit (30oC), ventilation is switched on (Fan -> ON), system send Alert mail to defined address, but the wall actuators stay closed.
If the temperature continues to rise and reaches 4oC more than the set limit, the actuator is started to open the sides of the greenhouse. State: Fan -> On; Wall -> Open.
If the temperature starts to drop, the fan will continue to run until it falls below the set limit. The sides will also be open during this time. When the temperature falls below the set limit, the system sends an e-mail to the user to inform him that the temperature has returned to normal, the fan is stopped and the side walls of the greenhouse are closed.
Received mail when temperature goes over the defined limit:
Received mail when temperature again become the normal:
Temperature readings and settings can be performed via a web browser. We need to start our web browser (any), enter the IP address obtained at the beginning, we will get the web page as shown below.
The HTML code generated by the specified screen was created in our program. We will not go into deeper explanations, we would just look the HTML code.
Hardware system configuration
Conclusion:
This case study like all others can be performed in many ways. One solution is presented here. The Kincony controller KC868-A4 was used, the Arduino IDE was used for programming. For settings see the link about KC868-A4. The plan is to process several different projects related to practical applications.
If you have any questions, suggestions or comments, write to info@edata.hr
|