Lorawan Soil Moisture Sensor

About the project

I made a LoRaWAN soil moisture sensor, based on RP2040. But there is still some difficulty with the low power consumption...

Project info

Difficulty: Moderate

Platforms: ArduinoMicroPython

Estimated time: 1 day

License: GNU General Public License, version 3 or later (GPL3+)


1. Project Description.

Makerfabs Lora Soil Moisture Sensor has been popular sold& used in open hardware community, but sometimes we get customers’ questions: How I can use your sensor with TTN/ Helium? Whenever we get these questions, we can only feedback: Er, there some difficulty…

The LoRa & LoRaWAN actually suits for absolutely different applications:

  • LoRa, mostly stands for local simple point-to-point communication, there sender and receiver are needed, it acts most like Physical layer in OSI, that the sender sends out the signal while the receiver gets it. LoRa suits for applications that need low-rate local point-to-point communication, ranging to a few kilometers.
  • LoRaWAN acts like the Network layer in OSI. It mostly is used in networks that need to access to the internet. LoRaWAN acts like a local WIFI network, that deal with all the coordination/ addressing/ exception dealing, etc… Same as WIFI, a Router is needed in the network, that deal with these tasks and accession to internet. The difference is that, benefits from the longer range of LoRaWAN, there are some public LoRaWAN routers, that you may not need to install your router by yourself. Just think it you using the WIFI router in your neighborhood, or a phone registering on a station.

Makerfabs the LoRa moisture sensor is a LoRa module, the controller Atmega328P controls the LoRa module SX127X, with SPI, to broadcast the soil moisture and air temperature& humidity every 1 hour, any LoRa receiver in the range can get the info, and thus to decide whether or not to deal with it. It has no connection to the internet. Of course, some users program the controller Atmega328P to run the LoRaWAN protocol, with a LoRaWAN router, to connect to TTN or Helium and get succeed, such as these following projects:

1. https://twitter.com/hexaspot/status/1593216730566123520

2. https://community.home-assistant.io/t/makerfabs-soil-moisture-sensor-v3-LoRaWAN-ttn-v3-and-ha-integration/446021


But this needs the user to have high coding skilling, and there sometimes some exceptions as the Atmega328 limits resources.

With more customers interested in LoRaWAN, I decide to make a LoRaWAN soil moisture sensor.

2. Current RP2040 LoraWAN Solutions

There are mainly 2 structures for LoRaWAN projects:

● STM32 Controller+ SX126X

In this structure, the STM32 run the LoRaWAN protocol and also deal with filed application, such as the Seeed LoraE5.

It is cheap and efficient. Users can run filed applications in the STM32(that also run LoRaWAN protocol), But the disadvantage is, users will need to remake all the codes, field applications codes such as sensor interaction, and the LoRaWAN protocol codes, whenever updates the filed application. Besides, it is hard to translate to other platforms, and can be only stuck to the STM32 platform.

● Separate Controller+ LoRaWAN Modules

In this structure, a separate LoRaWAN module was used to run/deal with the LoRaWAN protocol, so the end-users do not need to consider any LoRaWAN-related coding, just control the LoRaWAN module by AT commands, the separated controller can be used to run customers’ filed applications only.

Finally, I decided to use 2nd structure.

*The Seeed Lora E5 also has built-in firmware with AT commands, that can also be used as a LoRaWAN module in the 2nd structure.

3. LoraWAN Soil Moisture Sensor

As for the LoRaWAN module, I select the AiThink RA08H, As the LoRaWAN modules connect to main controller via UART and AT commands, actually it’s easy to update to some other modules from other suppliers.

As for the main controller selecting, I considered the following candidates:

● Atmega328P: Popular used 8 bits controller, Arduino Uno compatible. But the most problem is its price… It is up to $5 in the IC shortage;

● SAMD21: The controller used in Arduino zero and our Maduino Zero Modules, built-in USB;

● RP2040: A relatively new controller by Raspberry Pi. Hot recently…

To make it hot, I selected the RP2040… er, which proves maybe not be a good choice finally.

In 2 weeks, I made the hardware:

  • The core controller is RP2040, of course, with extra 128M flash, it generates the PWM and thus to detect the soil moisture via capacitive method;
  • It also detects the air temperature& humidity via a sensor AHT10;
  • 3 AAA batteries are used to generate 4.5V voltage, to ensure the ADC is stable, although 2 AAA batteries, 3V, is actually OK, but as I tested in the LoRa Moisture Sensor, the ADC result drops as the main voltage drops, so making the VCC to 3.3V stable help making the ADC stable.

