Difference between revisions of "Lora Soil Moisture Sensor"

From MakerFabsWiki
Jump to: navigation, search
(Hardware Connections)
(Hardware Connections)
Line 91: Line 91:
Download the [RadioHead file], click Add.ZIP.Library, select RadioHead.<br>
Download the [RadioHead file], click Add.ZIP.Library, select RadioHead.<br>

Revision as of 09:51, 23 June 2020


Lora Soil 0.jpg

 The Lora soil moisture sensor is based on Atmel's Atmega328P, it collect 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 the 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 battery for months. Besides, this sensor is coated with waterproof paint, makes it longer working time in the damp soil.
The Lora soil moisture sensor is shipped out with Arduino pro-mini bootloader pre-loaded, and there also 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 “Reset” pin for Arduino sketch downloading, if there no DTR, you may need to press the “reset” button manually in the downloading.


• 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
① ANT: Lora Antenna.
③ SWD: Serial Wire Debug.
④ ATMega328P.
⑤ AHT10.
⑥ J1: serial port 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: https://www.makerfabs.com/usb-uart-convertor-cp2102.html Install the CP2102 driver from: https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers

Hardware Connections

Indicator LED Status
Lora Soil Moisture Sensor USB-to-UART Tool
3V3 3V3

Lora Soil 05.jpg

After a 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. In my PC, there is COM7 that may different in your PC.
Lora Soil 08.jpg

Download the [RadioHead file], click Add.ZIP.Library, select RadioHead.
Lora Soil 09.jpg

Open LoraTransmitterADCAHT10.ino, verify and upload the firmware to Lora Soil Moisture.
Modify the frequency macro according to your board is 433Mhz or 868Mhz or 915Mhz.
If your Lora board is 433MHz:

  1. define RF95_FREQ 433.0

If your Lora board is 868MHz:

  1. define RF95_FREQ 868.0

If your Lora board is 915MHz:

  1. define RF95_FREQ 915.0

Tips: Lora Soil Moisture designed as a product, so it not integrates the USB-to-UART on board. If you upload the firmware fails, press and hold the Reset button before upload the firmware. When the IDE shows below, then release the button that may helped to upload the firmware success. That’s we need a reset the MCU when upload the firmware.
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.

2. 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 16.jpg

===microPython 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.

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 Here uses Micropython programming to receive and process data.
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


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