top of page
Search

Build a Data Acquisition, Processing, and Analysis System Faster and Cheaper with InDriver!

Writer: Andrzej JaroszAndrzej Jarosz

Here’s an example of an IIoT task: Every minute, collect data from a gas flow recorder (Modbus) and an energy meter (REST API), process it, and save it to an SQL database.


See how this can be done with the InDriver platform.

InDriver Industrial Data Integration Platform
InDriver Industrial Data Integration Platform

Forget expensive, complex tools like Ignition SCADA, Kepware, Matrikon, Node-RED, Azure Data Factory, or Postman. InDriver offers a simple, flexible, and affordable solution that runs on servers, edge devices, or the cloud. It scales easily with JavaScript-based tasks using ready-made API functions.


How do you think you could build a system with InDriver?


  1. Download it for free from inanalytics.io and install it on Windows.

  2. Define an SQL database and add your first task.

  3. Set when the task runs: on startup, cyclically, on messages, or shutdown.

  4. Write simple code or use ready examples.

  5. DONE!


Example: Every minute, collect data from a gas flow meter (Modbus) and energy meter (REST API), process it, and log it to an SQL database.


Gas Flow Meter with Modbus RTU
Gas Flow Meter with Modbus RTU

Energy Meter with REST API
Energy Meter with REST API


Solution made with InDriver:


InDriver configuration edited in InStudio
InDriver configuration edited in InStudio

JS Code:


  • onStartup – definition of connections to the meter and recorder, specifying the data polling frequency.


InDriver.import('RestApi');
InDriver.import('ModbusApi');
InDriver.loadScript(\"devicelibrary/plum.js\");

// connect to RESTAPI Energy Meter
RestApi.defineRequest('shelly','{"url":"https://shelly-56-eu.shelly.cloud/device/status?id=34945477f146&auth_key=<enter_your-key>","timeout":5000, "type":"post","headers":{"ContentTypeHeader":"application/json"}}');

// connect to Modbus Gas Meter
ModbusApi.connectDevice('Kotlownia_Gaz', '{"mode":"TCP","networkAddress":"10.4.107.159","networkPort": 502,"timeoutMs": 3000,"numberOfRetries": 3}');"

InDriver.installHook(60000); // call onHook every minute synchronized to RTC. 

  • onHook – parallel data reading every minute from REST API and Modbus, value processing, and logging to the Azure SQL database.


 let ts = InDriver.hookTs();

ModbusApi.begin();
RestApi.begin();

MacREJ5R_readVQTAsyncReq("Kotlownia_Gaz",2);
RestApi.sendRequest('shelly');

RestApi.commitWait();
ModbusApi.commitWait();

 if (RestApi.isSucceeded()) {
		 const text = RestApi.getData('shelly');
		 const obj = JSON.parse(text);
		 let energy1 = Math.abs(obj.data.device_status.emeters[0].total_returned);
		 let energy2 = Math.abs(obj.data.device_status.emeters[1].total_returned);
		 let energy3 = Math.abs(obj.data.device_status.emeters[2].total_returned);

		 let power1 = Math.abs(obj.data.device_status.emeters[0].power);
		 let power2 = Math.abs(obj.data.device_status.emeters[1].power);
		 let power3 = Math.abs(obj.data.device_status.emeters[2].power);
		 let energy3f = energy1 + energy2 + energy3;
		 let power3f = power1 + power2 + power3;
		
	if (last_energy3f !=energy3f) {
		 let data = {
		 power1 : power1,
		 power2 : power2,
		 power3 : power3,
		 voltage1 : Math.abs(obj.data.device_status.emeters[0].voltage),
		 voltage2 : Math.abs(obj.data.device_status.emeters[1].voltage),
		 voltage3 : Math.abs(obj.data.device_status.emeters[2].voltage),
		 current1 : Math.abs(obj.data.device_status.emeters[0].current),
		 current2 : Math.abs(obj.data.device_status.emeters[1].current),
		 current3 : Math.abs(obj.data.device_status.emeters[2].current),
		 energy1 : energy1,
		 energy2 : energy2,
		 energy3 : energy3,
		 energy_total: energy3f,
		 power_total: power3f
		 }
		 let shelly = {Shelly:data};
		 let list = [];
		 list.push(shelly);
		 let json = JSON.stringify(list);
		 InDriver.sqlExecute("azureserver", "insert into public.shelly (source, ts, data ) values ('Shelly','"+ts.toISOString()+"',$$"+json+"$$);");	
		 let delta = energy3f-last_energy3f;
		 InDriver.debug("Delta E: "+ delta+" Wh :" + json);
		 InDriver.sendMessage(ts, 'DeviceData', json);
		 last_energy3f = energy3f;
	} 
}

if (ModbusApi.isSucceeded()) {
   let data = JSON.stringify(MacREJ5R_readVQTAsyncProcess("BB_Kotlownia_Gaz"));
   InDriver.debug("BB_Kotlownia_Gaz "+data );
   if ( ModbusApi.isLastTransactionCompleted('BB_Kotlownia_Gaz') ){
   InDriver.sqlExecute("LocalPGSQL", select tsapiinsert('public', 'measurements',      'BB_Kotlownia_Gaz', '${ts.toISOString()}', '${data}')) 
   }
}

This example code shows how quickly you can build a system with InDriver, integrating Modbus, REST API, and SQL! 🚀

I'm curious if you’ve read this far 😉 and whether you implement similar solutions or see potential applications for the InDriver platform in your facility.

Feel free to contact me at contact@inanalytics.io or visit https://inanalytics.io.


 
 
 

Comments


bottom of page