Skip to content

BACnet Simulated Device

Edge Xpert provides a simulated BACnet device named bacnet-server. It is implemented with Lua scripting and is based on the BACnet Protocol Stack.

The BACnet simulated device can run in both IP and MSTP modes, but this must first be configured prior to use.

Configuring the Simulator

Edge Xpert provides the following default configuration in the supplied docker-compose.yml file.

    image: iotechsys/bacnet-server:${EDGEXPERT_IMAGE_VERSION}
    container_name: bacnet-server
    hostname: bacnet-server
    command: "--script /example-scripts/device-service-example.lua --instance 123 --name SimpleServer"
      - edgex-network
    restart: always
      RUN_MODE: "IP"
    logging: *default-logging


Ensure RUN_MODE is set to your desired mode. IP is the default setting. This should be changed to MSTP if using BACnet/MSTP.

The command field contains arguments necessary to run the Lua script, these are detailed further below. It is advised to leave this command as defined in the docker-compose.yml. However, if --name or --instance are modified in the command, these changes should be reflected when provisioning the device.

In order to run the server in the correct mode, we can create a new docker-compose.yml file to override the default environment variable. For further information on this, refer to the configuration section of BACnet/IP or BACnet/MSTP.

Server Options

Several arguments can be included when running the simulator which are described below.

Option Arguments Description Example Default if not set
--instance instance
Instance ID of the device
Set the BACnet instance ID of the device on the network --instance 123 1234
--name name
Name of the device
Sets the device object name --name SimpleServer SimpleServer
--script script
Path to the lua script
Passes a lua script to the simulator which is used to create a simulated device --script device-service-example.lua Populate the simulator with 1 instance of every object
--populate populate
Number of instances for each object
Creates a specified number of instances for each type of bacnet object. Used to pad out the simulator with many object instances. --populate 10 Populate the simulator with 1 instance of every object


The arguments populate and script should not be used at the same time

Environment Variables

As the simulator can run in either IP or MSTP mode, the environment variable, RUN_MODE, must be set to specify the running mode.

Option Expected Values Description
RUN_MODE IP / MSTP Controls whether the simulator will run as an IP or MSTP device


If this is not set, the device will default to IP

Configuring the Device Service

Running in IP mode

The BACnet Simulated Device is treated as a foreign device, and as such, BBMD configuration is required. This must be configured prior to starting the BACnet Device Service.

Start the simulation:

edgexpert up bacnet-server

The IP address of the bacnet-server container is required for configuration and can be found by running the following command:

edgexpert ip

This should list all the IP addresses of the Edge Xpert containers alphabetically. After retrieving the IP address, the BBMD environment variables in the device-bacnet-ip entry of your local docker-compose.yml can be set:

Environment Variable Value Notes
BACNET_BBMD_ADDRESS < bacnet-server IP address> Paste the value received from edgexpert ip here
BACNET_BBMD_PORT 47808 The default port used BACnet

Once configured and saved, the BACnet Device service can be started as described in the BACnet/IP example.

Running in MSTP mode

To simulate the connection between the device service and simulator, create a serial connection to the container using the bacnet-server IP address and set the port to /tmp/virtualport:

socat pty,link=/tmp/virtualport,raw,echo=0 tcp:<IP_of_bacnet-server>:55000

The BACNET_SERIAL_INTERFACE environment variable in the device-bacnet-mstp entry of your local docker-compose.yml should be set to match.

Environment Variable Value Notes
BACNET_SERIAL_INTERFACE /tmp/virtualport Path to the RS-485 connection on the host. No default, this must be set by the user

Once configured and saved, the BACnet Device service can then be started as described in the BACnet/MSTP example.

Back to top