iMod - new function: PSQL Event

A new function has been introduced in the iMod telemetric module – the capability of writing Postgre SQL data to a local or external database using a Message channel.

PostgreSQL is a free system for managing relationship databases. Databases of this type are characterized by an unlimited maximum base size and the possibility for management by means of an internet browser. In addition, it introduces the possibility of using different programming languages and features high stability and efficiency.

The iMod allows for writing of any amount of data from sensors and devices connected to it.* Thanks to a message channel, this data is sent to a PostgreSQL database depending on the type of event that will call it up, or cyclically, every so often. In the first case, it is sufficient to add the appropriate event to a parameter definition (for a change in value, after exceeding the threshold value or for a lack of change in further readings). In the second case, a script channel should be used, as discussed in the previous article.

Writing to an SQL base in the case of an event

A correctly defined message channel should appear as follows: 

  1. <message-channel name="Database">
  2.     <protocol name="SQL"/>
  3.     <port>""</port>
  4.     <property name="mode" value="direct"/>
  5.     <property name="driver" value="POSTGRESQL"/>
  6.     <property name="user" value="postgres"/>
  7.     <property name="password" value="1234"/>
  8. </message-channel>

The protocol has been defined as SQL, driver - PostgreSQL. The channel port is defined as the IP address of the external database, the access port to it, and the name of the database. In the next lines, the writing method, user name, and access password are given. In the future, the number of possible methods for communication will be increased.

The next step is to define the content of the sent message. According to the syntax of the SQL language, implementation of the message appears as follows:

  1. <message id="statement">
  2.     <![CDATA[ "INSERT INTO X (Value, Date) VALUES ('REG_VALUE[THIS]','TIME');"]]>
  3. </message>

As shown above, the current value of a given parameter and the date of entry will be input into table X in the Value and Date rows.

The final step is to force an entry to the PostgreSQL database, depending on the event. For this purpose, the appropriate event is to be configured in the parameter definition: 

  1. <parameter>
  2.     <id>100</id>
  3.     <source-channel channel-name="NPE_io" parameter-id="USER_LED"/>
  4.     <access-channel channel-name="Modbus_S1" parameter-id="100"/>
  5.     <event type="OnChange">
  6.         <message-channel channel-name="Database"/>
  7.         <message-id>"statement"</message-id>
  8.     </event>
  9. </parameter>

As seen in the above definition, the state of the User LED on the device will be saved in a database that has been configured earlier at the time of a change in its state.

 iMod + PostgreSQL
Scheme of using communication with a PostgreSQL external server

An undoubted advantage of such a function is the capability of writing data onto external disks, which practically allows for the writing of an unlimited amount of information.

*the only limit is the built-in device memory.

See devices from iMod series

Articles in Categories: Case Study Collapse
iMod in complex CANopen networks
The NPE/iMod telemetric module is perfect for use in CANopen networks – you just need to connect the external GW-7433D module included in the catalog offer. This protocol is very often used in the machine operating and automation systems. Its unquestionable advantages are easy installation and advance mechanisms for network error detection.
Read article »
iMod: Case Study Hydropower Plants
Due to a growing demand for electricity people started to look for new forms of energy production, especially from renewable sources.
Read article »
iMod: Case Study – Monitoring of Vehicles
Many of our clients look for innovative solutions in vehicle monitoring projects recently. iMod as a compact fanless solution, equipped with an additional GPS module can be used for this type of application without any problems.
Read article »
iMod – Case Study: renewable energy sources – solar panels
In recent years, use of many types of natural factors and phenomena as primary energy sources is being talked about more and more often and outspokenly. One such renewable source of energy is sunlight...
Read article »
Free SMS Gateway
Along with the development of the NX Dynamics platform (dedicated software for theNPE/iMod series devices), we have created a fully functional, free of charge and easy to use SMS gateway.
Read article »
VPN on NPE industrial computers
A Virtual Private Network is a safe tunnel used to send encrypted data between distant local networks or users in the virtual private network through a public network – mainly the internet.
Read article »
iMod – boiler room monitoring
By using the iMod telemetric module, the boiler room becomes fully automated – all processes are realized automatically, according to pre-defined logical criteria…
Read article »
iMod Case Study: Wind farm monitoring
The iMod telemetric module finds wide applications in monitoring and output management of a single wind turbine as well as of the entire farm.
Read article »
iMod – heating substation monitoring
The iMod, based on the NPE platform as a telemetric module, finds wide applications in heating substation monitoring in large heat transfer stations as well as in compact units.
Read article »
iMod PLC in refrigerating engineering
The iMod telemetric module has a wide range of applications in the field of automation. One of the many branches of industry in which the iMod fulfills the expectations of clients, and the requirements for control systems, is refrigerating engineering.
Read article »
iMod configurable automation controller with expansion modules
Thanks to external M-7xxx modules from the ICPDAS company, the iMod telemetric module has been expanded by additional inputs and outputs.
Read article »
The iMod as a fully functional PLC controller
The iMod telemetric module, besides many functions that are ideally suited for use in the fields of telemetry and industrial automation, has been equipped with a new function - PLC.
Read article »
Controlling iMod telemetric module using a TPD series touch HMI
The TPD series of small touch control panels makes it possible to expand the range of capabilities of the iMod telemetry module...
Read article »
iMod - remote supervision for wastewater pumping stations PC2000W
Thanks to the apache webserver included inside iMod we have developed a complete hmi application that includes synoptic, pump data, station data, alarms and logger files...
Read article »
Building monitoring - iMod with 1-Wire interface
iMod with 1-Wire interface controlls distributed temperature sensors, humidity alarm fire protection and access control (opening doors, windows)
Read article »