davemaster / Irrigation-3021

How Bluetooth Technology can improve the use of water resources worldwide

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Irrigation-3021

imagen(https://blogs.embarcadero.com/building-good-with-cbuilder-contest-results/)

https://blogs.embarcadero.com/building-good-with-cbuilder-contest-results/ https://youtube.com/embed/tNYx-wSfjVc

imagen

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.

Project Resume

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.

Needed Parts

  1. 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!!!.

imagen

  1. Arduino Board: UNO, NANO, MEGA, etc. https://www.arduino.cc/en/Main/Products

imagen

  1. HC-05 Bluetooth Module https://www.siarperu.com/store/#view=00011&busq=hc-05

imagen

  1. A 12V solenoid Valve https://www.sparkfun.com/products/10456

imagen

  1. Some Protoboards cabling, female-male, male-male or female-female https://naylampmechatronics.com/accesorios-y-prototipado/26-cable-para-protoboard.html

imagen

  1. Sensors for Humidity moisture, rain intensitivity, and water level:

imagen imagen imagen

Needed Software

  1. Embarcadero C++ Builder 10.3 Community Edition https://www.embarcadero.com/products/cbuilder/starter or lastest https://embarcadero.com/products/cbuilder

imagen

  1. Arduino IDE 1.8.15 https://www.arduino.cc/en/software

imagen

  1. Any Serial Terminal (for PC Windows or Mac where the C++ Builder is installed)

imagen

  1. 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.

    imagen

    imagen

  2. In my particular case, I used the scrcpy for see my project (Irrigation 3021) in its Android versión. https://github.com/Genymobile/scrcpy

imagen

imagen

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);
	}

..................................

imagen

About

How Bluetooth Technology can improve the use of water resources worldwide

License:GNU General Public License v2.0


Languages

Language:C++ 97.4%Language:Prolog 2.6%Language:C 0.1%