https://youtube.com/embed/tNYx-wSfjVc
How Bluetooth Technology can improve the use of water resources worldwide. Programming using C++ Builder 10.3 Community Edition was surprisly very faster than the turtle of Android Studio and its eternal indexing-nightmares; So, its time to move forward using this IDE, in this project, using the multi-device features.
The goal, more control over the water use in irrigation issues, first in my mom's garden, then in the city parks, then Farmlands, then in any water distribution activity worldwide. Thanks to the Building Good with C++Builder Contest for giving this oportunity.
The system is going to use a bluetooth capable device to control a valve to irrigate a plant. The control-device can be a laptop/pc or a smartphone (Android or iOS). These devices control through bluetooth wireless link an Arduino UNO board connected to a HC-05 bluetooth module; so this last can open/close the solenoid valve by a relay; according the following modes: 1. Based on sensors (humidity, water tank level, and rain intensitivity) the Arduino will decide when to open/close the valve to properly water the plant. The sensors values will be compared with setpoints to make decisions. Mode 2. Test mode, we can open/close valve no matter the sensors values. Mode 3, using irrigation schedules, ie, time defined periods when the valve will be open.
- Mobile Phone: Iphone, Android or laptop/pc Bluetooth capable. C++ Builder 10.3 can program them all with ONE project at the same time; pretty GOOD!!!.
- Arduino Board: UNO, NANO, MEGA, etc. https://www.arduino.cc/en/Main/Products
- HC-05 Bluetooth Module https://www.siarperu.com/store/#view=00011&busq=hc-05
- A 12V solenoid Valve https://www.sparkfun.com/products/10456
- Some Protoboards cabling, female-male, male-male or female-female https://naylampmechatronics.com/accesorios-y-prototipado/26-cable-para-protoboard.html
- Sensors for Humidity moisture, rain intensitivity, and water level:
- Embarcadero C++ Builder 10.3 Community Edition https://www.embarcadero.com/products/cbuilder/starter or lastest https://embarcadero.com/products/cbuilder
- Arduino IDE 1.8.15 https://www.arduino.cc/en/software
- Any Serial Terminal (for PC Windows or Mac where the C++ Builder is installed)
-
Proteus 8.6 with Arduino libraries for simulate Arduino valve control and the sensors attached (humidity, water leve, and rain) lectures and response of the valve control system (circuit and firmware) to commands from Irrigation 3021 app programmed in C++ Builder.
-
In my particular case, I used the scrcpy for see my project (Irrigation 3021) in its Android versión. https://github.com/Genymobile/scrcpy
SOURCE CODE UPDATED
In file BTReadThread.cpp, the following changes has been made:
.................................
else if(cmd==2) { dataFromArduino=Socket->ReceiveData();
if(dataFromArduino.Length>0)
{
StrReceived = TEncoding::ASCII->GetString(dataFromArduino);
/*************************************/
AllReceivedData+=StrReceived;
msg=AllReceivedData;
Synchronize(TabbedForm->WriteMemo);
if(AllReceivedData.Length()>12)
{
sensors=AllReceivedData;
Synchronize(TabbedForm->UpdateValueSensors);
AllReceivedData="";
Sleep(100);
}
#ifndef __ANDROID__
else
AllReceivedData="";
#endif
/*****************************************/
/*msg=StrReceived;
Synchronize(TabbedForm->WriteMemo);
if(msg.Length()>3)
{
sensors=StrReceived;
Synchronize(TabbedForm->UpdateValueSensors);
} */
}
Sleep(100);
}
..................................