April 7, 2025

34 Views

ERP

How to Store IoT Data Inside ERPNext: A Complete Guide for IoT Companies

...
Mradul Mishra
CTO Techsolvo
Table of Contents

Why Store IoT Data in ERPNext?

Integrating IoT data into ERPNext helps your organization:

  • Monitor machine performance in real time

  • Trigger automated workflows (e.g., create a maintenance ticket)

  • Generate actionable reports

  • Centralize production and device data

  • Improve predictive maintenance and reduce downtime


Tools and Technologies You’ll Need

Before you start, here’s what you’ll typically require:

  • ERPNext Instance (hosted on a cloud or private server)

  • IoT Device (any sensor-enabled machine or device)

  • MQTT Broker (like EMQX or Mosquitto)

  • MQTT Client / Bridge (a Python script, Node-RED, or any client)

  • Custom Frappe App or API Endpoint inside ERPNext to receive the data


Step-by-Step Guide to Store IoT Data in ERPNext


Step 1: Set Up Your ERPNext Environment

Host ERPNext using Frappe Cloud, VPS, or any preferred cloud provider. Ensure your instance is running and ready for integration.


Step 2: Design a DocType for Your IoT Data

Create a custom DocType in ERPNext to store machine data.

Example: Machine Data Log

  • Device ID (Data)

  • Timestamp (Datetime)

  • Temperature (Float)

  • Pressure (Float)

  • Humidity (Float)

  • Status (Select: OK / Warning / Critical)

$ bench new-doctype "Machine Data Log" --module "Custom App" --custom

Step 3: Set Up an MQTT Broker

Use an MQTT broker like EMQX or Mosquitto to handle device data:

  • Devices publish to a topic (e.g., machine/01/data)

  • Backend listens for updates and acts on them


Step 4: Write a Middleware or MQTT Subscriber

This script subscribes to the topic and forwards data to ERPNext via API.

Example (Python with paho-mqtt):

import paho.mqtt.client as mqtt
import requests
import json

ERP_URL = "https://iot.erp.company.com/api/resource/Machine Data Log"
ERP_TOKEN = "token {api_key}:{api_secret}"

def on_message(client, userdata, message):
    payload = json.loads(message.payload.decode())
    data = {
        "device_id": payload["device_id"],
        "timestamp": payload["timestamp"],
        "temperature": payload["temperature"],
        "pressure": payload["pressure"],
        "humidity": payload["humidity"],
        "status": payload["status"]
    }
    response = requests.post(ERP_URL, headers={"Authorization": ERP_TOKEN}, json={"data": data})
    print(response.status_code, response.text)

client = mqtt.Client()
client.connect("broker.emqx.io", 1883, 60)
client.subscribe("machine/+/data")
client.on_message = on_message
client.loop_forever()

Step 5: Secure Your APIs

  • Use ERPNext API keys (via API Key & Secret)

  • Enforce role-based access controls

  • Use HTTPS for secure transmission


Step 6: Automate and Trigger Events

You can write server-side scripts (hooks) that trigger actions based on the IoT data received.

Example Hook:

@frappe.whitelist()
def after_insert(doc, method):
    if doc.status == "Critical":
        frappe.get_doc({
            "doctype": "Maintenance Visit",
            "machine": doc.device_id,
            "status": "Scheduled",
            "description": f"Auto-generated ticket for {doc.device_id} - critical status",
        }).insert(ignore_permissions=True)

Visualize Your Data with Dashboards

Use ERPNext's built-in dashboard builder to create:

  • Live status monitors

  • Environmental trend reports

  • Downtime analytics

Or integrate with Metabase for more advanced dashboards.


Real-World Use Case Example

Imagine you run a factory with 30 CNC machines, each sending live temperature and load data:

  • Every 5 seconds, devices push JSON to MQTT

  • Middleware sends data to ERPNext

  • Alerts create support tickets

  • Reports highlight patterns in temperature surges


Benefits of Using ERPNext for IoT Data

  • Open-source and fully customizable

  • Centralized control over operations

  • Real-time insights and automations

  • Great for scaling in manufacturing and logistics


Bonus Tip: Test Everything in a Staging Setup

Before going live:

  • Simulate devices and payloads

  • Test high-frequency data loads

  • Monitor logs and error handling


Wrapping Up

Combining ERPNext with IoT enables smarter operations, predictive maintenance, and real-time control over machine processes. With MQTT and custom DocTypes, the integration is fast, scalable, and highly efficient.

If you're an IoT-driven company ready to bring ERP intelligence to your machines, connect with our Techsolvo experts to get started.

Let's get in touch

Give us a call or drop by anytime, we endeavour to answer all enquiries within 24 hours on business days.

Let's Convert Your Idea into Reality

Insights

To properly understand the things that are prevalent in the industries, keeping up-to-date with the news is crucial. Take a look at some of our expertly created blogs, based on full-scale research and statistics on current market conditions.

blog-image
ERP

How to Store IoT Data Inside ERPNext: A Complete Guide for IoT Companies

A complete guide for IoT and manufacturing companies on integrating machine-generated dat…

author
Mradul Mishra

April 7, 2025

blog-image
HRMS

Automation in Human Resource Management with Frappe HRMS

Discover how HR automation with Frappe HRMS can streamline HR operations, enhance employe…

author
Mradul Mishra

April 7, 2025

blog-image
HRMS

Top Open-Source HRMS Systems in 2025: The Best Free HR Software for Businesses

Discover the best open-source HRMS systems in 2025! Explore top HR software like Frappe H…

author
Mradul Mishra

April 7, 2025