Connecting to the real world with Arduino

Package Contents


Step-by-step guide to running your first model using ModelPlug


A collection of examples to help you get started


Components to connect to the Firmata boards


Components to access the board I/O


Devices using I2C protocol


Internal classes used by the ModelPlug library


What Is ModelPlug?

ModelPlug is a library that allows you to connect your simulations with the real world. It uses an Arduino board (or compatible) to send analog and digital signals to physical devices and receive signals from them.

What Can You Do with It?

  • Interact with your model by using buttons, switches, knobs, etc.
  • Input sensor information, for example, about light, temperature, position, pressure, etc.
  • Use actuators like motors, servos and relays.
  • Quickly prototype your system by using System Modeler blocks.

With ModelPlug, you can combine simulation models and real hardware. For example, you can get data from your hardware, design a control and test it in real time.

You can build a real control panel and use it to control your simulation models.

Overview of the Components

ModelPlug provides the following components:

Analog input Reads analog values from the pins  
Digital input Reads digital values from the pins  
Analog output Writes analog values to the pins  
Digital output Writes digital values to the pins  
Servo control Writes the angle to servo motors  
   Board Handlers  
Arduino Connects to Arduino boards like Arduino Uno, Arduino Mega 2560  
Arduino Leonardo Connects to Arduino Leonardo boards and boards using native USB  
StandardFirmata Connects to Arduino-compatible boards  
CustomFirmata Connects to any board supporting Firmata  

How Does It Work?

ModelPlug connects with the boards using USB serial communication. In order to configure, read and write to the board, ModelPlug uses the Firmata protocol v2.3 (http://www.firmata.org). This protocol allows you to connect not only to Arduinos, but also to many boards compatible with Arduino. Examples of other boards supporting the Firmata protocol are:

  • Teensy Development Board: Using AVR or ARM processors
  • chipKIT: Using PIC32 processors

ModelPlug wraps the functionality of Firmata by providing easy-to-use Modelica models that you can connect in your simulations.


  • ModelPlug requires a board with Firmata Version 2.3 or higher.
  • Currently ModelPlug does not support sensors that communicate through SPI with the board.
  • The minimum synchronization interval is 1 ms; therefore, ModelPlug cannot have a sampling interval smaller than that. The standard Firmata allows a minimum sampling interval of 10 ms.
  • ModelPlug uses a serial protocol; therefore, the transfer speed is constrained by the serial port speed. This can be problematic when reading or writing too many inputs/outputs with a small sampling interval.


Ask questions about System Modeler and ModelPlug:

Find out how to connect sensors and actuators to the Arduino:

Firmata protocol documentation:

The breadboard diagrams were created using Fritzing.

Wolfram Language



New in Version 2.0

  • Library compatible with Modelica Standard Library 4.0.0
  • Fix Modelica Language incompatibilities

New in Version 1.4.2

  • Support for Apple Silicon platform

New in Version 1.4.1

  • Fix compatibility issues on macOS
  • Fix Modelica Language incompatibilities

New in Version 1.4

  • Adds support for I2C devices
  • Includes documentation on how to connect to custom I2C devices

New in Version 1.3.1

  • Now compatible with Modelica library Version 3.2.3

New in Version 1.3

  • Added stored plots to examples for easy plotting of relevant variables
  • Now compatible with Modelica library Version 3.2.2

New in Version 1.2

  • Allows defining initial values in AnalogInput and DigitalInput Pins
  • Improved support for Windows 10