During my secondment at the University of Pontianak, I had the opportunity to contribute to the Sustainable project. My main role was assisting colleagues in developing a peatland monitoring system in West Kalimantan. The goal was to assess new production methods to enhance the quality and sustainability of coconut plantations.

Professor Doddy set two key requirements for our project: the sensor device needed to measure soil pH and temperature, and the system had to transmit data directly via the Internet, without relying on a data logger.

The system we proposed was quite simple: one gateway and two or more sensor devices. After a thorough market analysis, we decided to purchase a Dragino LG308 Indoor gateway from Indonesia’s Tokopedia e-commerce platform. We then built a custom case to make it suitable for outdoor conditions. For the sensors, we selected the LSPH01 for pH and temperature (purchased on Alibaba) and the LSE01 for in-depth temperature (provided by my company FgTech).

As part of the initial groundwork, I led a comprehensive training session for my colleagues. I covered the fundamental setup and components of an IoT (Internet of Things) system, along with a detailed overview of the LoRaWAN communication protocol. In essence, our devices connect to a gateway using a narrow radio frequency, which in Indonesia is 920 MHz. The gateway’s purpose is to link these sensors to the internet infrastructure, enabling data storage in the cloud. The network layer incorporates communication protocols like MQTT for machine-to-machine remote communication, a platform for device management, and a decoding script to make the data human-readable.

I worked extensively with Professor Asrul Abdullah on setting up the LG308 gateway. Dragino provided excellent documentation for configuring the LG308 using TheThingsNetwork as our network platform. What’s more, Dragino’s open-source design policy allowed us to modify the frequency of the LSE01 to ensure compatibility with Indonesia’s frequency regulations.

However, during testing, we encountered an issue with the LSPH01: the pH data was incorrect, consistently returning pH 3 instead of 7. Initially, we tried adjusting the payload parser and re-checked our setup configurations, but the problem persisted. We then meticulously tested all components of the Dragon device and discovered the root cause: a manufacturing error in the RS485 to TTL converter. This converter is crucial because the sensor probe uses different voltages for pH and temperature but transmits data via the same wiring.

Once we identified the problem, we explored alternative solutions. Our first thought was to reuse the pH probe and build an Arduino device to communicate with the gateway. Unfortunately, we quickly realized we needed a specific model of RS485 to TTL converter that wasn’t available in the local market; the only known seller was in India.

This challenge, however, presented an exciting opportunity. We decided to build a unique, all-in-one LoRaWAN soil sensor that we noticed wasn’t readily available commercially. We sourced a 7-in-1 soil sensor from the Chinese company Weihai, capable of sensing macronutrients (NPK), humidity, temperature, pH, and electrical conductivity.

We successfully built the device using the following components:

  • ESP32 as the microcontroller
  • OLED display for output
  • Wires for connections
  • 7-in-1 integrated soil sensor
  • RS485 to TTL for data transmission
  • ArduinoIDE for code development

We also built an Arduino gateway to test the device connection. The device’s software consists of two main scripts: one for decoding sensor input and transmitting data, and another for receiving data. While transmitter and receiver scripts were available in Arduino documentation, we developed the decoder script from scratch, based on the sensor’s datasheet. This script utilizes the AltSoftSerial Library to emulate an additional serial port. The script is divided into a setup function (to put the RS485 in receiving mode) and a loop that saves each of the seven variables.

The outcome was successful! We managed to connect the device with the Arduino gateway. We initially encountered a packet loss issue, which we easily resolved by increasing the data sending interval to one hour.

In parallel, Mr. Asrul Abdullah focused on the platform stack for connecting and saving soil data in a database. We opted for the following robust platforms:

  • TheThingsNetwork (TTN): An open, global, community-driven IoT network providing infrastructure for LoRaWAN communication.
  • InfluxDB: An open-source time-series database optimized for storing, querying, and visualizing time-stamped data.
  • Node-RED: An open-source visual programming tool for wiring together hardware devices, APIs, and online services.
  • Grafana: An open-source analytics and visualization platform for querying, visualizing, alerting on, and understanding metrics.

Finally, Professor Doddy gave me the wonderful opportunity to present on Agri-IoT and LoRaWAN to the students of the University of Pontianak. It was a fantastic chance to explain a general IoT system and demonstrate how these concepts were applied within our consortium’s project.