Device

The Lora Soil Moisture Sensor is a nice combination with the following components on a single circuit board:


LORAWan Node
The following additional libraries are used in the ARDUINO IDE for a first prototype:

The basic framework for the sketch is the OTAA example from the LMIC library. Of course, special attention should be paid to the regional adaptation of the lmic_project_config.h file. The correct pin mapping can be derived by the circuit diagram. The source code for reading out the soil moisture sensor and the AHT10 was taken from Makerfabs' project documentation. The low power library is intended to reduce the energy requirement between each measurement and transmission. In addition, the battery voltage is determined via the bandgap voltage of the processor. The individual sensors are only supplied with energy for measurement.

Some difficulties with the AHT10 could be reduced with an additional queue, but could not be completely resolved. The cause here may be the AHT10 itself, the sleep mode and the control of the supply voltage. Due to the utilization of the flash memory with 92% and the dynamic memory with 85%, various unpredictable instabilities and runtime errors can be caused by the sketch. Perhaps a more efficient LMIC library can be used later.  At the moment the device seems to be running stable, but I will be happy to share my long-term experiences.


LORAWan TTN integration
For the integration in TTN V3, an application with a device is usually created. The values for APPEUI, DEVEUI and APPKEY specified for the device are entered in the sketch (note the bit order according to the example, TTN generates the necessary character strings for copy-paste at the push of a button). The preparation of the payload for the integration, e.g. of Thingspeak, takes place via a payload converter in Javascript.


LORAWan Chirpstack Integration (privat)

Implementation of the following toolchain was successfully completed: OS Debian 11 on a NUC with Chirpstack, Mosquitto, InfluxDB2, Nodered, iobroker, Grafana and a lot of more stuff.

Unfortunately I had to abort the full implementation on a Cubietruck because the architecture is not well supported. At least Mosquitto, InfluxDB (V1) and iobroker work, so at least some services can be outsourced later.


Sensor calibration

The AHT10 is inherently imprecise and is subject to a good spread, so calibration is not required here. Since the sensor is used close to the ground, the measured temperature is likely to be a mixture of ground and air temperature. The air humidity cannot be evaluated anyway if the housing is sealed watertight (necessary outdoors and in a greenhouse ...).

The soil moisture sensor can be calibrated by recording the measured values in the air (0%) and in clear water (100%). A series of experiments with soil that is moistened in a defined manner is more complex. Here you can consider whether the effort is worthwhile, since ultimately the measured values in the real environment depend on the actual soil composition, water type and also on the positioning in the bed. Realistically, I consider the measured values as a rough guide as to whether it is necessary to water. I'd better leave everything else to scientists.

The battery voltage sensor is calibrated by a form factor calculated by the measured value of the insight and outsight voltage.


Experiences with the Prototype No. 1 in the field

The device has been working flawlessly for a month. I could increase the resolution of the soil moisture by a factor of three, but I don't see any added value in this. It is still a little difficult to interpret the soil moisture value. at the moment i regularly feed water into the bed via a hose system so that i feel that i am adequately supplied with the plants. I have added a few graphs of the current measured values (thingspeak). The batteries seem to last a while, but i doubt they'll last too long. This makes rechargeable batteries and solar charging functions all the more important.
Otherwise I am still struggling with the commissioning of Chirpstack on my Cubietruck. The installation of TTN privately fails due to the setbacks to the installation of docker on the cubietruck. Maybe the good old cubietruck is no longer up to date... (but still a nice device)

Unfortunately, the device ran out of energy after 5 weeks. This seems a little poor in view of the 20-minute measurement intervals and the use of the low power library. After some measurements I have to state that the sensor consumes around more than 570uA in low-power mode, which is around a factor of 100 higher than expected. At least that explains the short lifespan of the batteries used.

The cause seems to be the TLC555IDR component, which continues to consume a lot of energy despite the VCC supply voltage being switched off. This is confirmed by the description of the new version V3 of the sensor, which unfortunately I discovered some days ago... . :-( .

Optimizing the power consumption

Kindly, the manufacturer of the sensor (consciously?) has already made all the preparations in hardware version V2 to remove the TLC555IDR and operate the soil moisture sensor directly via the processor (PWM timer1) without any further wiring. Only the software had to be adjusted slightly. The result is a soil moisture sensor that consumes 6-8uA in low power mode and 4-9mA for a short time (1-2s) in active operation. This should be good enough to last a gardening season with one set of batteries.

Experiences with the Prototype No. 2 in the field

Update 7th Aug 2022:

Both prototypes are still working well. I sealed the original housing of the two prototypes with adhesive tape for testing purposes, but even with this additional protection, the material proves to be unsuitable for outdoor use - especially under greenhouse conditions. So I will have to design and print a new waterproof case in ABS..


Update 26th Dec 2022:

The batteries of the two prototypes only gave up at the beginning of December. After all, the sensors can be operated for one gardening season.

Update 22th Jan 2023:

Makefabs finally offers a new product that meets my needs. I'll take a look at the source code, maybe this can be used for my project. In the meantime, I have replaced the battery holder with a LiPo, so that I no longer need disposable batteries and can now also connect a solar cell to extend the runtime if necessary.

Next Steps