Wireless soil moisture sensor with LoRa

August 17, 2019 - Reading time: 3 minutes

My nephew visited me some months ago and asked me for a wireless soil moisture sensor. At that time I was already aware of those groundbreaking new wireless technologies like LoRa, Sigfox and NB-IoT, but had no comprehensive experience so far. So I decided to

  • get an overview of the competing technologies LoRa, Sigfox and NB-IoT,
  • develop some low cost wireless nodes
  • and get some practical experience.

This is the first part of my journey which covers LoRa. Before diving into the technical details let me talk about low power long range communication in general.The range of a wireless system mainly depends on these factors

  • transmitter power
  • receiver sensitivity (bandwidth)
  • antenna gain
  • radio environment (from line of sight to dense urban areas)

Many people are not aware that the radio environment has an extreme infkuence in range. There is easily a factor of 10 or morge in range comparing rural and urband sites. Datasheets often claim a range which can only be achieved under most favourite conditions and therefore disappointment is guaranteed.  I usually follow these rules:

  • use the highest transmitter power which is accpetable in regard to frequency spectrum regulations and power supply capability
  • use antennas with as much gain as possible
  • place the antennas as high as possible
  • use a low bandwidth/datarate to increase sensitivity (in my application I usually transmit only a few bytes of data)

Before LoRa it was already possible to achieve long range at low power, but LoRa made this possible at very low cost by integrating the required signal processing into a single chip. I usually go with the module RFM95 by HopeRF which is about 5-6 Euros and add an ATmega328 controller. Here you can see me first attempt.

Software is either pure LoRa or LoRaWAN in conjunction the TheThingsNetwork. For LoRaWAN I chose MCCI Catena LMIC lib which works quite well and a low power lib to achieve a few Mikroamps during sleep times. This way I am running an experiemental node in my garden together with an SMT50.

Soil moisture sensors and irrigation of lawn

August 3, 2019 - Reading time: 2 minutes

My nephew recently visited me and asked for advice on lawn irrigation. He has a couple of soil moisture sensors placed all over his lawn in the root zone (about 10 cm deep) and is wondering how to adjust the threshold for irrigation. My first simple advice was just to observe the lawn and identifiy the water content when the leaves are getting brown. Brown leaves are an indication of water stress. My nephew was not really satisfied with this answer and said: "Grandma, you have such a long experience in gardening, you have a so-called green thumb, but I am a real novice. Could you please help me so that even I can adjust he irrigation threshold without observing the leaves". So did a survey and found this guide from the University of Florida on Smart Irrigation This is the sum up of their recommendations:

  • Place the sensor at locations which are representative for the area to be irrigated (see more details about sensor locations in the guide)
  • Burry the sensors in the root zone
  • Carefully install the sensors with no air gaps around the sensor
  • Calibrate the sensor
    • Apply water in the sensor area up to saturation
    • Do not apply water for 24 hours
    • Record the water content which is the threshold value (threshold can be adjusted to 20% lower than this value)

In any case I would always observe the lawn and see if it is in good shape with this irrigation threshold setting.

Where to buy the best thick shake?

August 3, 2019 - Reading time: ~1 minute

It may sound a bit off topic, but I decided to share my experience in delicious food and drinks. As a passionate gardener I grow not only flowers but also vegetables and fruits, and of course I enjoy having good food. I came across many countries in the world and remember quite a number of unique spots. I start this series with my favourite shake supplier in the US which is Iceberg Drive Inn. The first restaurant open in 1960 in Salt Lake City.

My first experience with Icebergs was on a hot summer night in St. George, Utah. I came across Icebergs and decided to try their thick blueberry shake. It was incredible, both taste and size were amazing. Since that time I even take a longer detour just to enjoy the famous thick shake. My favourites are blueberry and strawberry.


Soil moisture measurement with Loxone and SMT100

July 14, 2019 - Reading time: 3 minutes

This is my first step in building an automated irrigation system with the Loxone Miniserver. Loxone is a manufacturer of smart home systems and became quite popular due to its medium price tag and good support of interfaces. I decided to give it a try and chose the Loxone Miniserver and the corresponding Modbus extension. With the Modbus extension it is possible to add up to 32 Modbus devices. If this is not enough you can add more Modbus extensions Here is how the Loxone Miniserver looks like.


With Modbus RTU it is quite simple to add a SMT100 to the Loxone. The SMT100 is available as Modbus version (please mention this when ordering). The manufacturer TRUEBNER provides an application note and a Modbus test program. I configured the SMT100 as Modbus device with address 1. Here is the configuration required by the Loxone. Please first add the Modbus extension to the Miniserver and then connect the SMT100 to the Modbus extension. Do not forget to power the SMT100.

Step 1: Modbus Extension

