IGT-20 with Modbus for Environmental Monitoring

Abstract

This article describes a real installation of IGT-20 that collects information of temperature and humidity in an electric component warehouse. In this installation, IGT-20 accesses to four sensors which run a very popular Modbus RTU protocol over the RS-485 interface. IGT-20 keeps monitoring if the values go beyond the expected limits. Historic data are stored in IGT-20 and visualized with D3.js. And also the stored data can be uploaded to cloud for further analysis.

System Overview

The following figure reveals the overview of the described system.IGT-20 Environmental Monitoring System ArchitectureIn order to know the temperature and humidity at different locations, it’s very common to use multiple sensors. And these location might be far away from one another. Thus the multi-drop wiring and long distance features of RS-485 make it a good choice. There totally four sensors in this installation at the four corner of this warehouse.

IGT-20 acts as a gateway to inquiry data from these sensors via its built-in RS-485 and upload it to private and public clouds via its built-in LAN. Beside of the transparent transmission, IGT-20 can also monitors, stores and visualizes the data.

With totally two SDHC slots, IGT-20 makes it possible to keep user data up to around 60GB. Considering some applications, such as discrete manufacturing, environmental monitoring, health care and so on, this is a sufficient storage and enables advanced features.

IGT-20 monitors the local and real time data in two ways. The first is to check if each single datum is in a expected range. Besides, the locally kept historic data enable IGT-20 to check the trend and stability of data. This ensures the electronic components staying in a good condition. Further complicated off-line analysis is also possible after these data is uploaded.

Apache Server is installed in IGT-20 to provide cross-platform visualization of the locally stored data. Managers and warehouse keepers can use their desktop, handy phone and tablet to inquiry the data or to see the whole trend chart just with those commonly used web browsers.

The built-in mPCie slot has been reserved and not used yet. By installing a 3G or LTE module, IGT-20 can use SMS to send short message to warehouse keepers once abnormal situation occurs. However, this is not covered in this article.

Modbus RTU on IGT-20

Modbus is a de-facto standard for industrial devices and uses the master-slave architecture. That is, the master asks, and then the assigned slave reacts. The frame format is quite simple for implementation. And the hardware requirement is low. Thus Modbus has been a popular protocol and and still widely used around the world.

As an industrial gateway, IGT-20 provides two built-in configurable RS-232/422/485 serial ports to connect to devices with different interfaces. The modes, i.e. RS-232, RS-422 and RS-485, is switched by setting two internal GPIOs. This is covered by another article.

The auto flow control feature of RS-485 of IGT-20 makes it easier to program for half-duplex interface. It’s a wise choice to use sensors with Modbus RTU over RS-485 with IGT-20. According to the manual of the sensor, the default Device ID is 0x01, and temperature and humidity are available at Holding Register 0x02 and 0x03 respectively. What we need to do is open the serial port and send the following hex out.

0x01 0x03 0x00 0x02 0x00 0x02 0x65 0xCB

If everything is fine, the response can be read

0x01 0x03 0x04 0xTT 0xtt 0xHH 0xhh 0xRR 0xrr

where

temperature = (TT*256+tt)/10.0
humidity = (HH*256+hh)/10.0

RR and rr are the CRC. It’s not difficult to complete this implementation. However, a Modbus library has been developed by libmodbus.org, and has been put into Debian repositories. Although libmodbus is not included in the factory OS image, it can be installed by the following command:


apt-get update && apt-get upgrade
apt-get install libmodbus-dev

Using libmodbus make it much easier to read temperature and humidity with the following pseudo code:


ctx=modbus_new_rtu(TTY_DEVICE, BAUDRATE, PARITY_CHECK, DATA_BITS, STOP_BITS);
modbus_connect(ctx);
modbus_set_slave(ctx, DEVICE_ID);
modbus_read_registers(ctx, 2 /*start addr*/, 2 /*# of registers*/, readData);
temperature=readData[0];
humidity=readData[1];
modbus_close(ctx);
modbus_free(ctx);

The CRC field and error handling of communication are done by libmodbus. Focus can be put on the data itself.

D3.js on IGT-20

Using the ready library libmodbus is only part of IGT-20 benefit. The pre-installed Debian comes with more than 50,000 packages. Apache is another commonly used software package. Apache is a very popular web server. Around 50% of the on-line web server is based on Apache. Apache can also be installed by the following command:


apt-get update && apt-get upgrade
apt-get install apache2

Installing Apache turns IGT-20 into a small web server and connects IGT-20 with modern web technologies, such as AJAX and HTML5. One of the possibilities is to make IGT-20 accessible on different platform, such as desktops, handy phones and tablets. In this installation, visualization of the stored data is done with D3.js.

D3.js is a JavaScript library and helps to bring data to life using HTML, SVG and CSS. With a few lines of code of D3.js and JavaScript, an interactable and clear real-time chart can be implemented. This provides a good choice of UI for local data. Again once it’s done, it’s cross-platform accessible.

Detail of implementation is not covered here. Following is the screen shot from a handy phone.

Though there’s no display output of IGT-20, there is still much possibility to create a better user interface if necessary.

Conclusion

This picture was taken where this installation deployed. IGT-20 is at the bottom of the picture, two sensors locates at right side of this picture, while another two are outside of the picture. In this installation, IGT-20 acquires temperature and humidity data via RS-485 with Modbus RTU protocol. By using lib

modbus, a free software library to send/receive data according to the Modbus protocol, it’s very easy to turn IGT-20 into a Modbus master and get data from slaves. And there are many other Modbus sensors, such as air quality and air pressure,  for environmental monitoring.

IGT-20 equips with Cortex-A8, 1GB RAM and pre-installed OS, Debian, which comes with around 50,000 software packages to facilitate your work. Besides, around 60GB storage of user data is provided by the dual SDHC slots. This makes it possible to store the data and make a local analysis.

The raw data, analysis result and alarm if any can be uploaded to private or public cloud via the built-in LAN, or optional WiFi/3G/LTE modules depending on your application. The real time trend chart, or any other visualization, is also possible and made easy by off-the-shelf packages, such as Apache and D3.js.

If your work needs only transparent transmission, there are many other lower level products which meet the needs well. However, if local storage, on-line analysis and visualization of data are considered, IGT-20 can be a better solution.

Comments are closed.