This quickstart tutorial walks through how to capture, store, transform, forward, and query data using a Siemens S7 simulator.
Requirements
- Ensure the FairCom server is installed and running.
- Verify that Siemens S7 service is enabled in the FairCom Edge server.
- Edit the
services.jsonfile in theconfigfolder. - Locate the
"integrationServices"object of the service for the desired platform. - Set
"enabled"totrue.-
Windows
"integrationServices": [ { "serviceName": "siemensS7", "serviceLibrary": "siemenss7service.dll", "schemaName": "siemensS7", "enabled": true }, -
Linux
"integrationServices": [ { "serviceName": "siemensS7", "serviceLibrary": "libsiemenss7service.so", "schemaName": "siemensS7", "enabled": true },
-
Windows
- Save any changes. Restart FairCom Edge Server.
- Confirm server access by running the FairCom API Explorer. The typical URL is https://localhost:8443/.
Initialize the Siemens S7 simulator
For this tutorial, we are using an open-source Siemens S7 simulator available with the snap7 package.
- Download and extract the full snap7 package from this website: Snap7 Official examples or by searching for "snap7 examples" and downloading the most current version.
- Launch the open-source Siemens S7 server simulator that is included with the package.
- Open a command prompt.
- Navigate to the folder of the server executable for the OS being used.
- For Windows: <snap7_examples_directory>\cpp\win64\
- For Linux: <snap7_examples_directory>/cpp/x86_64-linux/
- If the server executable is not available, follow the README.txt file to build it.
- Execute Siemens S7 server simulator and leave it running.
- For Windows: run
srv_resourceless.exe - For Linux: run
srv_resourceless
- For Windows: run
Note This server creates a DBArea number 3.
Create a session
- Start the FairCom Control Center.
- Sign in with the username and password. FairCom's default username is ADMIN (case-insensitive) and the password is ADMIN (case-sensitive).
Note When you log into the FairCom Control Center, a session is automatically created. Any request submitted in the API Console will have the"authToken"property automatically populated with that session's auth token. If you aren't following this tutorial inside the FairCom Control Center, you must first execute the createSession action and set the"authToken"property manually.
Create an Integration Table for Siemens S7 data
This procedure creates an Integration Table named siemensS7table in the faircom database to to store data received from a Siemens S7 source. The Integration Table automatically creates the create_ts, error, and source_payload JSON fields.
- Navigate to the Code tab from the sidebar menu and select API Console.
- Copy and paste the following code into the API Console request:
{ "action": "createIntegrationTable", "params": { "databaseName": "faircom", "ownerName": "admin", "tableName": "siemensS7table" }, "authToken": "replaceWithAuthTokenFromCreateSession" } - Click the Run button.
- Observe the response in the Output section and ensure the action is completed successfully.
Note An
"errorCode"with a value of0indicates success. An"errorCode"with a non-zero value indicates a failure. See Errors and contact FairCom for more information about an error.
Create Tags for this Integration Table
This procedure creates a tag. It represents a property in the table siemensS7table, field source_payload. The tag is also assigned to a user-defined field (flag1) and its value is automatically synchronized with the source_payload property.
- Copy and paste the following code into the API Console request:
{ "action": "createTag", "params": { "tagName": "flag1", "tableName": "siemensS7table", "tagDataType": "number", "sourcePayloadPath": "flag1", "sourceFieldName": "flag1", "sourceFieldType": "smallint" }, "authToken": "replaceWithAuthTokenFromCreateSession" } - Click the Run button.
- Observe the response in the Output section and ensure the action is completed successfully.
Capture Siemens S7 data in the Integration Table
This procedure creates an input that captures data from a Siemens S7 source and writes the incoming data to the siemensS7table Integration Table for subsequent processing.
- Copy and paste the following code into the API Console request:
{ "api": "hub", "action": "createInput", "params": { "inputName": "siemensS7input", "serviceName": "siemensS7", "tableName": "siemensS7table", "databaseName": "faircom", "dataCollectionIntervalMilliseconds": 5000, "settings": { "ipAddress": "127.0.0.1", "rack": 0, "slot": 2, "propertyMapList": [ { "propertyPath": "flag1", "memoryArea": "db", "dataBlockNumber": 3, "offset": 0, "dataType": "word" } ] } }, "authToken": "replaceWithAuthTokenFromCreateSession" } - Click the Run button.
- Observe the response and ensure the action is completed successfully.
Note An
"errorCode"with a value of0indicates success. An"errorCode"with a non-zero value indicates a failure. See Errors and contact FairCom for more information about an error.
That is all that is required to configure the FairCom server to read data from a device via the Siemens S7 protocol. Continue the tutorial to learn how to view the collected data, forward the collect data to a MQTT topic and how to write data to a Siemens S7 device.
View the transformed data
View the siemensS7Table table in the faircom database for the transformed data.
You can use either of these procedures to view the transformed data.
View transformed data through the Integration Tables navigation window
- Navigate to the Data tab from the sidebar menu and select Integration Tables.
- Click on the
siemenss7tabletable. - Click on the fields section.
- Search for and enable the
flag1field.

- For each piece of data collected, it is possible to see its values and information. For example, in the last record collected the
flag1value is 12593.

View transformed data through a SQL query
- Navigate to the Data tab from the sidebar menu and select SQL Commands.
- In the Statement section, enter and run the following SQL query:
SELECT id, flag1 from siemenss7table where flag1 > 2000 - Observe the response and ensure the action is completed successfully.
Query captured Modbus TCP data using the JSON API
- Navigate to the Code tab from the sidebar menu and select API Console.
- Copy and paste the following code into the API Console request to get data from
siemenss7tableusing the timestamp order (ts_index):{ "action": "getRecordsByIndex", "params": { "databaseName": "faircom", "tableName": "siemenss7table", "indexName": "ts_index" }, "authToken": "replaceWithAuthTokenFromCreateSession" } - Click the Run button.
- Observe the response in the Output section and ensure the action is completed successfully.
Forward captured data to an MQTT topic
Once Siemens S7 data is flowing into a table as JSON and is being transformed into discrete fields in the same table, forward the data out over MQTT.
- Navigate to the Code tab from the sidebar menu and select API Console.
- Copy and paste the following code into the API Console request:
{ "action": "configureTopic", "params": { "topic": "s7Forward", "databaseName": "faircom", "tableName": "siemensS7Table" }, "authToken": "replaceWithAuthTokenFromCreateSession" }
- Click the Run button.
- Observe the response in the Output section and ensure the action is completed successfully.
- Subscribe to the MQTT topic to verify that your data was forwarded.
- Navigate to the MQ tab from the sidebar menu and select Messages.
- Click the Add Subscription button. In the Topic filter search bar, select "s7Forward" and click Subscribe. As soon as new data is read, messages will appear in the Messages section.

Configure Siemens S7 to output data to a device
The following example configures a Siemens S7 connector to output data to a Siemens S7 device. When MQTT, SQL, JSON DB, or an input connector inserts a record into the siemensS7table integration table, the FairCom server delivers the record to the Siemens S7 connector. This example configures the Siemens S7 connector to extract the value of the flag1 property from the record’s source_payload field and write it to offset 32 in the DB3 area using the Siemens S7 protocol.
- Navigate to the Code tab from the sidebar menu and select API Console.
- Copy and paste the following code into the API Console request:
{
"action": "createOutput",
"params": {
"outputName": "siemensS7Output",
"serviceName": "siemensS7",
"tableName": "siemensS7table",
"databaseName": "faircom",
"settings": {
"ipAddress": "127.0.0.1",
"rack": 0,
"slot": 2,
"propertyMapList": [
{
"propertyPath": "flag1",
"memoryArea": "db",
"dataBlockNumber": 3,
"offset": 32,
"dataType": "word"
}
]
}
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}
- Click the Run button.
- Observe the response in the Output section and ensure the action is completed successfully.
- At the command prompt window in which the command
srv_resourceless.exeis running, it should be possible to see the data being read from offset 0 and written back at offset 32. (The actual value written may vary.)
Read Request
Area : DB3, Start : 0, Size : 1
Write Request
Area : DB3, Start : 32, Size : 1
0x0000: 19 .