Set Baudrate to 9600 and Parity to even

Step 2: Modbus Device

Set Modbus address

Step 3: Add Sensor settings for temperature

I/O address 0

Command 3 (read holding registers)

Data type 16 bit unsigned integer

Step 4: Add Sensor settings for moisture

I/O address 1

Command 3 (read holding registers)

Data type 16 bit unsigned integer

Use conversion formulas (math block formula)

moisture: 16 bit value /100

temperature: 16 bit value / 100 - 100

Use virtual status blocks to display moisture and temperature on the website

This is the final result

If anyone needs a more detailed explanation how to setup Loxone with the Modbus Extension please send me an email at maria.gardenergranny@gmail.com.

Of course it is not a requirement to use Modbus for the SMT100 with Loxone. There are two more options. First option: Use the SMT100 with analog voltage output. Second option: Use the SMT100 ASCII with an RS485 Extension. For me Modbus was the most convenient choice. I know Modbus from the beginng. I still remember the good old times back in 1979 when Modbus came on the market and I developed a Modbus controller for my sewing machine.




SMT100 RS485 with Arduino

October 6, 2018 - Reading time: 10 minutes

The SMT100 by TRUEBNER is one of the most accurate low cost soil moisture sensors on the market. I was really amazed by the accuracy and repeatability presented in a scientific publication from the Research Center Jülich in Germany and instantly ordered a sensor opting for the RS485 version. RS485 is the standard used in many industrial applications but only specifies the electrical signals. The message format or protocol is another story. The protocol used by the SMT100 RS485 is T-BUS. You will find a good description on wikipedia. Though the T-BUS protocol is a very well designed and flexible protocol it requires some efforts to implement on the Arduino. I was to lazy for that and found out that the SMT100 is also capable of unterstanding simple ASCII commands. So I decided to spent a few minutes to write a small Arduino test program. Of course you do need a piece of hardware to interface an RS485 sensor to the Arduino. I had an RS485 shield from Sparkfun lying around but any of the other RS485 shields on the market should do the job as well and you only habe to spent a few bucks. The SMT100 has 4 wires which have to be connected to the shield as follows:

  • brown (Vcc, +5V)
  • white (GND)
  • green (RS485A)
  • yellow (RS485B)

This is how the setup looks like:

This is the code I have been using:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(2,3);

String str;