I have a LoRaWAN router in our office, the Dragino_LIG16, I created a simple LoRaWAN to internet access quickly.

1. Local moisture& air data are uploaded to LoRaWAN TTN(the things network)

2. Also, the TTN supports transmitting the data to Thingspeak for visual checking:

*For more info about TTN/ Thingspeask setting, please refer to:

4. Power Consumption

The total hardware/ software seems to work great, but then I encountered a problem: Power Consumption.

A main advantage of LoRaWAN is its low power consumption, Makerfabs LoRa Moisture Sensor current is a few uA(7.1uA in sleeping mode), that is, with the 2*AAA batteries, it can work for at least a year(theoretically). But when I try to check the power consumption of the RP2040, I find it problem:

● In either Arduino& MicroPython, I do not get much support on the sleep mode setting, there are few files, not mentioned to libs, about the RP2040 power saving. I found tomjorquera made the PICO low power setting, but it is driven by external interrupt, and can not be reset from sleep by internal clock. Besides, it proves that the RP2040 current high even in dormant mode:

● Then, I have to transmit to Pico C/C++ SDK, the original RP2040 development tool released by Raspberry Pi team:

But still, I found the sleep mode of RP2040 up to 1.03 mA, that is, theoretically, with 3 AAA batteries, the working time is less than a month, even with bare RP2040… This is not good for a LoRaWAN sensor.

By the way, as there arenot any libs for external modules, same as that in MicroPython& Arduino, for PWM generating/AHT10 interaction, I have to write them by ourselves in Pico C/C++ SDK, which takes a lot of time.

By 2022/11/18, I still do not get a better result. Personally, I think maybe the RP2040 is not a good choice that needs lower power, and lacks of support on Arduino& MicorPython.

I am considering to switch back to Atmega328P, which I am much more familiar with and the current less than 1 uA (sleep mode), 0.1% of that for RP2040. The good news is that, its price is about $2 now, and maybe even lower in the near future, as there IC shortage ends up.

Keep tuned...

Check this video:

5. Update: New ATMega328P Lorawan Soil Moisture Sensor

As we decided to switch back to Atmega328P, the hardware design and production turns out quickly.  Now, I am happy to announce that this new LoRaWAN soil moisture sensor is available.

Makerfabs LoRaWAN soil moisture sensor uses the Atmega328P as the main controller, which is Arduino compatible, and AIthink RA08H as the LoRaWAN interface.

As the sensor, this module uses capacitive method to test the soil moisture, and an AHT10 to test the air temperature& humidity.

Compares to the v1 version with RP2040, the core controller Atmega328P is the most modification.

With this controller, the module sleeping current is only 7.1uA and 4mA in LoRaWAN communication around.

With our default setting, 1 hour per update, it can at least work for 1.5 years with 3 AAA batteries;

To Help users create LoRaWAN applications quickly, Makerfabs provided the application firmware frame, which is based on Arduino IDE.

In the firmware frame, we have set the lower power module, PWM setting, etc, users can simply modify a few codes (Appkey/ AppEUI/ DevEUI), to achieve a LoRaWAN application in a few minutes.

Also, you can modify the setting, such as LoRaWAN message interval, and add or remove functions freely in the codes.

With a LoRaWAN router, it is now easy to create a LoRaWAN application now.

  1. Configure the LoRaWAN router, in our demo application, we update the soil moisture data to LoRaWAN service TTN every 60 minutes, and display the output via Thingspeak;
  2. Modify the end-device setting, including the LoRaWAN app/dev setting; by default, the result is updated every 1 hour.
  3. Monitor the data via TTN or Thingspeak;

For all the above steps,  Makerfabs has prepared a very detailed Wiki page for the learner, to create the first LoRaWAN application with TTN/Thinspeak, in a few minutes.

We believe the LoRaWAN could be a good solution for low-power, low-rate applications such as agriculture,  and there will be more LoRaWAN sensors, including light sensor/ CO2 sensor, available at Makerfabs online store, If you have any ideas/suggestions about Makerfabs LoRaWAN products, feel free to contact us.


Photo of Makerfabs01


Makerfabs, Turnkey PCB Assemblies | Small Batch PCBA Prototyping | IoT Hardware Engineering.


Leave your feedback...