DIY

Remote monitoring of soil moisture, air and temperature

Remote monitoring of soil moisture, air and temperature  Remote monitoring of soil moisture, air and temperature In this article, the wizard will tell us how you can measure soil moisture using just a few electronic components. The most interesting thing about this device is remote monitoring. Those. the sensor can be placed in a flower pot on a closet or on a street bed, and read the value in a convenient place for the user.
This assembly requires the following components:
-Soil moisture sensor; -ESP32 + expansion board;
LoRa Soil Moisture Sensor is powered by Atmel Atmega328P. It collects the local air temperature/humidity using the AHT10 sensor and determines the soil moisture. The sensor transmits readings to the ESP32 gateway. And it is very convenient to use it to remind that plants need watering in the garden.
Built-in * LoRa module connects to the Atmega328P using SPI and GPIO, the pinout is below:
Atmega328P —— & gt; LoRa module
D12 —- & gt; MISO
D11 —— & gt; MISO
D13 —— & gt; SCK
D10 —— & gt; NSS
D4 —— & gt; RESET
D2 —— & gt; DIO0
D6 —- & gt; DIO1
* LoRa is a wireless technology with high network capacity and low power consumption of end devices.
 Remote monitoring of soil moisture, air and temperature Remote monitoring of soil moisture, air and temperature To successfully connect the humidity sensor to the gateway, you need to use the RadioLib.h library.
When LoRa has transmitted data, you need to add a sign to the transmitted information so that ESP32 will recognize it.

 String message = & # 34; # & # 34; + (String) packetnum + & # 34; Humidity & # 58; & # 34; + (String) humidity + & # 34;% Temperature & # 58; & # 34; + (String) temperature + & # 34; C & # 34; + & # 34; ADC & # 58; & # 34; + (String) sensorValue + & # 34; SOIL2 & # 34 ;; Serial.println (message); packetnum ++; Serial.println (& # 34; Transmit & # 58; Sending to rf95_server & # 34;); int state = radio.transmit (message);  

All sensor code can be downloaded here.
Lora gateway is a combination of ESP32 module and MakePython LoRa. ESP32 is a very popular microcontroller for Arduino or MicroPython. MakePython ESP32 has ESP32 and display.
MakePython LoRa is a two-channel LoRa extension for MakePython ESP32. This extension is needed for WIFI.
The board has two LoRa modules, in this project one module named U2 was used to receive data. When the two boards are assembled, the ESP32 connects to the LoRa module using SPI. LoRa module is connected to ESP32 using SPI and GPIO.
Detailed connection of ESP32 and U2 LoRa module:
ESP32 ——- & gt; U2 LoRa module
IO12 —— & gt; MISO
IO13 —— & gt; MOSI
IO14 —— & gt; SCK
IO32 —— & gt; NSS
IO33 —— & gt; RESET
IO36 —— & gt; DIO0
IO27 —— & gt; DIO1
Remote monitoring of soil moisture, air and temperature Remote monitoring of soil moisture, air and temperature Now you need to program the ESP32.
Configures the LoRa module interface

  #define DIO0 36 #define DIO1 27 #define LORA_RST 33 #define LORA_CS 32 #define SPI_MOSI 13 #define SPI_MISO 12 #define SPI_SCK 14  

Installs the LoRa library – RadioLib.h to support the LoRa module and receive data transmitted by the soil moisture sensor.

  String str; int state = radio.receive (str);  

To recognize the data from which sensor the data is transmitted, a special label must be defined for each information, for example “SOIL1”.

 if (str.indexOf (& # 34; SOIL1 & # 34;) & gt; -1) & # 123; sensorADC = str.substring (str.indexOf (& # 34; ADC & # 58; & # 34;) + 4, str.indexOf (& # 34; ADC & # 58; & # 34;) + 7); ADCvalue & # 91; 0 & # 93; = sensorADC; Serial.println (& # 34; 1 & # 58; & # 34; + ADCvalue & # 91; 0 & # 93;); } if (str.indexOf (& # 34; SOIL2 & # 34;) & gt; -1) & # 123; sensorADC = str.substring (str.indexOf (& # 34; ADC & # 58; & # 34;) + 4, str.indexOf (& # 34; ADC & # 58; & # 34;) + 7); ADCvalue & # 91; 1 & # 93; = sensorADC; Serial.println (& # 34; 2 & # 58; & # 34; + ADCvalue & # 91; 1 & # 93;); }  

Writes the following data to display data on the screen:

  display.clearDisplay (); display.setTextSize (2); display.setTextColor (SSD1306_WHITE); display.setCursor (0, 0); display.print (F (& # 34; SOIL1 & # 58; & # 34;)); display.println (ADCvalue & # 91; 0 & # 93;); display.print (F (& # 34; SOIL2 & # 58; & # 34;)); display.println (ADCvalue & # 91; 1 & # 93;); display.display ();  

The entire code can be downloaded here.
Now you need to connect the power supply and test the operation of the device.
The wizard installed two sensors powered by a battery. I put one sensor in the pot and the other in the garden. After turning on the ESP32, the LCD should display the sensor readings.
In addition, the ESP32 can transmit the data received by the LoRa module to a website via WIFI, for example, to Thingspeak. It can also pass data or commands to other LoRa modules.
Remote monitoring of soil moisture, air and temperature Remote monitoring of soil moisture, air and temperature

Source:

usamodelkina.ru

Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button