void setup() {

  mySerial.begin (9600);



void loop() {

    if(Serial.available() > 0)


        str = Serial.readStringUntil('\n');

        mySerial.println (str);


        if (mySerial.available() > 0){

          str = mySerial.readStringUntil('\n');


          } else {

             Serial.println("no response from sensor");




There are two serial ports, the serial port to the PC and the software serial port to the RS485 shield. It is important to choose the right pins for TX and RX. RS485 in this case is half duplex, so you have to switch between TX and RX. On my shield this is automatically done when sending out data on the TX line. On other shields you may have to set a certain pin to transmit and release fo receive. On my shield this manual switching is also possible by appropriate jumper settings but I again took the lazy way relying on the automatic switching. The Arduino code waits for commands from the PC serial port. After hitting return on the keybord the command is transmitted to the sensor via the RS485 shield. Response time may be a few 100 ms and to be sure I introduced a one second delay before checking availability of data which is printed to the serial port to the PC again. Thats all.

Here are some examples of available commands:

Command: GetTemperature!

Answer: Temperature in degrees celsius

Command: GetWaterContent!

Answer: Volumetric water content in %

RS485 is a bus system so can you have more than one sensor attached. In this case it is important to configure each sensor with an individual address. During addressing only one sensor shall be on the bus. In order to set the address of a sensor to 1 you should enter:

Command: SetAddress!1

Answer: 1

You can check the address with:

Command: GetAddress!

Answer: 1

The commands to interrogate a sensor with address 1 are:

Command: GetTemperature!1

Answer: Temperature in degrees celsius

Command: GetWaterContent!1

Answer: Volumetric water content in %



Logo! with SMT50 example

September 24, 2018 - Reading time: 7 minutes

This is an example using Logo! and SMT50 for my German gardener friends (therefore written in German).

Eine Bewässerungssteuerung mit der Logo benötigt folgende Komponenten:

  • Bodenfeuchtesensoren (hier SMT50)
  • Logo Steuerung (hier Logo8!24RCE)
  • Ventile (z.B. 24V Magnetventile von Hunter)

Eine sinnvolle Bewässerungslogik basiert auf einem Zeitprogramm, das jedoch bei zu hoher Bodenfeuchte unterbrochen wird. Das Zeitprogramm bewässert beispielsweise morgens und abends zu bestimmten Zeiten.

Als Bodenfeuchtesensor wird der SMT50 von TRUEBNER verwendet, der analoge Spannungssignale für Bodenfeuchte und Temperatur ausgibt. Die Ventile zur Bewässerung werden über Relaisausgänge der Logo gesteuert.

In diesem Beispiel soll nur ein Bodenfeuchtesensor SMT50 verwendet werden. Das Display der Logo soll sowohl die Bodenfeuchte (vol. Wassergehalt in %) und die Temperatur in °C anzeigen. Der Temperatursensor im SMT50 gibt eine Spannung aus, die gemäß der Kennlinie im Datenblatt in eine Temperatur umzurechnen ist. Beispielsweise ergeben 20°C eine Spannung von 0,6 V. Man kann das leicht mit einem Multimeter überprüfen. Dazu verbindet man den SMT50 mit einer Spannungsversorgung (braun: +4 bis +30V, weiß: Masse) und misst dann mit dem Multimeter die Spannung zwischen dem grünen Anschluss und Masse. Diese analoge Spannung kann an die Logo anlegt werden. Bei der Programmierung der Logo wird dann ein analoges Eingangselement benötigt, so wie im folgenden Bild gezeigt.

Der Messbereich der analogen Eingänge der Logo geht von 0 bis 10 V. Ein AD-Wandler bildet diesen Spannungsbereich auf Zahlen zwischen 0 und 1000 ab, die im Logo Programm weiterverarbeitet werden können. Über den Webzugriff der Logo kann man die aktuellen Messwerte anschauen. Beispielsweise wird in diesem Bild der Messwerte 70 angezeigt. Der SMT50 wurde dabei an den Analogengang 1 angeschlossen.

Der Wert 70 entspricht dabei 0,7 V. Dabei muss man jedoch die Belastung des SMT50 durch den vergleichsweise niedrigen Innenwiderstand der Logo berücksichtigen.  Es bildet sich ein Spannungsteiler aus dem Innenwiderstand des SMT50 (10 kOhm) und dem Eingangswiderstand der Logo (ca. 80 kOhm) aus, der zu einem reduzierten Spannungsmesswert führt. In einem Beispiel soll das erläutert werden. Wenn man den SMT50 zuerst nicht an den Analogeingang anschließt, so kann man bei der Temperatur vom 27,6°C eine Spannung von 0,776 V messen. Schließt man den SMT50 jetzt an die Logo an und misst wiederum mit einem Multimeter an den Eingangsklemmen der Logo, so hat sich die Spannung auf 0,690 V erniedrigt. Dies liegt am Spannungsabfall im Ausgangswiderstand des SMT50, da ein gewisser Strom fließt. Man kann diesen Spannungsabfall in der Logo durch eine entsprechende Verstärkung kompensieren. Die gemessene Spannung muss um den Faktor 0,776/0,690=1,124 verstärkt werden. Dazu passt man die Werte im Analogeingangsblock wie folgt gezeigt an (Gain auf 1,12, da nur 2 Nachkommanstellen möglich).

Zusätzlich wurde noch ein Offset eingetragen. Dieser Offset ist notwendig, da Kennlinie gegenüber dem Nullpunkt verschoben ist (0°C entsprechen 0,5V = 50 AD Wandler Werte). Berücksichtigt man eventuelle Toleranzen des Temperatursensors durch Kalibrierung mit einem Referenzthermometer, so kann man den Offset entsprechend vom Sollwert 50 verändern (hier 53).

Schließt man an den Analogeingang 2 den gelben Draht an (Feuchteausgang des SMT50), so benötigt man die im nächsten Bild gezeigte Umrechnung.

Der Faktor 1,85 rührt einmal von dem Spannungsteiler und zweitens von der Umrechnung der Spannung in Feuchte (3 V entsprechen 50% Wassergehalt).

Eine möglches Gesamtprogramm ergibt sich wie folgt:

Es werden 2 Analogsignale eingelesen (Temperatur und Feuchte), die beide auf dem Logo Display angezeigt werden. Dazu muss die Displayausgabe onfiuriert werden.

Darüber hinaus wird eine Zeitschaltuhr verwendet, die das Ventil (Relaissausgang Q1) steuern soll.

Die Bewässerung soll jedoch nur dann aktiv sein, wenn die Bodenfeuchte einen bestimmten Wert unterschritten hat. Dazu wird ein Schwellwertschalter verwendet.

Da bei Überschreitung der Feuchte die Bewässerung ausgeschaltet werden soll, ist ein zusätzlicher Inverter notwendig. Die UND-Verknüpfung gibt das Relais für die Bewässerung nur frei, wenn sowohl die Bewässerungszeit aktiv ist als auch die Bodenfeuchte unter einem bestimmten Wert liegt.







Gardenergrannys Homepage