Lora Soil Moisture Sensor

From MakerFabsWiki
Jump to: navigation, search


Lora Soil 0.jpg

The Lora soil moisture sensor is based on Atmel's Atmega328P, it collects local air temperature/ humidity with sensor AHT10, and detect the soil humidity with capacitor-humility measurement solution with 555, and transmit the local environment data to the gateway, with Lora communication, suit for applications for smart-farm, irrigation, agriculture, etc.
In applications, always you do not need to check the air/soil state continuously, have a test of them for few seconds after then minutes/hours sleeping is normally Ok for most projects. To save power, there the Air/ Soil measuring functional could be shut down in the working, so they can be only powered ON a short time and then a long time power off. With MCU in sleeping mode and low power consumption Lora module, this module works ok with 2 AAA batteries for months. Besides, this sensor is coated with waterproof paint, which makes it a longer working time in damp soil.
The Lora soil moisture sensor is shipped out with Arduino pro-mini bootloader pre-loaded, and there also a default sketch programmed. Uses can re-program it with Arduino IDE, we suggest a standard USB2UART convertor for this. Note that the DTR in the USB2UART convertor is needed to connect to the "Reset" pin for Arduino sketch downloading, if there no DTR, you may need to press the “reset” button manually in the downloading.
The firmware has been uploaded to Lora Soil Moisture Sensor, and it can be obtained from here: LoraTransmitterADCAHT10.

Lora Soil Moisture Sensor offers bandwidth options ranging from 7.8125kHz to 500 kHz with spreading factors ranging from 6 to 12, there are three choices of the working frequency.

Item Lora Module working frequency
Lora Soil Moisture Sensor 433M RFM98W-433MHz/SX1278 433MHz
Lora Soil Moisture Sensor 868M RFM95W-868MHz 868MHz
Lora Soil Moisture Sensor 915M RFM95W-915MHz 915MHz

Lora Soil 01A.jpg
Free ISM bands world Wide(come from TI)
Lora Soil Moisture Sensor based on the Arduino, users can program it with Arduino IDE, which is very easy especially suit for the none-programmers. There are also guide for users to learn how to create the first IoT project with this board, with which the starters can learn the hardware and programming skill quickly.

This guide help you the basic usage of Lora Soil Moisture Sensor.

This Moisture Sensor can be used to detect the moisture of soil or judge if there is water around the sensor. They can be very easy to use, just insert it into the soil and then analog read it. With help of this module, it will be realizable to make the plant reminds you : Hey, I am thirsty now, I need some water.
This design is based on a capacitive principle. We integrated the 555 oscillator capacitive measurement, which will give you a reading ranging from about 500 (very wet) to 1000 (very dry).


• ATMEL Atmega328P: High Performance, Low Power Atmel®AVR® 8-Bit Microcontroller
• RAM: 2KBytes.
• Flash:32Kbytes.
• EEPROM: 1Kbytes.
• Clock Speed: 8 MHz.
• Interface: UART.
• MCU Power Consumption at 1MHz, 1.8V, 25C

– Active Mode: 0.2mA
– Power-down Mode: 0.1µA
– Power-save Mode: 0.75µA (Including 32kHz RTC)

• 2*AAA battery powered
• Measure soil moisture
• Integrated air humidity and air temperature sensor
• Default baud rate: 115200bps.
• Working Temperature: -20 ~ +85℃.

Interface Function

Lora Soil 2.jpg
②J1:UART interface
④ISP: used for download bootloader
⑤RST:Reset button
⑥Lora Module
⑦Air humidity and air temperature sensor:AHT10
⑧Antenna interface



Required Materials

1. Lora Soil Moisture Sensor
2. Maduino Lora Radio
3. USB-to-UART tool
4. 2*AAA battery
5. microUSB Cable
6. PC

Lora Soil 03.jpg
System diagram
Notice: Maduino Lora Radio and the Lora Soil Moisture Sensor must have the same work frequency. Otherwise, it receive nothing from another.

Lora Soil Moisture Sensor requires a USB-to-UART tool to upload firmware to it, you can get it from:
Install the CP2102 driver from:

Hardware Connections

Lora Soil Moisture Sensor USB-to-UART Tool

4-Channel Lora Relay-10A 3.JPG
A cp2104-usb-to-serial-converter is very convenient to connect the sensor and PC for loading the code. If using another CP2104 converter to load the code, it has to press the RESET button when uploading for loading successfully.

Loading Firmware

  • After an Arduino IDE installed, there is a default package to support Lora Soil Moisture Sensor(Arduino Zero ),
  • From the top Arduino IDE menu, select Tools-> Board-> Arduino Pro or Pro Mini

Lora Soil 06.jpg

  • From the top Arduino IDE menu, select Tools-> Processor->Atmega328P(3.3V,8Mhz)

