-
1Enter Dragino Lora device properties in TheThingsNetwork
In the box of the LoRa device there is a sticker with all possible keys, EUIs, addresses and the serial number.
- DEV ADDR
- DEV EUI
- APP EUI
- APP KEY
- APPSKEY
- NETSKEY
After logging into TheThingsNetwork Console a new application is created. The APP EUI from the sticker is added via addEUI. Then a new device is created. It is very important to enter the DEV EUI, the APP EUI and the APP KEY from the sticker. Voilá, that's it for now with TheThingsNetwork and we go to the LoRa module. (Note: With other keys and EUIs you can certainly also work, but then have greater configuration effort on the module side).
-
2Connect SMT100 soil moisture sensor to LoRa device
The next step is to connect the SMT100 RS-485 soil moisture sensor with the LoRa module as follows (left green socket for screwing, attention: look up exact assignment in the Dragino manual!):
- Brown wire +5 V
- White wire GND
- Green wire RS-485 A
- Yellow wire RS-485 B
Then connect the USB to TTL cable for configuration (right socket for pin headers, attention: look up exact assignment in Dragino manual!):
- GND
- UART_TXD
- UART_RXD
Please make sure that the USB TTL cable has 3.3 V level (TX from LoRa module to RX from cable, RX from LoRa module to TX from cable, if necessary check exactly how the cables are assigned and the connections are defined). I used a cheap cable from Ebay (about 4 Euro) and made sure that a FT232 USB chip is used. This usually does not give driver problems. I prefer to use HTerm as terminal program. The switches on the LoRa module must be set to 5V and Flash. The jumper for the supply of the module with the battery voltage must of course also be plugged.
-
3Configure LoRa device
In HTerm or any other terminal program you see the start of the module after plugging the power supply jumper.
Now you can configure the SMT100 by entering the password in HTerm (123456) and then send AT commands (Attention: Always capitalize commands and don't forget the CR at Send on Enter).
- AT+BAUDR=9600 (9600 baud)
- AT+PARITY=2 (even parity)
- AT+5VT=100 (wait 100ms after turning on the 5 V supply for the sensor)
- AT+MBFUN=1 (enable Modbus)
- AT+COMMAND1=fd 03 00 00 00 01,1 (Temperature)
- AT+COMMAND2=fd 03 00 01 00 01,1 (Soil moisture)
- AT+DATACUT1=0,0,0
- AT+DATACUT2=0,0,0
- AT+TDC=60000 (Transmission interval, 60 s = 60000 ms)
You may check settings with:
- AT+BAUDR=?
- AT+PARITY=?
- AT+5VT=?
- AT+MBFUN=?
- AT+COMMAND1=?
- AT+COMMAND2=?
- AT+DATACUT1=?
- AT+DATACUT2=?
- AT+TDC=?
The communication between the LoRa module and the connected SMT100 can be tested using AT+CFGDEV. Here is an example:
For explanation you should have the application note for Modbus from TRUEBNER ready.
The byte sequence fd 03 00 00 00 01 sends a Modbus broadcast to the one connected sensor and expects the temperature. The temperature is stored in the response in the 4th and 5th byte as a 16 bit number. If 2d e3 is converted to a decimal value, 11747 is obtained. If 11747 is divided by 100 and 100 is subtracted, 17.47°C is obtained. The byte sequence fd 03 00 01 00 01 sends a Modbus broadcast to the one connected sensor and expects the soil moisture. The soil moisture is stored in the response in the 4th and 5th byte as a 16 bit number. If 0b c3 is converted to a decimal value, 3011 is obtained. If 3011 is divided by 100, 30.11% is obtained as volumetric water content.
After the successful test the USB cable can be removed and the LoRa module is ready for operation.
-
4Check in TheThingsNetwork
After the successful test the USB cable can be removed and the LoRa module is ready for operation. Now you can go back to TheThingNetwork and watch the LoRa communication, but before that you should set a TTN decoder, so that the transmitted byte sequences are interpreted correctly. The decoder used here looks like this and extracts battery voltage, temperature and soil moisture from the data. (Note: The LoRa module transmits the battery voltage and also a payload version value by default, but we do not consider it here).
The following screenshot shows the data packets with the individual bytes and the decoding.
What is the next step? There is still a visualization missing, for which there are several possibilities.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.