Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cakraawijaya/aquaponic-ph-control-monitoring-with-type-2-fuzzy-method-based-on-iot-bot
UPN Veteran Jatim | Final Project | Undergraduate Thesis
https://github.com/cakraawijaya/aquaponic-ph-control-monitoring-with-type-2-fuzzy-method-based-on-iot-bot
4-layer adaptor arduino-ide cp210x-driver esp32 fis-matlab fuzzy-type2 iot iot-net it2fl mqtt ph4502c piezoelectric pump relay rtc solenoid-valve switching-psu telegram-bot
Last synced: 7 days ago
JSON representation
UPN Veteran Jatim | Final Project | Undergraduate Thesis
- Host: GitHub
- URL: https://github.com/cakraawijaya/aquaponic-ph-control-monitoring-with-type-2-fuzzy-method-based-on-iot-bot
- Owner: cakraawijaya
- License: mit
- Created: 2022-06-19T10:36:42.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-12-28T07:14:34.000Z (13 days ago)
- Last Synced: 2024-12-28T07:31:26.421Z (13 days ago)
- Topics: 4-layer, adaptor, arduino-ide, cp210x-driver, esp32, fis-matlab, fuzzy-type2, iot, iot-net, it2fl, mqtt, ph4502c, piezoelectric, pump, relay, rtc, solenoid-valve, switching-psu, telegram-bot
- Language: C++
- Homepage: https://www.youtube.com/watch?v=yWIjs6XYV9M
- Size: 22.4 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?style=flat)](https://github.com/ellerbrock/open-source-badges/)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?logo=github&color=%23F7DF1E)](https://opensource.org/licenses/MIT)
![GitHub last commit](https://img.shields.io/github/last-commit/cakraawijaya/Aquaponic-pH-Control-Monitoring-with-Type-2-Fuzzy-Method-Based-on-IoT-Bot?logo=Codeforces&logoColor=white&color=%23F7DF1E)
![Project](https://img.shields.io/badge/Project-ESP32-light.svg?style=flat&logo=espressif&logoColor=white&color=%23F7DF1E)
![Type](https://img.shields.io/badge/Type-Undergraduate%20Thesis-light.svg?style=flat&logo=gitbook&logoColor=white&color=%23F7DF1E)# Aquaponic-pH-Control-Monitoring-with-Type-2-Fuzzy-Method-Based-on-IoT-Bot
Undergraduate Thesis Project Documentation (S1) - Informatics UPN Veteran Jatim
An aquaponic system is a combined farming system between fish with vegetables where the activities are mutually beneficial. On the other hand, crop failure can also be a concern for aquaponic farmers as this can happen at any time. Harvest failure can be influenced by many factors, but is usually caused by the high pH ambiguity of the water around the scope of cultivation. The aquaponic farmers are worried that if the crop failure continues it will harm their food security. This project was created in the hope of solving the pH problem. This project has been carried out and took approximately 1 year. The system created can control and monitor changes in water pH at any time. This system is based on the Internet of Things (IoT), using MQTT as the communication protocol. This system is also equipped with artificial intelligence, which uses IT2FL (Interval Type-2 Fuzzy Logic) as its decision support. In addition, the system interface uses Telegram Bot, making it easier for users to interact.
## Project Requirements
| Part | Description |
| --- | --- |
| Development Board | DOIT ESP32 DEVKIT V1 |
| Supporting Board | Arduino Uno R3 |
| Code Editor | Arduino IDE |
| Application Support | • Telegram Bot
• Matlab R2020 |
| Driver | CP210X USB Driver |
| IoT Platform | io-t.net |
| Communications Protocol | • Inter Integrated Circuit (I2C)
• Message Queuing Telemetry Transport (MQTT)
• MTProto |
| IoT Architecture | 3 Layer |
| Matlab | Fuzzy Interface System |
| Programming Language | C/C++ |
| Arduino Library | • WiFi (default)
• PubSubClient
• LiquidCrystal_I2C
• CTBot
• ArduinoJson
• RTClib |
| Actuators | • Submersible pump aquarium (x1)
• Pneumatic solenoid valve (x2)
• Piezoelectric (x1) |
| Sensor | • pH Sensor (x1)
• RTC (x1) |
| Display | LCD I2C (x1) |
| Experimental Object | • Pakcoy mustard seeds
• Dumbo catfish fry |
| Other Components | • Micro USB cable - USB type A (x1)
• Jumper cable (1 set)
• Switching power supply 12V 1A (x1)
• Electrical relay 2 channel (x1)
• Round switch (x1)
• ESP32 expansion board (x1)
• PCB Dot Matrix (x1)
• Terminal PCB block screw (x10)
• Socket female jack DC (x1)
• Connector male jack DC (x3)
• Probe Elektroda pH (x1)
• Pipes (1 set)
• Netpot (1 set)
• Rockwool (1 set)
• Flannel fabric (1 set)
• Water filter (x1)
• Glass hubcap (1 set)
• Bottle (x2)
• Aquarium wheeled placemat (x1)
• Aquarium (x1)
• Casing box (x1)
• Skun (1 set)
• Galvanized plate (x1)
• Bolts plus (1 set)
• Nuts (1 set) |
## Download & Install
1. Arduino IDE
```
https://www.arduino.cc/en/software
```
2. CP210X USB Driver
```
https://bit.ly/CP210X_USB_Driver
```
3. Matlab R2020
```
https://bit.ly/Matlab_R2020a_Installer
```
## Project Designs
Infrastructure
Pictorial Diagram
Prototype Design
Main Box Design
Fuzzy Interface System IT2FL
IT2FL Input Variable
IT2FL Output Variable
## Scanning the I2C Address on the LCD
```ino
#includevoid setup() {
Wire.begin();
Serial.begin(115200);
while (!Serial); // Wait for serial monitor
Serial.println("\nI2C Scanner");
}void loop() {
int nDevices = 0;
Serial.println("Scanning...");for (byte address = 1; address < 127; ++address) {
// The i2c_scanner uses the return value of the Wire.endTransmission
// To see if a device did acknowledge to the address
Wire.beginTransmission(address);
byte error = Wire.endTransmission();if (error == 0) {
Serial.print("I2C device found at address 0x");
if (address < 16) {
Serial.print("0");
}
Serial.print(address, HEX);
Serial.println(" !");++nDevices;
} else if (error == 4) {
Serial.print("Unknown error at address 0x");
if (address < 16) {
Serial.print("0");
}
Serial.println(address, HEX);
}
}
if (nDevices == 0) {
Serial.println("No I2C devices found\n");
} else {
Serial.println("done\n");
}
delay(5000); // Wait 5 seconds for next scan
}
```
## pH Sensor Calibration
The pH sensor can be calibrated using the results of a linear regression calculation. You can see the linear regression equation as follows.
I
$\ Y = a+b.X $
Explanation of the symbols in equation I, you can see more details in the following table.
Symbol
Description
𝑌
pH buffer value
𝑋
voltage value obtained based on Y
𝑎 and 𝑏
linear regression determination value
The linear regression determination values (a and b) can be obtained through equations II and III.
II
$\ a = \frac{\sum Y.\sum X^{2}-\sum X.\sum XY}{n.\sum X^{2}-(\sum X)^{2}} $
III
$\ b = \frac{n.\sum XY-\sum X.\sum Y}{n.\sum X^{2}-(\sum X)^{2}} $
Example of pH sensor calibration: Click Here
## RTC Sensor Calibration
This RTC sensor can be calibrated using the following program code :
```ino
#include // Calling the RTC library
RTC_DS3231 rtc; // Constructorvoid setup(){
RTCinit(); // Calling the RTCinit method
}void loop(){}
void RTCinit(){
// Starting up the RTC
rtc.begin();// DateTime Setting
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));// Set Time Now
// If calibrated, please close with a comment
rtc.adjust(DateTime(YYYY,MM,DD,HH,MM,SS));
}
```
## Arduino IDE Setup
1. Open the ``` Arduino IDE ``` first, then open the project by clicking ``` File ``` -> ``` Open ``` :
``` PH_IT2FL.ino ```
2. Fill in the ``` Additional Board Manager URLs ``` in Arduino IDE
Click ``` File ``` -> ``` Preferences ``` -> enter the ``` Boards Manager Url ``` by copying the following link :
```
https://dl.espressif.com/dl/package_esp32_index.json
```
3. ``` Board Setup ``` in Arduino IDE
How to setup the ``` DOIT ESP32 DEVKIT V1 ``` board
• Click ``` Tools ``` -> ``` Board ``` -> ``` Boards Manager ``` -> Install ``` esp32 ```.
• Then selecting a Board by clicking: ``` Tools ``` -> ``` Board ``` -> ``` ESP32 Arduino ``` -> ``` DOIT ESP32 DEVKIT V1 ```.• ``` Arduino Uno ``` board in this project is only used as a filter or voltage divider.
• You don't need to configure the ``` Arduino Uno ``` board, just focus on the ``` ESP32 ```.
4. ``` Change the Board Speed ``` in Arduino IDE
Click ``` Tools ``` -> ``` Upload Speed ``` -> ``` 115200 ```
5. ``` Install Library ``` in Arduino IDE
Download all the library zip files. Then paste it in the: ``` C:\Users\Computer_Username\Documents\Arduino\libraries ```
6. ``` Port Setup ``` in Arduino IDE
Click ``` Port ``` -> Choose according to your device port ``` (you can see in device manager) ```
7. Change the ``` WiFi Name ```, ``` WiFi Password ```, and so on according to what you are currently using.
8. Before uploading the program please click: ``` Verify ```.
9. If there is no error in the program code, then please click: ``` Upload ```.
10. Some things you need to do when using the ``` ESP32 board ``` :
• ``` Arduino IDE ``` information: ``` Uploading... ``` -> immediately press and hold the ``` BOOT ``` button.• ``` Arduino IDE ``` information: ``` Writing at .... (%) ``` -> release the ``` BOOT ``` button.
• Wait until the message appears: ``` Done Uploading ``` -> ``` The program is directly operated ```.
• Press the ``` EN (RST) ``` button and then ``` Restart ``` to handle the ``` ESP32 ``` board that cannot process the ``` SC ```.
• Do not press the ``` BOOT ``` and ``` EN ``` buttons at the same time as this may switch to ``` Upload Firmware ``` mode.
11. If there is still a problem when uploading the program, then try checking the ``` driver ``` / ``` port ``` / ``` others ``` section.
## Io-t.net Setup
1. Getting started with io-t.net :
• Go to the official website at the following link : io-t.net.
• If you do not have an account, please Register first -> activate your account via email.
• If you already have an account, please Sign In to be able to access io-t.net services.
2. Create a node :
• Go to ``` Instance ``` menu -> ``` Set Node ```.
• Then give the node a unique name that you use.
3. Create a device :
• Go to ``` Devices ``` menu.
• Select ``` Add Devices ``` -> fill in the ``` Client ID ```, ``` Access ```, ``` Topic ``` sections as needed. For example :
- ``` Client ID ``` -> ``` Phiotnet_v1 ```.- ``` Access ``` -> ``` Publish & Subscribe ```.
- ``` Topic ``` -> ``` detect ```.
## Telegram Bot Setup
1. Open @BotFather.2. Type ``` /newbot ```.
3. Type the desired bot name, for example: ``` phiotnet_bot ```.
4. Type the desired bot username, for example: ``` phiotnet_bot ```.
5. Also do it for bot image settings, bot descriptions, and so on according to your needs.
6. Copy ``` your telegram bot API token ``` -> then paste it into the ``` #define BOTtoken "YOUR_API_BOT_TOKEN" ``` section.
For example :```ino
#define BOTtoken "2006772150:AAE6Fdjk3KbiySkzV6CLbd6ClJDzgTfJ5y0"
```
## Matlab Setup
1. Open the ``` Matlab ```.2. Open the ``` Set Path ``` dialog box using the command :
```
pathtool
```
3. Select ``` Add Folder... ``` -> search the ``` FIS-IT2FLS-Toolbox-MATLAB ``` folder -> ``` Select Folder ```.
4. Click ``` Save ``` and then click ``` Close ```.
5. Open the ``` IT2FL Toolbox ``` using the command :
```
fuzzyt2
```
6. The rest you can customize according to your needs.
## Get Started
1. Download and extract this repository.
2. Make sure you have the necessary electronic components.
3. Make sure your components are designed according to the diagram.
4. Configure your device according to the settings above.5. Please enjoy [Done].
## Demonstration of Application
Via Telegram: @phiotnet_bot
## Highlights
Product
IT2FL Decision Support System
Telegram Bot
More information:• Undergraduate Thesis: Click Here
• SINTA-type journals: Click Here
• Non SINTA-type journals: Click Here
## Notes
-
Hardware Repairs :
1.
Use a standard PSU with a capacity of 3A to supply all installed devices.
2.
Add a Step Down Converter to get a more stable voltage and in accordance with the needs of the device. With this component, there is no need for an Arduino Uno.
3.
Add insulators to electrical components to prevent leakage current.
4.
Install cooling fans or additional ventilation to increase airflow and prevent overheating.
5.
Add Heat Sinks to heat-prone components.
6.
Change the Relay setting from NO (Normally Open) to NC (Normally Close) to reduce overheating in the Solenoid Valve.
7.
Use physical protection such as a special case to protect the pH Sensor Probe from damage, especially from impact.
-
Firmware Repairs :
1.
Replace the delay function with millis() to manage time without stopping the execution of other functions.
2.
Optimize the algorithm to reduce latency in the decision-making process. It is recommended to use RTOS (Real-Time Operating System) in order to better prioritize the functions.
3.
Add OTA (Over The Air) methods to improve network security, including Telegram Bot.
-
Suggested Additional Automation Features :
1.
Automatic pump integrated with a level sensor to control liquid filling in the form of pH and AB Mix.
2.
Time-based automatic feeding for scheduled feeding.
3.
Automatic pump controlled via telegram bot to simplify the process of draining and replenishing water.
4.
Monitoring water quality in ponds or aquariums using a combination of pH, water temperature, and ammonia sensors.
5.
Plant irradiation with growth lamps to grow plants optimally even in low light conditions (as a substitute for sunlight).
-
Media and Infrastructure Optimization :
1.
Increase the number of hydroponic modules to accommodate more plants.
2.
Exploration of alternative growing media such as husk charcoal or cocopeat to improve plant growth efficiency.
## Appreciation
If this work is useful to you, then support this work as a form of appreciation to the author by clicking the ``` ⭐Star ``` button at the top of the repository.
## Disclaimer
This application is my own work and is not the result of plagiarism from other people's research or work, except those related to third party services which include: libraries, frameworks, and so on.
## LICENSE
MIT License - Copyright © 2022 - Devan C. M. Wijaya, S.Kom
Permission is hereby granted without charge to any person obtaining a copy of this software and the software-related documentation files to deal in them without restriction, including without limitation the right to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons receiving the Software to be furnished therewith on the following terms:
The above copyright notice and this permission notice must accompany all copies or substantial portions of the Software.
IN ANY EVENT, THE AUTHOR OR COPYRIGHT HOLDER HEREIN RETAINS FULL OWNERSHIP RIGHTS. THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, THEREFORE IF ANY DAMAGE, LOSS, OR OTHERWISE ARISES FROM THE USE OR OTHER DEALINGS IN THE SOFTWARE, THE AUTHOR OR COPYRIGHT HOLDER SHALL NOT BE LIABLE, AS THE USE OF THE SOFTWARE IS NOT COMPELLED AT ALL, SO THE RISK IS YOUR OWN.