Lora Soil 07.jpg

  • After inserted the USB-to-UART tool to you PC, select the related Port. On my PC, there is COM7 that may differ in your PC.

Lora Soil 08.jpg

Lora Soil 09.jpg

Modify the frequency macro according to your board is 433Mhz or 868Mhz or 915Mhz.
If your Lora board is 433MHz:
#define RF95_FREQ 433.0
If your Lora board is 868MHz:
#define RF95_FREQ 868.0
If your Lora board is 915MHz:
#define RF95_FREQ 915.0

Tips: Lora Soil Moisture designed as a product, so it does not integrate the USB-to-UART on board. If you upload the firmware fails, press and hold the Reset button before upload the firmware. loading the code and when the IDE shows below, release the button, it may help to upload the firmware success.
Lora Soil 10A.jpg
  • Install the AAA*2 batteries and put the Lora Soil Moisture aside, now we need to make the Lora Radio Receiver.

Lora Radio Receiver

Plug the Maduino Lora Radio to PC via microUSB cable.
Lora Soil 11A.jpg

Open the code LoraReceiver.ino
Select the Arduino Pro or Pro mini

Lora Soil 12A.jpg

Select ATmega328P(3.3V,8Mhz)

Lora Soil 13A.jpg

Verify and upload the firmware.

Lora Soil 14A.jpg

Lora Soil 15A.jpg


The Lora Soil Moisture will send messages via Lora Radio frequency. And the Maduino Lora Radio will receive the result and print them in the Serial Monitor.
Lora Soil 16.jpg

We can see it gets the air humidity and temperature and soil moisture from the Lora Soil Moisture Sensor.
Lora Soil 17.jpg

Lora Gateway usage

This routine will use Lora Soil Moisture sensor and Lora gateway to make an Internet project that collects air temperature and soil humidity data and uploads it to the server, allowing you to learn the usage of Lora Soil and the basic use of Lora in depth.
Lora Soil 20.jpg

1.The Lora Soil node sends data to the gateway.

  • Here we need to use Arduino for programming.
  • Use the serial tool to connect the Lora soil moisture sensor.
  • Open Arduino IDE, Board choose Arduino Pro or Pro Mini, Processor choose ATmega328p (3.3V, 8MHz), select the corresponding port.

Lora Soil 3.jpg

  • Download the program from here: TransmitterAHT10.
  • Open the program and click upload (you need to press the reset button during the upload process). After success, you can see the following output from the serial monitor:

Lora Soil 4.jpg

2. LoRa Gateway(microPython) Here uses Micropython programming to receive and process data. Of course, it can be used in Arduino too.
You need to use Makepython Lora module and MakePython ESP32 module, you can get them from the link below.
Makepython ESP32:
Lora Soil 5.jpg

Makepython Lora:
Lora Soil 6.jpg

Assemble MakePython Lora and ESP32 to make a gateway that can receive remote data and upload it to the Internet.
Lora Soil 7.jpg

3.Receive the data transmitted by Lora Soil Moisture sensor.
You download the code from here: code, then upload all xxx.py in the Micropython_Lora_Soil file to ESP32.
Open the LoRaDuplexCallback.py file, You need to make some adjustments so that your ESP32 can connect to the network and upload data to the server.

  • Modify the API_KEY you obtained in ThingSpeak. (I will introduce how to obtain it later)
  • Modify SSID and PSW to connect WiFi.
ssid = "Makerfabs"
pswd = "20160704"
  • Open the connectWiFi.py file, here also need to modify the ssid and pswd.

Lora Soil 8.jpg

4.Use ThingSpeak IoT

  • Sign up an account in https://thingspeak.com/. If you already have one, sign in directly.
  • Click New Channel to create a new ThingSpeak channel.
  • Input name, Description, Select Field 1 to 5. Then save channel on the bottom.

Lora Soil 9.jpg

  • Click the API Keys option, copy the API Key, we will use it in the program.

Lora Soil 10.jpg

5. Result

  • Insert one end of the Lora Soil Moisture sensor module into the soil of the flower pot to collect data.
  • Press the reset button of Makeoython ESP32, after the connection to the network is successful, the screen can display the data sent by the Lora Soil Moisture sensor module.

Lora Soil 11.jpg

  • After logging into ThingSpeak, you can see the data uploaded by ESP32 Gateway.

Lora Soil 12.jpg

Power consumption test

1. Content: how long two batteries can power the module.
2. How to do: Use two batteries to power the module to monitor the temperature and humidity of the soil in the flower pots placed in the office. Record the time from the beginning of the test to the battery exhaustion.
3. Battery: Two AAA batteries.
4. The time of the run: 29 days and 2 hours (2020-11-26 14:44 to 2020-12-25 16:34)
5. Record: as the picture.
Lora Soil 13.jpg
Lora Soil 14.jpg


You can list your questions here or contact with support@makerfabs.com for technology support.