Siemens Industry Online Support
Siemens AG
Entry type: Application example, Entry ID: 40603943, Entry date: 07/25/2014

Reading Data Matrix Codes With S7-1200 and Archiving Them in an MS Access Database (Set 27)

  • Entry
  • Associated product(s)

With an unambiguous coding, all the production steps for every part produced can be planned and carried out. The purpose of this application is to identify products reliably with a coding and to trace them after they have been delivered. A reader should read various codes on the surface of the products, and transmit them with RS232 to a SIMATIC S7 station and then to a database.

Fig. 01

The application example shows the concrete connection of the MV340 reader via the RS232 communication module CM1241 to an S7-1200 PLC. With the reader the matrix codes are transmitted into the S7-1200. The SIMATIC NET OPC server forwards these codes to the OPC Client (MS Access database). The corresponding scancode is searched for in a product table in the data base and its product name is transmitted back to the PLC via the SIMATIC NET OPC Server.

Functions of the application
The following functions have been realized in this application:

  • Configuration of the point-to-point connection of the communication module CM1241 RS232.
  • Receiving of the code from MV340 from the CM1241 and storing it in a data block on the S7-1200.
  • Using an MS Access database, in which an OPC client has been realized in VBA for the communication with the PLC.
  • Monitoring the communication between the PC and the PLC.

Fig. 02

Advantages and benefits
This application provides several universal S7 and PC program parts you can easily adapt for your projects. In particular, the communication between SIMATIC S7 and OPC Client is structured on the PC side and also in the SIMATIC S7 program so generally that it can be used for many variants of communication between the SIMATIC S7 and the PC.


Content of Downloads


Flyer 40603943_Set_27_Flyer_V20_en.pdf ( 227 KB )
Reading Data Matrix Codes With S7 and Archiving Them in an MS Access Database
40603943_DataMatrixCode_S7-1200_DOKU_V20_en.pdf ( 2681 KB )
STEP 7 V12 project for the application example
40603943_DataMatrixCode_S7-1200_CODE_V20.zip ( 5565 KB )

Security Note
Siemens provides products and solutions with industrial security functions that support the secure operation of plants, solutions, machines, equipment and/or networks. They are important components in a holistic industrial security concept. With this in mind, Siemens’ products and solutions undergo continuous development. Siemens recommends strongly that you regularly check for product updates.
For the secure operation of Siemens products and solutions, it is necessary to take suitable preventive action (e.g. cell protection concept) and integrate each component into a holistic, state-of-the-art industrial security concept. Third-party products that may be in use should also be considered. For more information about industrial security, visit
To stay informed about product updates as they occur, sign up for a product-specific newsletter. For more information, visit

Last modification
Figures, Flyer, Security Note