Back to articles
AI & Cloud

Configure VPS as IoT Edge Data Aggregator for Smart Agriculture: Optimize Data and Reduce Costs

A detailed guide on configuring a VPS as an IoT Edge Data Aggregator for smart agriculture, optimizing data and reducing operational costs. Utilize edge computing to process sensor...

DPTCloud Engineering5 min read
Configure VPS as IoT Edge Data Aggregator for Smart Agriculture: Optimize Data and Reduce Costs

Introduction to IoT Edge Data Aggregator for Smart Agriculture

In the context of rapidly growing smart agriculture, collecting, processing, and analyzing data from environmental sensors (temperature, humidity, light, soil pH, etc.) is a key factor in optimizing yield and reducing operational costs. However, transmitting data from hundreds of sensors to the cloud often causes high load, high latency, and high costs. An effective solution is to use a VPS as an IoT Edge Data Aggregator – a system that processes data locally (edge computing), sending only aggregated, filtered, and analyzed data to the cloud or central system.

This station acts as an intermediary between IoT devices and the agricultural management system, reducing cloud load, improving response speed, and enhancing overall performance. This guide will walk you through configuring a VPS (High-RAM Cloud VPS) to become an efficient Edge Data Aggregator for smart agriculture.

Requirements and Preparations Before Configuration

To successfully deploy this solution, you will need:

  • High-RAM Cloud VPS: Choose the High-RAM Cloud VPS for Self-Hosted LLMs & API Gateways with at least 16GB RAM and 4 vCPU to handle data from multiple sensors simultaneously.
  • Operating System: Ubuntu 22.04 LTS or Debian 11/12 for stability and full support.
  • Necessary Software: MQTT broker (Mosquitto), InfluxDB (or TimescaleDB), Node-RED or Python (with paho-mqtt, influxdb-client libraries), and monitoring tools (Prometheus + Grafana).
  • IoT Devices: Agricultural sensors (e.g., DHT22, Soil Moisture Sensor, Light Sensor, etc.) connected via Wi-Fi, LoRa, or MQTT.

Implementing the Edge Data Aggregator Configuration

Perform the following steps on your VPS:

1. Install and Configure MQTT Broker (Mosquitto)

MQTT is a lightweight protocol suitable for IoT. It allows sensors to send data to the Edge station efficiently.

sudo apt update
sudo apt install mosquitto mosquitto-clients -y
sudo systemctl enable mosquitto
sudo systemctl start mosquitto

2. Install and Configure InfluxDB (Time-Series Data Storage)

InfluxDB is an ideal time-series database for sensor data.

# Add InfluxDB repository
wget -qO - https://repos.influxdata.com/influxdata-archive_compat.key | sudo tee /etc/apt/keyrings/influxdata-archive.key
echo 'deb [signed-by=/etc/apt/keyrings/influxdata-archive.key] https://repos.influxdata.com/debian stable main' | sudo tee /etc/apt/sources.list.d/influxdata.list
sudo apt update
sudo apt install influxdb -y
sudo systemctl enable influxdb
sudo systemctl start influxdb

3. Set Up Node-RED for Data Processing and Aggregation

Node-RED is a visual tool for programming IoT data processing logic.

# Install Node.js
curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install nodejs -y

# Install Node-RED
sudo npm install -g --unsafe-perm node-red
sudo systemctl enable nodered
sudo systemctl start nodered

In Node-RED, create flows to:

  • Perform data filtering (remove erroneous values, values outside thresholds).
  • Aggregate data (calculate averages, max/min over time intervals).
  • Send processed data to InfluxDB.
  • Send alerts via email or Telegram if values exceed thresholds.

4. Connect IoT Sensors

Set up IoT sensors to send data to the MQTT broker on the VPS. For example, with a DHT22 sensor:

import paho.mqtt.client as mqtt
import Adafruit_DHT

sensor = Adafruit_DHT.DHT22
pin = 4

# Connect to MQTT broker
client = mqtt.Client()
client.connect("your-vps-ip", 1883, 60)

# Send data
humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
if humidity is not None and temperature is not None:
    client.publish("farm/sensor/temperature", f"{temperature:.1f}")
    client.publish("farm/sensor/humidity", f"{humidity:.1f}")

Optimizing Data and Reducing Costs

This solution offers several benefits:

  • Data Optimization: Only transmit processed data, reducing 70-90% of data sent to the cloud.
  • Reduced Operational Costs: Lower bandwidth usage, reduced cloud storage and processing costs.
  • Fast Response: Local processing enables immediate feedback when issues occur (e.g., high temperature).
  • Increased Reliability: Less dependent on internet connectivity.

Verification and Testing

To verify the system is working:

  • Run the command: mosquitto_sub -t "farm/sensor/#" -v to see sensor data arriving.
  • Access InfluxDB UI (http://your-vps-ip:8086) and check that data has been saved.
  • Access Grafana (if installed) to view time-series data charts.

Troubleshooting

  • No data received: Check MQTT connection, firewall (port 1883 must be open), and topic names.
  • InfluxDB not receiving data: Check access permissions, database name, and connection from Node-RED.
  • Node-RED not starting: Check logs: journalctl -u nodered -n 50.

References

DPTCloud Tier III Infrastructure

High-RAM Cloud VPS Plans Optimized for AI, Databases & Cache

Enterprise RAID 10 NVMe SSDs, CMC & FPT District 9 uplinks with Anycast Anti-DDoS and 99.99% SLA.

View 22 VPS Plans
ECO · vn-02Recommended

VPS-4E

297.000 ₫ / mo

10% VAT included

  • CPU: 4 vCPU
  • RAM: 8 GB
  • SSD: 50 GB NVMe
ECO · vn-02

VPS-5E

614.900 ₫ / mo

10% VAT included

  • CPU: 8 vCPU
  • RAM: 16 GB
  • SSD: 100 GB NVMe
ADVANCED · vn-03Recommended

VPS-4T

548.900 ₫ / mo

10% VAT included

  • CPU: 4 vCPU
  • RAM: 8 GB
  • SSD: 50 GB NVMe

Related Articles

View all
ZaloZalo SupportDiscord0384 753 478