Soil Monitoring and Irrigation of LoRa
by Lan_Makerfabs in Circuits > Wireless
1969 Views, 24 Favorites, 0 Comments
Soil Monitoring and Irrigation of LoRa
Hello, this is Makerfabs! last time we seek help from the environmental authorities. and all the Science and Technology Industrial Park had checked the releasing pollutants. Now, that's a good start. at the same time, I think the greening of our science and technology industrial park is doing well, but it lacks some intelligent ways to manage. It suddenly occurred to me that LoRa could be used to control soil moisture, so that it would not cost a lot of manpower to irrigate flowers and plants.
Supplies
- Lora Soil Monitoring, to get all the components by this kit.
Lora Technology
LoRa stands for Long Range Radio, it is flexible for rural or indoor use cases such as smart agriculture, and smart cities, mainly targeted for M2M. Theoretically, LoRa arranges can be up to a few kilometers in urban areas, and more than 10 kilometers in rural areas (but as for me, I do not test it so long, the max distance tested is about 3 kilometers).
LoRaWAN is software protocol, that deals with the LoRa messages and communication back and forth with the internet. LoRaWAN needs a stronger controller ability to deal with the protocol and also LoRaWAN Router for internet connection. Maybe we will use this technology in other project next time.
Instruments Introduction
2.1 Soil Monitoring sensor.
Makerfabs LoRa soil moisture sensor
For soil monitoring instrument, the core spec:
- Soil spec checking, basically: humidity/temperature; and if necessary advanced spec: PH/Nitrogen/ Phosphorus/Potassium.(Industrial grade)
- Wireless data transmission, and long life-time
- Anti-corrosion
The Makerfabs Soil Moisture Sensor measures the soil humidity (with capacitive mechanism, detailed info ) & temperature and sends the data via LoRa every 1 hour. it is anti-corrosion coated. With a 2 AAA battery, the lifetime can be up to 2 years. It is shipped with pre-program firmware, which users can install the battery and then use directly. For more details, check the wiki. But note that for humidity, its output is “relative humidity”, which is not a “real humidity” but values reflect the humidity changes. Such as values < 500 mean the soil is soaked, while >800 mean very dry. Also, it differs a little depending on how the sensor is installed.
2.2 ESP32 TFT Touch with LoRa expansion
The ESP32 3.5 inch Display with LoRa expansion work as the control console, that it receive soil status from multiple points, and send commands to the LoRa MOSFET, to control the valve open/close.
2.3 LoRa Actuator
This cheap& easy to use LoRa MOSFET can be used to control multiple actuators such as fans/valves/electromagnetic lock/ motors…with max current 2A. It is shipped with Makerfabs default firmware(code available on GitHub), which users can use without any coding/programming. It receives the LoRa messages and acts as the commands (0%~100% by PWM), and feedback on its status to other LoRa modules. We can use this module to control up to 4 valves, and then to control irrigation of 4 points.
Set WiFi in the SD Card
Plug the LoRa expansion board into the ESP32 display breakout board, and program it with the codes at GitHub. Set the WiFi connection parameters in the SD card.
Set a file named wifi.txt in the SD card, open the file, input the configuration of the username and password about the WiFi, save the file and insert the SD card to ESP32 3.5 inch Display. The following program reads the file automatically.
int wifi_init()
{
Serial.println("Prepare Link Wifi");
WiFi.begin(ssid, pwd);
int connect_count = 0;
//10S未连接上自动跳过并返回0
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
connect_count++;
if (connect_count > 20)
{
Serial.println("Wifi time out");
return FALSE;
}
}
// 成功连接上WIFI则输出IP并返回1
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
configTime(28800, daylightOffset_sec, ntpServer);
// configTime((const long)(timezone * 3600), daylightOffset_sec, ntpServer);
Serial.println(F("Alread get npt time."));
return SUCCESS;
Power up ESP32 display, after 3 seconds of logo display, it enters the working page. With right Wifi setting, ESP32 gets the real-time from NTP, and shows on the display.
LoRa Soil Moisture Sensor Setting
We use the simple LoRa soil moisture sensor, take the sensor from the package, and power the sensor with a 2 AAA battery. There is the sensor ID number on the battery slot (and also on the mechanic case), such as ID010040:
press the “add moisture button” in the ESP32 display, then you can input the ID.
As the setting is complete, the ESP32 display will get the LoRa message from the LoRa soil moisture sensor. As the sensor will output data every 1 hour, to validate the connection, press the “reset” button for an instant message.
The shows ADC data means the moisture sensor output, the lower the values are, the higher moisture, check the Typical Output. The sensor data and the time stamp show on the display, it will update every 1 hour. Actually, it will also add a log in the SD card for further checking.
There Max 8 LoRa moisture sensor can be added and monitored.
Step 5: Connect the Valves to the LoRa MOSFET Outputs
There the for values, it has one water-input port, and one output port, connect the input port to your water tank(I used a big mineral water bottle as a water tank), and the output to plants. We use a one-input-four output terminal for easy installation.
Press the add MOS in the ESP32 display and input MOSFET ID, such as ID060000, and power up the LoRa MOSFET.
The LoRa MOSFET will report its status to the ESP32 display, and you can now control the MOSFET connected valves:
Press the MOSX, to change it from OFF to ON, and press send…
The connected valve status changes. Try to control other acturors such as FANS/DC. Actually you can also send commends via LoRa, to change the PWM duty, to control the connected FANS/DC speed. There max 2 MOSFET(8 actuators ) can be added.
Summary
This demo uses the basic modules to remotely monitor soil status/ control irrigation, which can be used in filed applications. But as my time schedule and also poor experience in programming, it is just a demo of LoRa usage, to show how to create a field application. For makers that are familiar with the coding, there much more spec can be added:
- Remote monitoring/control with Internet. As the ESP32 is connected to WiFi, all sensor data can be re-routed to internet, or remote control the valves, with MQTT.
- More LoRa sensors, now it supports 8 soil points and 2 MOSFET that support 8 valves, theoretically, there infinite sensors can be added, but as the LoRa unsafe one-way data transmission, there possibility of data lost when the sensor quality larger. LoRaWAN can ensure the safe connection, but I have not made that. And also, more actuators.
- With the industry level moisture sensor, for more detailed soil monitoring.
- PWM duty controlling of the connected actuators, to control the load speed…
See this video to learn the full display effect.
With the support of enough equipment, we can use Lora to irrigate the nearby soil, which is a very good design for smart agriculture. Using science and technology to change the mode of production is the goal of future development. We use these materials to guide more MAKERS on how to use them, and that's our goal. I hope you like this project.