Difference between revisions of "Lora Soil Moisture Sensor"

From MakerFabsWiki
Jump to: navigation, search
(Interface Function)
(Interface Function)
Line 55: Line 55:
  
 
== Interface Function ==
 
== Interface Function ==
[[File:Lora_Soil_2.jpg|380px]]<br>
+
[[File:Lora_Soil_2.jpg|200px]]<br>
 
①U1:LTC555<br>
 
①U1:LTC555<br>
 
②J1:UART interface<br>
 
②J1:UART interface<br>

Revision as of 10:57, 23 June 2020

Introduction

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.

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 433MHzcommunication is established.
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).

Features

• 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
①U1:LTC555
②J1:UART interface
③U2:Atmega328P
④ISP: used for download bootloader
⑤RST:Reset button
⑥Lora Module
⑦Air humidity and air temperature sensor:AHT10
⑧Antenna interface

Usage

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

Lora Soil Moisture Sensor USB-to-UART Tool
3V3 3V3
GND GND
RX TXD
TX RXD

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.
https://github.com/Makerfabs/MaduinoLoraRadio
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

Result:

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


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.

Step:
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.
https://www.makerfabs.com/makepython-esp32.html
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)
#https://thingspeak.com/channels/1035244
API_KEY='SO3W20EMSKIEJN4E'
  • 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

FAQ

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

Resources